diff options
Diffstat (limited to 'sca-java-1.x/trunk/modules/core/src')
-rw-r--r-- | sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java index dd3a4f9ac3..becf5f9295 100644 --- a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java +++ b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java @@ -28,11 +28,12 @@ import org.apache.tuscany.sca.invocation.Message; */ public final class ThreadMessageContext { + // TUSCANY-3770: Used as a marker for detecting when thread context information can be removed + private static final Message msg = new MessageImpl(); + private static final ThreadLocal<Message> CONTEXT = new ThreadLocal<Message>() { @Override protected synchronized Message initialValue() { - Message msg = new MessageImpl(); - msg.setFrom(new EndpointReferenceImpl("/")); return msg; } }; @@ -58,6 +59,12 @@ public final class ThreadMessageContext { public static Message setMessageContext(Message context) { Message old = CONTEXT.get(); CONTEXT.set(context); + + // TUSCANY-3770: Remove thread context information when the request invocation has completed + if (context == msg) { + CONTEXT.remove(); + } + return old; } @@ -70,11 +77,13 @@ public final class ThreadMessageContext { return CONTEXT.get(); } - /** + // TUSCANY-3770: This method is no longer needed, as thread context information is removed implicitly + /* * Removes and state from the current thread to ensure that * any associated classloaders can be GCd - */ + * public static void removeMessageContext() { CONTEXT.remove(); } + */ } |