Skip to content
Browse files
NO-JIRA Fixing Thread Leakage on test from UDP thread
When running a UDP connection factory you have to either keep it running, or close it so the UDP thread is closed.
this is an issue for the testsuite as we validate for leaked threads. This needs to be fixed on the test.
  • Loading branch information
clebertsuconic committed Apr 26, 2022
1 parent 5e54159 commit 6a3df6412baee054a7acc2ca8dc99d5560dcbbfa
Showing 1 changed file with 21 additions and 0 deletions.
@@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.LinkedList;

import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
@@ -58,6 +59,7 @@
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.Wait;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -75,6 +77,23 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {

private TransportConfiguration liveTC;

private List<ActiveMQConnectionFactory> factories = new LinkedList<>();

// adding connection factories that need to be closed
// this is because UDP connection factories could hold a UDP thread running if they are not closed
private void addCF(ConnectionFactory factory) {
if (factory instanceof ActiveMQConnectionFactory) {

public void closeCFs() {
factories.forEach(cf -> {

public void testMultipleConnectionFactories() throws NamingException, JMSException {
Hashtable<String, Object> props = new Hashtable<>();
@@ -251,6 +270,7 @@ public void testRemoteCFWithUDP() throws NamingException, JMSException {
Context ctx = new InitialContext(props);

ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup("myConnectionFactory");

@@ -268,6 +288,7 @@ public void testRemoteCFWithUDPWithTransportConfig() throws NamingException, JMS
Context ctx = new InitialContext(props);

ActiveMQConnectionFactory cf = (ActiveMQConnectionFactory) ctx.lookup("myConnectionFactory");

DiscoveryGroupConfiguration discoveryGroupConfiguration = cf.getDiscoveryGroupConfiguration();
Assert.assertEquals(5000, discoveryGroupConfiguration.getRefreshTimeout());

0 comments on commit 6a3df64

Please sign in to comment.