This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new e86ea0f622 ARTEMIS-1759 classloader leaks in Core and JMS Client
e86ea0f622 is described below

commit e86ea0f622f059784aa9a66fd4fd15874ac660e6
Author: Justin Bertram <[email protected]>
AuthorDate: Fri Nov 14 13:46:13 2025 -0600

    ARTEMIS-1759 classloader leaks in Core and JMS Client
    
    Remove fields that hold stack-traces in a few classes. These are mostly
    unused and when they are used it is only for logging. The upside of
    having additional logging is not worth the risk of leaks and eventual
    OOME.
---
 .../core/client/impl/ClientSessionFactoryImpl.java   |  6 +-----
 .../artemis/core/client/impl/ServerLocatorImpl.java  |  4 ----
 .../artemis/jms/client/ActiveMQConnection.java       |  4 ----
 .../activemq/artemis/tests/util/ServerTestBase.java  | 20 +++++++++++---------
 .../artemis/tests/util/ActiveMQTestBase.java         | 19 ++++++++++---------
 5 files changed, 22 insertions(+), 31 deletions(-)

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 8f88423789..edce730c62 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
@@ -155,8 +155,6 @@ public class ClientSessionFactoryImpl implements 
ClientSessionFactoryInternal, C
 
    private volatile boolean closed;
 
-   public final Exception createTrace;
-
    public static final Set<CloseRunnable> CLOSE_RUNNABLES = 
Collections.synchronizedSet(new HashSet<>());
 
    private final ConfirmationWindowWarning confirmationWindowWarning;
@@ -207,8 +205,6 @@ public class ClientSessionFactoryImpl implements 
ClientSessionFactoryInternal, C
                           final List<Interceptor> incomingInterceptors,
                           final List<Interceptor> outgoingInterceptors,
                           final TransportConfiguration[] connectorConfigs) {
-      createTrace = new Exception();
-
       this.serverLocator = serverLocator;
 
       this.clientProtocolManager = serverLocator.newProtocolManager();
@@ -997,7 +993,7 @@ public class ClientSessionFactoryImpl implements 
ClientSessionFactoryInternal, C
             return true;
          }
       } catch (InterruptedException ignore) {
-         throw new ActiveMQInterruptedException(createTrace);
+         throw new ActiveMQInterruptedException(ignore);
       }
       return false;
    }
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 13c98a1106..91f96db155 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
@@ -182,8 +182,6 @@ public final class ServerLocatorImpl implements 
ServerLocatorInternal, Discovery
       return factories;
    }
 
-   private final Exception traceException = new Exception();
-
    private ServerLocatorConfig config = new ServerLocatorConfig();
 
    private String passwordCodec;
@@ -334,8 +332,6 @@ public final class ServerLocatorImpl implements 
ServerLocatorInternal, Discovery
                              final boolean useHA,
                              final DiscoveryGroupConfiguration 
