activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: [ARTEMIS-2163]: Classloading issue if artemis-commons is not in the same classloader as artemis-client-* or artemis-server.
Date Thu, 15 Nov 2018 14:28:12 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 9d680cc0b -> ea2bd9275


[ARTEMIS-2163]: Classloading issue if artemis-commons is not in the same classloader as artemis-client-*
or artemis-server.

* Passing the owner class to define the classloader to load classes via ClassLoadingUtil with
artemis-commons in a different classloader..

JIRA: https://issues.apache.org/jira/browse/ARTEMIS-2163


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/80525f1c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/80525f1c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/80525f1c

Branch: refs/heads/master
Commit: 80525f1c9165fde93fd3b0c73b77ff66fd02d1cb
Parents: 9d680cc
Author: Emmanuel Hugonnet <emmanuel.hugonnet+gitkraken@gmail.com>
Authored: Mon Nov 5 16:42:21 2018 +0100
Committer: Emmanuel Hugonnet <emmanuel.hugonnet+gitkraken@gmail.com>
Committed: Wed Nov 14 18:23:30 2018 +0100

----------------------------------------------------------------------
 .../apache/activemq/artemis/utils/ClassloadingUtil.java | 12 ++++++++++--
 .../core/client/impl/ClientSessionFactoryImpl.java      |  2 +-
 .../artemis/core/client/impl/ServerLocatorImpl.java     |  6 +++---
 .../core/remoting/impl/TransportConfigurationUtil.java  |  2 +-
 .../artemis/jms/client/ActiveMQConnectionFactory.java   |  2 +-
 .../core/deployers/impl/FileConfigurationParser.java    |  4 ++--
 6 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
index 9ea1b61..99c39e0 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ClassloadingUtil.java
@@ -35,7 +35,11 @@ public final class ClassloadingUtil {
    private static final String INSTANTIATION_EXCEPTION_MESSAGE = "Your class must have a
constructor without arguments. If it is an inner class, it must be static!";
 
    public static Object newInstanceFromClassLoader(final String className) {
-      ClassLoader loader = ClassloadingUtil.class.getClassLoader();
+      return newInstanceFromClassLoader(ClassloadingUtil.class, className);
+   }
+
+   public static Object newInstanceFromClassLoader(final Class<?> classOwner, final
String className) {
+      ClassLoader loader = classOwner.getClassLoader();
       try {
          Class<?> clazz = loader.loadClass(className);
          return clazz.newInstance();
@@ -60,7 +64,11 @@ public final class ClassloadingUtil {
    }
 
    public static Object newInstanceFromClassLoader(final String className, Object... objs)
{
-      ClassLoader loader = ClassloadingUtil.class.getClassLoader();
+      return newInstanceFromClassLoader(ClassloadingUtil.class, className, objs);
+   }
+
+   public static Object newInstanceFromClassLoader(final Class<?> classOwner, final
String className, Object... objs) {
+      ClassLoader loader = classOwner.getClassLoader();
       try {
          Class<?>[] parametersType = new Class<?>[objs.length];
          for (int i = 0; i < objs.length; i++) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
index daac8f3..b135677 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
@@ -982,7 +982,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal,
C
       return AccessController.doPrivileged(new PrivilegedAction<ConnectorFactory>()
{
          @Override
          public ConnectorFactory run() {
-            return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(connectorFactoryClassName);
+            return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(ClientSessionFactoryImpl.class,
connectorFactoryClassName);
          }
       });
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
index 972c9c7..856affd 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
@@ -278,8 +278,8 @@ public final class ServerLocatorImpl implements ServerLocatorInternal,
Discovery
       AccessController.doPrivileged(new PrivilegedAction<Object>() {
          @Override
          public Object run() {
-            loadBalancingPolicy = (ConnectionLoadBalancingPolicy) ClassloadingUtil.newInstanceFromClassLoader(connectionLoadBalancingPolicyClassName);
-            return null;
+               loadBalancingPolicy = (ConnectionLoadBalancingPolicy) ClassloadingUtil.newInstanceFromClassLoader(ServerLocatorImpl.class,
connectionLoadBalancingPolicyClassName);
+               return null;
          }
       });
    }
@@ -1888,7 +1888,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal,
Discovery
 
             String[] arrayInterceptor = interceptorList.split(",");
             for (String strValue : arrayInterceptor) {
-               Interceptor interceptor = (Interceptor) ClassloadingUtil.newInstanceFromClassLoader(strValue.trim());
+               Interceptor interceptor = (Interceptor) ClassloadingUtil.newInstanceFromClassLoader(ServerLocatorImpl.class,
strValue.trim());
                interceptors.add(interceptor);
             }
             return null;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java
index c6d8a5f..33bfbac 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/TransportConfigurationUtil.java
@@ -65,7 +65,7 @@ public class TransportConfigurationUtil {
          @Override
          public Object run() {
             try {
-               return ClassloadingUtil.newInstanceFromClassLoader(className);
+               return ClassloadingUtil.newInstanceFromClassLoader(TransportConfigurationUtil.class,
className);
             } catch (IllegalStateException e) {
                return null;
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
index 364862b..ac0f8eb 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnectionFactory.java
@@ -152,7 +152,7 @@ public class ActiveMQConnectionFactory extends JNDIStorable implements
Connectio
          AccessController.doPrivileged(new PrivilegedAction<Object>() {
             @Override
             public Object run() {
-               ClientProtocolManagerFactory protocolManagerFactory = (ClientProtocolManagerFactory)
ClassloadingUtil.newInstanceFromClassLoader(protocolManagerFactoryStr);
+               ClientProtocolManagerFactory protocolManagerFactory = (ClientProtocolManagerFactory)
ClassloadingUtil.newInstanceFromClassLoader(ActiveMQConnectionFactory.class, protocolManagerFactoryStr);
                serverLocator.setProtocolManagerFactory(protocolManagerFactory);
                return null;
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/80525f1c/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index 255cce6..00db3f8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -723,7 +723,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
       ActiveMQServerPlugin serverPlugin = AccessController.doPrivileged(new PrivilegedAction<ActiveMQServerPlugin>()
{
          @Override
          public ActiveMQServerPlugin run() {
-            return (ActiveMQServerPlugin) ClassloadingUtil.newInstanceFromClassLoader(clazz);
+            return (ActiveMQServerPlugin) ClassloadingUtil.newInstanceFromClassLoader(FileConfigurationParser.class,
clazz);
          }
       });
 
@@ -926,7 +926,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
       SecuritySettingPlugin securitySettingPlugin = AccessController.doPrivileged(new PrivilegedAction<SecuritySettingPlugin>()
{
          @Override
          public SecuritySettingPlugin run() {
-            return (SecuritySettingPlugin) ClassloadingUtil.newInstanceFromClassLoader(clazz);
+            return (SecuritySettingPlugin) ClassloadingUtil.newInstanceFromClassLoader(FileConfigurationParser.class,
clazz);
          }
       });
 


Mime
View raw message