You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/07/23 10:05:29 UTC
[4/5] git commit: camel-jms reply manager should use AC classloader
to avoid using current thread CL which may lead to CL issues in OSGi
deployments.
camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5e8235a8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e8235a8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e8235a8
Branch: refs/heads/camel-2.11.x
Commit: 5e8235a80449e795484127ac89990dd7e7897eee
Parents: e118998
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 09:10:01 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 09:15:30 2013 +0200
----------------------------------------------------------------------
.../org/apache/camel/component/jms/JmsProducer.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5e8235a8/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
index ec93dd8..4bf5598 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
@@ -75,7 +75,16 @@ public class JmsProducer extends DefaultAsyncProducer {
if (started.get()) {
return;
}
+
+ // must use the classloader from the application context when creating reply manager,
+ // as it should inherit the classloader from app context and not the current which may be
+ // a different classloader
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ ClassLoader ac = endpoint.getCamelContext().getApplicationContextClassLoader();
try {
+ if (ac != null) {
+ Thread.currentThread().setContextClassLoader(ac);
+ }
// validate that replyToType and replyTo is configured accordingly
if (endpoint.getReplyToType() != null) {
// setting temporary with a fixed replyTo is not supported
@@ -96,6 +105,10 @@ public class JmsProducer extends DefaultAsyncProducer {
}
} catch (Exception e) {
throw new FailedToCreateProducerException(endpoint, e);
+ } finally {
+ if (ac != null) {
+ Thread.currentThread().setContextClassLoader(current);
+ }
}
started.set(true);
}