summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-28 07:52:26 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-28 07:52:26 +0000
commitcc0f2b66367070cb9c00d2df4d78292bea5a31fc (patch)
treee0ad4e44e19366235ceadbeafdbd1d94045562f4
parentd908b383f94b5967dba572e41ad73aed9cd0c421 (diff)
Remove the default contents of he thread message context just in case that this is holding onto a classloader. Don't have proof that this is a problem on 2.x but was causing problems on 1.x
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@798432 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java12
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java3
2 files changed, 13 insertions, 2 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java
index f81e17c49b..13ce6510ae 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java
@@ -31,10 +31,10 @@ public final class ThreadMessageContext {
private static final ThreadLocal<Message> CONTEXT = new ThreadLocal<Message>() {
@Override
protected synchronized Message initialValue() {
- Message msg = new MessageImpl();
+ //Message msg = new MessageImpl();
// TODO - EPR - What to set as default?
//msg.setFrom(new EndpointReferenceImpl("/"));
- return msg;
+ return null;//msg;
}
};
@@ -70,4 +70,12 @@ public final class ThreadMessageContext {
public static Message getMessageContext() {
return CONTEXT.get();
}
+
+ /**
+ * 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/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index a35f078860..e01cb87d50 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -39,6 +39,7 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.core.assembly.ActivationException;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
import org.apache.tuscany.sca.node.Client;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFinder;
@@ -175,6 +176,8 @@ public class NodeImpl implements Node, Client {
manager.extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).removeUtility(compositeActivator);
this.compositeActivator = null;
this.proxyFactory = null;
+
+ ThreadMessageContext.removeMessageContext();
} catch (ActivationException e) {
throw new IllegalStateException(e);