discoveryGroupConfiguration,
                              final TransportConfiguration[] transportConfigs) {
-      traceException.fillInStackTrace();
-
       this.topology = Objects.requireNonNullElseGet(topology, () -> new 
Topology(this));
 
       this.ha = useHA;
diff --git 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
index 3f7d966edf..f5030a2087 100644
--- 
a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
+++ 
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
@@ -128,8 +128,6 @@ public class ActiveMQConnection extends 
ActiveMQConnectionForContextImpl impleme
 
    private ClientSession initialSession;
 
-   private final Exception creationStack;
-
    private ActiveMQConnectionFactory factoryReference;
 
    private final ConnectionFactoryOptions options;
@@ -168,8 +166,6 @@ public class ActiveMQConnection extends 
ActiveMQConnectionForContextImpl impleme
       this.cacheDestinations = cacheDestinations;
 
       this.enable1xPrefixes = enable1xPrefixes;
-
-      creationStack = new Exception();
    }
 
    /**
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServerTestBase.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServerTestBase.java
index ac62c5ad04..150eda011d 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServerTestBase.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ServerTestBase.java
@@ -35,6 +35,7 @@ import java.util.Set;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
 import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
 import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
 import org.apache.activemq.artemis.core.config.Configuration;
@@ -160,9 +161,9 @@ public abstract class ServerTestBase extends 
ArtemisTestCase {
          clearServers();
       }
 
-      List<Exception> exceptions;
+      List<ClientSessionFactory> csfs;
       try {
-         exceptions = checkCsfStopped();
+         csfs = checkCsfStopped();
       } finally {
          cleanupPools();
       }
@@ -170,9 +171,10 @@ public abstract class ServerTestBase extends 
ArtemisTestCase {
       InVMConnector.resetThreadPool();
 
       //clean up pools before failing
-      if (!exceptions.isEmpty()) {
-         for (Exception exception : exceptions) {
-            exception.printStackTrace(System.out);
+      if (!csfs.isEmpty()) {
+         System.out.println(csfs.size() + " ClientSessionFactories still 
running:");
+         for (ClientSessionFactory csf : csfs) {
+            System.out.println("\t" + csf.toString());
          }
          System.out.println(threadDump("Thread dump with reconnects 
happening"));
       }
@@ -569,19 +571,19 @@ public abstract class ServerTestBase extends 
ArtemisTestCase {
       return createServer(realFiles, createDefaultConfig(0, false), 
AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, -1, 
-1);
    }
 
-   private List<Exception> checkCsfStopped() throws Exception {
+   private List<ClientSessionFactory> checkCsfStopped() throws Exception {
       if (!Wait.waitFor(ClientSessionFactoryImpl.CLOSE_RUNNABLES::isEmpty, 
5_000)) {
          List<ClientSessionFactoryImpl.CloseRunnable> closeRunnables = new 
ArrayList<>(ClientSessionFactoryImpl.CLOSE_RUNNABLES);
-         List<Exception> exceptions = new ArrayList<>();
+         List<ClientSessionFactory> csfs = new ArrayList<>();
 
          if (!closeRunnables.isEmpty()) {
             for (ClientSessionFactoryImpl.CloseRunnable closeRunnable : 
closeRunnables) {
                if (closeRunnable != null) {
-                  exceptions.add(closeRunnable.stop().createTrace);
+                  csfs.add(closeRunnable.stop());
                }
             }
          }
-         return exceptions;
+         return csfs;
       }
 
       return Collections.emptyList();
diff --git 
a/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
 
b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index b9fca4bf92..e98ab6673d 100644
--- 
a/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ 
b/tests/artemis-test-support/src/main/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -299,9 +299,9 @@ public abstract class ActiveMQTestBase extends 
ArtemisTestCase {
 
          closeAllOtherComponents();
 
-         List<Exception> exceptions;
+         List<ClientSessionFactory> csfs;
          try {
-            exceptions = checkCsfStopped();
+            csfs = checkCsfStopped();
          } finally {
             cleanupPools();
          }
@@ -313,9 +313,10 @@ public abstract class ActiveMQTestBase extends 
ArtemisTestCase {
          assertAllExecutorsFinished();
 
          //clean up pools before failing
-         if (!exceptions.isEmpty()) {
-            for (Exception exception : exceptions) {
-               exception.printStackTrace(System.out);
+         if (!csfs.isEmpty()) {
+            System.out.println(csfs.size() + " ClientSessionFactories still 
running:");
+            for (ClientSessionFactory csf : csfs) {
+               System.out.println("\t" + csf.toString());
             }
             System.out.println(threadDump("Thread dump with reconnects 
happening"));
          }
@@ -1988,19 +1989,19 @@ public abstract class ActiveMQTestBase extends 
ArtemisTestCase {
       }
    }
 
-   private List<Exception> checkCsfStopped() throws Exception {
+   private List<ClientSessionFactory> checkCsfStopped() throws Exception {
       if (!Wait.waitFor(ClientSessionFactoryImpl.CLOSE_RUNNABLES::isEmpty, 
5_000)) {
          List<ClientSessionFactoryImpl.CloseRunnable> closeRunnables = new 
ArrayList<>(ClientSessionFactoryImpl.CLOSE_RUNNABLES);
-         List<Exception> exceptions = new ArrayList<>();
+         List<ClientSessionFactory> csfs = new ArrayList<>();
 
          if (!closeRunnables.isEmpty()) {
             for (ClientSessionFactoryImpl.CloseRunnable closeRunnable : 
closeRunnables) {
                if (closeRunnable != null) {
-                  exceptions.add(closeRunnable.stop().createTrace);
+                  csfs.add(closeRunnable.stop());
                }
             }
          }
-         return exceptions;
+         return csfs;
       }
 
       return Collections.emptyList();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to