summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2010-11-10 20:18:35 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2010-11-10 20:18:35 +0000
commit62e7ebe8f099a7c7093f6f9e27ec9302e3996971 (patch)
treeca9493b3729ae501358d886778a7c88f8724d819
parent7634f603f4fe1ee00645cf214904ed239b1a24d7 (diff)
Merge r1033012 TUSCANY-3770: Remove thread message context on completion of each request
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1033692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java17
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.1/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java5
2 files changed, 16 insertions, 6 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java b/sca-java-1.x/branches/sca-java-1.6.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java
index dd3a4f9ac3..becf5f9295 100644
--- a/sca-java-1.x/branches/sca-java-1.6.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java
+++ b/sca-java-1.x/branches/sca-java-1.6.1/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();
}
+ */
}
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/sca-java-1.x/branches/sca-java-1.6.1/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
index 27dd89d31b..81ae425de5 100644
--- a/sca-java-1.x/branches/sca-java-1.6.1/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
+++ b/sca-java-1.x/branches/sca-java-1.6.1/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
@@ -330,8 +330,9 @@ public class WebAppServletHost implements ServletHost {
instance = null;
servlets.clear();
LogFactory.release(this.getClass().getClassLoader());
- Introspector.flushCaches();
- ThreadMessageContext.removeMessageContext();
+ Introspector.flushCaches();
+ // TUSCANY-3770: thread message context now removed implicitly
+ //ThreadMessageContext.removeMessageContext();
}
public String getContextPath() {