From a622fa7443c6f051ee7ea773cded44f658946100 Mon Sep 17 00:00:00 2001 From: Erich Duda Date: Fri, 6 May 2016 07:54:51 +0200 Subject: [PATCH] ARTEMIS-518 - Improvement of default thread factory --- .../artemis/cli/commands/tools/PrintData.java | 5 +++-- .../cli/commands/tools/XmlDataExporter.java | 7 ++++--- .../artemis/utils/ActiveMQThreadFactory.java | 5 +++++ .../activemq/artemis/utils/UUIDGenerator.java | 4 ++-- .../artemis/utils/ReferenceCounterTest.java | 4 ++-- .../activemq/artemis/ClientThreadPoolsTest.java | 3 ++- .../jdbc/file/JDBCSequentialFileFactoryTest.java | 3 ++- .../artemis/jms/bridge/impl/JMSBridgeImpl.java | 5 ++++- .../context/AbstractConnectionContextTest.java | 3 ++- .../proton/plug/test/invm/InVMTestConnector.java | 3 ++- .../org/proton/plug/test/invm/ProtonINVMSPI.java | 7 ++++--- .../test/minimalclient/SimpleAMQPConnector.java | 3 ++- .../test/minimalserver/MinimalConnectionSPI.java | 3 ++- .../plug/test/minimalserver/MinimalServer.java | 3 ++- .../artemis/rest/MessageServiceManager.java | 3 ++- .../core/remoting/impl/invm/InVMConnector.java | 6 +++--- .../PropertiesLoginModuleRaceConditionTest.java | 3 ++- .../server/impl/ScheduledDeliveryHandlerTest.java | 5 +++-- .../artemis/tests/util/ActiveMQTestBase.java | 3 ++- .../byteman/HierarchicalObjectRepositoryTest.java | 3 ++- .../tests/integration/client/CoreClientTest.java | 3 ++- .../distribution/ClusteredGroupingTest.java | 3 ++- .../journal/NIOJournalCompactTest.java | 5 +++-- .../openwire/amq/JMSConsumer2Test.java | 3 ++- .../paging/MultipleProducersPagingTest.java | 3 ++- .../server/AddressFullLoggingTest.java | 3 ++- .../integration/server/FileLockTimeoutTest.java | 3 ++- .../server/SuppliedThreadPoolTest.java | 5 +++-- .../timing/core/server/impl/QueueImplTest.java | 7 ++++--- .../asyncio/MultiThreadAsynchronousFileTest.java | 2 +- .../core/paging/impl/PagingStoreImplTest.java | 3 ++- .../impl/OperationContextUnitTest.java | 7 ++++--- .../impl/DuplicateDetectionUnitTest.java | 5 +++-- .../impl/netty/NettyAcceptorFactoryTest.java | 3 ++- .../remoting/impl/netty/NettyAcceptorTest.java | 3 ++- .../remoting/impl/netty/NettyConnectorTest.java | 15 ++++++++------- .../unit/core/server/impl/QueueImplTest.java | 5 +++-- .../core/server/impl/fakes/FakeQueueFactory.java | 5 +++-- .../artemis/tests/util/SpawnedVMSupport.java | 3 ++- 39 files changed, 104 insertions(+), 63 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java index cdc1bbff1a..9256acc4a1 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java @@ -54,6 +54,7 @@ import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager; import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ExecutorFactory; @Command(name = "print", description = "Print data records information (WARNING: don't use while a production server is running)") @@ -139,8 +140,8 @@ public class PrintData extends LockAbstract { Set pgTXs = cursorACKs.getPgTXs(); - ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1); - final ExecutorService executor = Executors.newFixedThreadPool(10); + ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); + final ExecutorService executor = Executors.newFixedThreadPool(10, ActiveMQThreadFactory.defaultThreadFactory()); ExecutorFactory execfactory = new ExecutorFactory() { @Override public Executor getExecutor() { diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java index 2556db07d2..c3deae4940 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/XmlDataExporter.java @@ -87,6 +87,7 @@ import org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFac import org.apache.activemq.artemis.jms.persistence.config.PersistedDestination; import org.apache.activemq.artemis.jms.persistence.config.PersistedType; import org.apache.activemq.artemis.jms.persistence.impl.journal.JMSJournalStorageManagerImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.Base64; import org.apache.activemq.artemis.utils.ExecutorFactory; @@ -142,7 +143,7 @@ public final class XmlDataExporter extends LockAbstract { String pagingDir, String largeMessagesDir) throws Exception { config = new ConfigurationImpl().setBindingsDirectory(bindingsDir).setJournalDirectory(journalDir).setPagingDirectory(pagingDir).setLargeMessagesDirectory(largeMessagesDir).setJournalType(JournalType.NIO); - final ExecutorService executor = Executors.newFixedThreadPool(1); + final ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); ExecutorFactory executorFactory = new ExecutorFactory() { @Override public Executor getExecutor() { @@ -678,8 +679,8 @@ public final class XmlDataExporter extends LockAbstract { */ private void printPagedMessagesAsXML() { try { - ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1); - final ExecutorService executor = Executors.newFixedThreadPool(10); + ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); + final ExecutorService executor = Executors.newFixedThreadPool(10, ActiveMQThreadFactory.defaultThreadFactory()); ExecutorFactory executorFactory = new ExecutorFactory() { @Override public Executor getExecutor() { diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java index 169ce9abfa..3a4de3e53e 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java @@ -89,4 +89,9 @@ public final class ActiveMQThreadFactory implements ThreadFactory { return t; } + public static ActiveMQThreadFactory defaultThreadFactory() { + String callerClassName = Thread.currentThread().getStackTrace()[2].getClassName(); + return new ActiveMQThreadFactory(callerClassName, false, null); + } + } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java index ea426dbd68..627fa86fae 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java @@ -133,7 +133,7 @@ public final class UUIDGenerator { public static byte[] getHardwareAddress() { try { // check if we have enough security permissions to create and shutdown an executor - ExecutorService executor = Executors.newFixedThreadPool(1); + ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); executor.shutdownNow(); } catch (Throwable t) { @@ -259,7 +259,7 @@ public final class UUIDGenerator { } private static byte[] findFirstMatchingHardwareAddress(List ifaces) { - ExecutorService executor = Executors.newFixedThreadPool(ifaces.size()); + ExecutorService executor = Executors.newFixedThreadPool(ifaces.size(), ActiveMQThreadFactory.defaultThreadFactory()); Collection> tasks = new ArrayList<>(ifaces.size()); for (final NetworkInterface networkInterface : ifaces) { diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java index e02c8bc587..0616f57b7c 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ReferenceCounterTest.java @@ -48,14 +48,14 @@ public class ReferenceCounterTest extends Assert { @Test public void testReferenceWithExecutor() throws Exception { - ExecutorService executor = Executors.newSingleThreadExecutor(); + ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); internalTestReferenceNoExecutor(executor); executor.shutdown(); } @Test public void testReferenceValidExecutorUsed() throws Exception { - ExecutorService executor = Executors.newSingleThreadExecutor(); + ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); LatchRunner runner = new LatchRunner(); ReferenceCounterUtil counter = new ReferenceCounterUtil(runner, executor); counter.increment(); diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java index 1f99eef67d..75b871dc4d 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java @@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -106,7 +107,7 @@ public class ClientThreadPoolsTest { 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); - ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = (ScheduledThreadPoolExecutor)Executors.newScheduledThreadPool(1); + ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = (ScheduledThreadPoolExecutor)Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); ActiveMQClient.injectPools(poolExecutor, scheduledThreadPoolExecutor); diff --git a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java index 554f36b832..bd200bd058 100644 --- a/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java +++ b/artemis-jdbc-store/src/test/java/org/apache/activemq/artemis/jdbc/file/JDBCSequentialFileFactoryTest.java @@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile; import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.derby.jdbc.EmbeddedDriver; import org.junit.After; import org.junit.Before; @@ -55,7 +56,7 @@ public class JDBCSequentialFileFactoryTest { @Before public void setup() throws Exception { - Executor executor = Executors.newSingleThreadExecutor(); + Executor executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); factory = new JDBCSequentialFileFactory(connectionUrl, tableName, className, executor); factory.start(); diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java index 3a8e519aeb..e5168e77f4 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java @@ -1597,9 +1597,12 @@ public final class JMSBridgeImpl implements JMSBridge { */ private ExecutorService createExecutor() { ExecutorService service = Executors.newFixedThreadPool(3, new ThreadFactory() { + + ThreadGroup group = new ThreadGroup("JMSBridgeImpl"); + @Override public Thread newThread(Runnable r) { - final Thread thr = new Thread(r); + final Thread thr = new Thread(group, r); if (moduleTccl != null) { AccessController.doPrivileged(new PrivilegedAction() { @Override diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java index ea84e43229..1cf7bb2538 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.Executors; import io.netty.buffer.ByteBuf; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.qpid.proton.engine.Connection; import org.apache.qpid.proton.engine.Link; import org.apache.qpid.proton.engine.Session; @@ -50,7 +51,7 @@ public class AbstractConnectionContextTest { private class TestConnectionContext extends AbstractConnectionContext { public TestConnectionContext(AMQPConnectionCallback connectionCallback) { - super(connectionCallback, Executors.newSingleThreadExecutor(), null); + super(connectionCallback, Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()), null); } @Override diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/InVMTestConnector.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/InVMTestConnector.java index 0843c49396..197c39ea89 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/InVMTestConnector.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/InVMTestConnector.java @@ -18,6 +18,7 @@ package org.proton.plug.test.invm; import java.util.concurrent.Executors; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.proton.plug.AMQPClientConnectionContext; import org.proton.plug.context.client.ProtonClientConnectionContext; import org.proton.plug.test.minimalclient.Connector; @@ -34,6 +35,6 @@ public class InVMTestConnector implements Connector { @Override public AMQPClientConnectionContext connect(String host, int port) throws Exception { - return new ProtonClientConnectionContext(new ProtonINVMSPI(), Executors.newSingleThreadExecutor(), null); + return new ProtonClientConnectionContext(new ProtonINVMSPI(), Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()), null); } } diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/ProtonINVMSPI.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/ProtonINVMSPI.java index 8e2177ddb0..ba65727207 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/ProtonINVMSPI.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/invm/ProtonINVMSPI.java @@ -20,6 +20,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import io.netty.buffer.ByteBuf; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.proton.plug.AMQPConnectionContext; import org.proton.plug.AMQPConnectionCallback; import org.proton.plug.AMQPSessionCallback; @@ -35,11 +36,11 @@ public class ProtonINVMSPI implements AMQPConnectionCallback { AMQPConnectionContext returningConnection; - ProtonServerConnectionContext serverConnection = new ProtonServerConnectionContext(new ReturnSPI(), Executors.newSingleThreadExecutor(), null); + ProtonServerConnectionContext serverConnection = new ProtonServerConnectionContext(new ReturnSPI(), Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()), null); - final ExecutorService mainExecutor = Executors.newSingleThreadExecutor(); + final ExecutorService mainExecutor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); - final ExecutorService returningExecutor = Executors.newSingleThreadExecutor(); + final ExecutorService returningExecutor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); public ProtonINVMSPI() { mainExecutor.execute(new Runnable() { diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalclient/SimpleAMQPConnector.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalclient/SimpleAMQPConnector.java index 122477b72a..59772f079b 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalclient/SimpleAMQPConnector.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalclient/SimpleAMQPConnector.java @@ -29,6 +29,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInitializer; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.proton.plug.AMQPClientConnectionContext; import org.proton.plug.context.client.ProtonClientConnectionContextFactory; @@ -60,7 +61,7 @@ public class SimpleAMQPConnector implements Connector { AMQPClientSPI clientConnectionSPI = new AMQPClientSPI(future.channel()); - final AMQPClientConnectionContext connection = (AMQPClientConnectionContext) ProtonClientConnectionContextFactory.getFactory().createConnection(clientConnectionSPI, Executors.newSingleThreadExecutor(), null); + final AMQPClientConnectionContext connection = (AMQPClientConnectionContext) ProtonClientConnectionContextFactory.getFactory().createConnection(clientConnectionSPI, Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()), null); future.channel().pipeline().addLast(new ChannelDuplexHandler() { @Override diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalConnectionSPI.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalConnectionSPI.java index 412114fe1a..32f3007add 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalConnectionSPI.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalConnectionSPI.java @@ -24,6 +24,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.proton.plug.AMQPConnectionContext; import org.proton.plug.AMQPConnectionCallback; import org.proton.plug.AMQPSessionCallback; @@ -44,7 +45,7 @@ public class MinimalConnectionSPI implements AMQPConnectionCallback { this.channel = channel; } - ExecutorService executorService = Executors.newSingleThreadExecutor(); + ExecutorService executorService = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); @Override public void close() { diff --git a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java index 3677035035..7cb7861272 100644 --- a/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java +++ b/artemis-protocols/artemis-proton-plug/src/test/java/org/proton/plug/test/minimalserver/MinimalServer.java @@ -40,6 +40,7 @@ import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.util.ResourceLeakDetector; import io.netty.util.concurrent.GlobalEventExecutor; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.proton.plug.AMQPServerConnectionContext; import org.proton.plug.context.server.ProtonServerConnectionContextFactory; import org.proton.plug.test.Constants; @@ -125,7 +126,7 @@ public class MinimalServer { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); - connection = ProtonServerConnectionContextFactory.getFactory().createConnection(new MinimalConnectionSPI(ctx.channel()), Executors.newSingleThreadExecutor(), null); + connection = ProtonServerConnectionContextFactory.getFactory().createConnection(new MinimalConnectionSPI(ctx.channel()), Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()), null); //ctx.read(); } diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java index 014853d2f5..e9c853b9c3 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/MessageServiceManager.java @@ -40,6 +40,7 @@ import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.apache.activemq.artemis.rest.util.LinkStrategy; import org.apache.activemq.artemis.rest.util.TimeoutTask; import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.XMLUtil; public class MessageServiceManager { @@ -126,7 +127,7 @@ public class MessageServiceManager { } } if (threadPool == null) - threadPool = Executors.newCachedThreadPool(); + threadPool = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); timeoutTaskInterval = configuration.getTimeoutTaskInterval(); timeoutTask = new TimeoutTask(timeoutTaskInterval); threadPool.execute(timeoutTask); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java index 1a86e472bd..e239466f9c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java @@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -41,6 +40,7 @@ import org.apache.activemq.artemis.spi.core.remoting.ClientProtocolManager; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ConnectionLifeCycleListener; import org.apache.activemq.artemis.utils.ActiveMQThreadPoolExecutor; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ConfigurationHelper; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.jboss.logging.Logger; @@ -107,10 +107,10 @@ public class InVMConnector extends AbstractConnector { private static synchronized ExecutorService getInVMExecutor() { if (threadPoolExecutor == null) { if (ActiveMQClient.getGlobalThreadPoolSize() <= -1) { - threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), Executors.defaultThreadFactory()); + threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), ActiveMQThreadFactory.defaultThreadFactory()); } else { - threadPoolExecutor = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.getGlobalThreadPoolSize(), 60L, TimeUnit.SECONDS, Executors.defaultThreadFactory()); + threadPoolExecutor = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.getGlobalThreadPoolSize(), 60L, TimeUnit.SECONDS, ActiveMQThreadFactory.defaultThreadFactory()); } } return threadPoolExecutor; diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java index 8c39d180af..4fa9c71b9e 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/PropertiesLoginModuleRaceConditionTest.java @@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler; import org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoader; import org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -119,7 +120,7 @@ public class PropertiesLoginModuleRaceConditionTest { options.put("baseDir", temp.getRoot().getAbsolutePath()); errors = new ArrayBlockingQueue<>(processorCount()); - pool = Executors.newFixedThreadPool(processorCount()); + pool = Executors.newFixedThreadPool(processorCount(), ActiveMQThreadFactory.defaultThreadFactory()); callback = new JaasCallbackHandler(USERNAME, PASSWORD, null); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java index 04a587dfb0..71e04f9333 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java @@ -46,6 +46,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.RoutingContext; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.transaction.Transaction; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.LinkedListIterator; import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.ReferenceCounter; @@ -170,8 +171,8 @@ public class ScheduledDeliveryHandlerTest extends Assert { @Test public void testScheduleNow() throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(50); - ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1); + ExecutorService executor = Executors.newFixedThreadPool(50, ActiveMQThreadFactory.defaultThreadFactory()); + ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1, ActiveMQThreadFactory.defaultThreadFactory()); try { for (int i = 0; i < 100; i++) { // it's better to run the test a few times instead of run millions of messages here diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java index cf9ee846e0..e8fd9ef9f9 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java @@ -128,6 +128,7 @@ import org.apache.activemq.artemis.jlibaio.LibaioContext; import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -472,7 +473,7 @@ public abstract class ActiveMQTestBase extends Assert { } protected final OrderedExecutorFactory getOrderedExecutor() { - final ExecutorService executor = Executors.newCachedThreadPool(); + final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); executorSet.add(executor); return new OrderedExecutorFactory(executor); } diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java index 2c47bf03a4..50a626834d 100644 --- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java +++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/HierarchicalObjectRepositoryTest.java @@ -22,6 +22,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectRepository; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.jboss.byteman.contrib.bmunit.BMRule; import org.jboss.byteman.contrib.bmunit.BMRules; import org.jboss.byteman.contrib.bmunit.BMUnitRunner; @@ -49,7 +50,7 @@ public class HierarchicalObjectRepositoryTest { public void setUp() { latch = new CountDownLatch(1); latch2 = new CountDownLatch(1); - executor = Executors.newSingleThreadExecutor(); + executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); repo = new HierarchicalObjectRepository<>(); addToRepo(repo, A); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java index c9b8944b14..86bc765a78 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/CoreClientTest.java @@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Assert; import org.junit.Test; @@ -55,7 +56,7 @@ public class CoreClientTest extends ActiveMQTestBase { @Test public void testCoreClientWithInjectedThreadPools() throws Exception { - ExecutorService threadPool = Executors.newCachedThreadPool(); + ExecutorService threadPool = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(10); ServerLocator locator = createNonHALocator(false); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java index f2f3f3c80f..6cacd3c39a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java @@ -39,6 +39,7 @@ import org.apache.activemq.artemis.core.server.management.NotificationListener; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Test; import java.util.ArrayList; @@ -550,7 +551,7 @@ public class ClusteredGroupingTest extends ClusterTestBase { session.close(); // need thread pool to service both consumers and producers plus a thread to cycle nodes - ExecutorService executorService = Executors.newFixedThreadPool(groups.size() * 2 + 1); + ExecutorService executorService = Executors.newFixedThreadPool(groups.size() * 2 + 1, ActiveMQThreadFactory.defaultThreadFactory()); final AtomicInteger producerCounter = new AtomicInteger(0); final CountDownLatch okToConsume = new CountDownLatch(groups.size() + 1); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java index 0cd9557e72..f1b602f457 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/NIOJournalCompactTest.java @@ -49,6 +49,7 @@ import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl; import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.IDGenerator; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.SimpleIDGenerator; @@ -1627,11 +1628,11 @@ public class NIOJournalCompactTest extends JournalImplTestBase { final AtomicLong seqGenerator = new AtomicLong(1); - final ExecutorService executor = Executors.newCachedThreadPool(); + final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); OrderedExecutorFactory factory = new OrderedExecutorFactory(executor); - final ExecutorService deleteExecutor = Executors.newCachedThreadPool(); + final ExecutorService deleteExecutor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); final JournalStorageManager storage = new JournalStorageManager(config, factory, null); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java index f621740772..3f28aa74d1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JMSConsumer2Test.java @@ -32,6 +32,7 @@ import javax.jms.MessageListener; import javax.jms.Session; import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest; import org.junit.Test; @@ -93,7 +94,7 @@ public class JMSConsumer2Test extends BasicOpenWireTest { } } - final ExecutorService executor = Executors.newCachedThreadPool(); + final ExecutorService executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); consumer.setMessageListener(new MessageListener() { @Override public void onMessage(Message m) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java index 0adcc2f6ed..769f436188 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MultipleProducersPagingTest.java @@ -47,6 +47,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfi import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -73,7 +74,7 @@ public class MultipleProducersPagingTest extends ActiveMQTestBase { @Before public void setUp() throws Exception { super.setUp(); - executor = Executors.newCachedThreadPool(); + executor = Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()); AddressSettings addressSettings = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE).setPageSizeBytes(50000).setMaxSizeBytes(404850); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/AddressFullLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/AddressFullLoggingTest.java index 36f866a168..f315b89265 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/AddressFullLoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/AddressFullLoggingTest.java @@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -75,7 +76,7 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { final ClientMessage message = session.createMessage(false); message.getBodyBuffer().writeBytes(new byte[1024]); - ExecutorService executor = Executors.newFixedThreadPool(1); + ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); Callable sendMessageTask = new Callable() { @Override public Object call() throws ActiveMQException { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java index 95d2f8f0fd..70b5cb87f8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/FileLockTimeoutTest.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfigu import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.logs.AssertionLoggerHandler; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -70,7 +71,7 @@ public class FileLockTimeoutTest extends ActiveMQTestBase { server2.getConfiguration().setJournalLockAcquisitionTimeout(5000); // if something happens that causes the timeout to misbehave we don't want the test to hang - ExecutorService service = Executors.newSingleThreadExecutor(); + ExecutorService service = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); Runnable r = new Runnable() { @Override public void run() { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java index 8dda21595c..3a6f56bb90 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/SuppliedThreadPoolTest.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl; import org.apache.activemq.artemis.core.server.impl.ServiceRegistryImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -42,8 +43,8 @@ public class SuppliedThreadPoolTest extends ActiveMQTestBase { @Before public void setup() throws Exception { serviceRegistry = new ServiceRegistryImpl(); - serviceRegistry.setExecutorService(Executors.newFixedThreadPool(1)); - serviceRegistry.setScheduledExecutorService(Executors.newScheduledThreadPool(1)); + serviceRegistry.setExecutorService(Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory())); + serviceRegistry.setScheduledExecutorService(Executors.newScheduledThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory())); server = new ActiveMQServerImpl(null, null, null, null, serviceRegistry); server.start(); server.waitForActivation(100, TimeUnit.MILLISECONDS); diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java index 4205294afc..18ab995ed1 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/server/impl/QueueImplTest.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.tests.timing.core.server.impl; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Before; import org.junit.After; @@ -69,7 +70,7 @@ public class QueueImplTest extends ActiveMQTestBase { @Test public void testScheduledNoConsumer() throws Exception { - QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor()); + QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory())); // Send one scheduled @@ -134,7 +135,7 @@ public class QueueImplTest extends ActiveMQTestBase { @Test public void testScheduled() throws Exception { - QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor()); + QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), new SimpleString("queue1"), null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory())); FakeConsumer consumer = null; @@ -232,7 +233,7 @@ public class QueueImplTest extends ActiveMQTestBase { public void disconnect() { } }; - QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), QueueImplTest.queue1, null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor()); + QueueImpl queue = new QueueImpl(1, new SimpleString("address1"), QueueImplTest.queue1, null, null, false, true, false, scheduledExecutor, null, null, null, Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory())); MessageReference messageReference = generateReference(queue, 1); queue.addConsumer(consumer); messageReference.setScheduledDeliveryTime(System.currentTimeMillis() + 2000); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java index 4806bf9e3c..6c638aef36 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java @@ -71,7 +71,7 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { public void setUp() throws Exception { super.setUp(); pollerExecutor = Executors.newCachedThreadPool(new ActiveMQThreadFactory("ActiveMQ-AIO-poller-pool" + System.identityHashCode(this), false, this.getClass().getClassLoader())); - executor = Executors.newSingleThreadExecutor(); + executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); } @Override diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java index 59d26462b8..d16da9f269 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/paging/impl/PagingStoreImplTest.java @@ -56,6 +56,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.util.FakePagingManager; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ExecutorFactory; import org.apache.activemq.artemis.utils.RandomUtil; import org.junit.After; @@ -770,7 +771,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase { @Before public void setUp() throws Exception { super.setUp(); - executor = Executors.newSingleThreadExecutor(); + executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); } @Override diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java index e1dd4cc012..e3321307e3 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/persistence/impl/OperationContextUnitTest.java @@ -26,6 +26,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQExceptionType; import org.apache.activemq.artemis.core.io.IOCallback; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.core.persistence.impl.journal.OperationContextImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Assert; import org.junit.Test; @@ -43,7 +44,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { @Test public void testCompleteTaskAfterPaging() throws Exception { - ExecutorService executor = Executors.newSingleThreadExecutor(); + ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); try { OperationContextImpl impl = new OperationContextImpl(executor); final CountDownLatch latch1 = new CountDownLatch(1); @@ -102,7 +103,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { @Test public void testCaptureExceptionOnExecutor() throws Exception { - ExecutorService executor = Executors.newSingleThreadExecutor(); + ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); executor.shutdown(); final CountDownLatch latch = new CountDownLatch(1); @@ -148,7 +149,7 @@ public class OperationContextUnitTest extends ActiveMQTestBase { @Test public void testCaptureExceptionOnFailure() throws Exception { - ExecutorService executor = Executors.newSingleThreadExecutor(); + ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); final CountDownLatch latch = new CountDownLatch(1); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java index c47041ac98..d99b4f0da8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/postoffice/impl/DuplicateDetectionUnitTest.java @@ -37,6 +37,7 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.postoffice.impl.DuplicateIDCacheImpl; import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader; import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ExecutorFactory; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.RandomUtil; @@ -69,7 +70,7 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { @Before public void setUp() throws Exception { super.setUp(); - executor = Executors.newSingleThreadExecutor(); + executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); factory = new OrderedExecutorFactory(executor); } @@ -89,7 +90,7 @@ public class DuplicateDetectionUnitTest extends ActiveMQTestBase { PostOffice postOffice = new FakePostOffice(); - ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize()); + ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory()); journal = new JournalStorageManager(configuration, factory, null); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java index 260fcfeaad..46d7aa3549 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java @@ -32,6 +32,7 @@ import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleListener; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Assert; import org.junit.Test; @@ -71,7 +72,7 @@ public class NettyAcceptorFactoryTest extends ActiveMQTestBase { }; - Acceptor acceptor = factory.createAcceptor("netty", null, params, handler, listener, Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize()), null); + Acceptor acceptor = factory.createAcceptor("netty", null, params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory()), null); Assert.assertTrue(acceptor instanceof NettyAcceptor); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java index 3b1b0253ba..1379628c6c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java @@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.spi.core.remoting.BufferHandler; import org.apache.activemq.artemis.spi.core.remoting.Connection; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -93,7 +94,7 @@ public class NettyAcceptorTest extends ActiveMQTestBase { public void connectionReadyForWrites(Object connectionID, boolean ready) { } }; - pool2 = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize()); + pool2 = Executors.newScheduledThreadPool(ActiveMQDefaultConfiguration.getDefaultScheduledThreadPoolMaxSize(), ActiveMQThreadFactory.defaultThreadFactory()); NettyAcceptor acceptor = new NettyAcceptor("netty", null, params, handler, listener, pool2, null); addActiveMQComponent(acceptor); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java index 1888fb44ee..e8178ed29d 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java @@ -19,6 +19,7 @@ package org.apache.activemq.artemis.tests.unit.core.remoting.impl.netty; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Test; import java.util.HashMap; @@ -64,7 +65,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } }; - NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); connector.start(); Assert.assertTrue(connector.isStarted()); @@ -101,7 +102,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { }; try { - new NettyConnector(params, null, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + new NettyConnector(params, null, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); Assert.fail("Should throw Exception"); } @@ -110,7 +111,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } try { - new NettyConnector(params, handler, null, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + new NettyConnector(params, handler, null, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); Assert.fail("Should throw Exception"); } @@ -152,7 +153,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } }; - NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); System.setProperty(NettyConnector.JAVAX_KEYSTORE_PATH_PROP_NAME, "client-side-keystore.jks"); System.setProperty(NettyConnector.JAVAX_KEYSTORE_PASSWORD_PROP_NAME, "secureexample"); @@ -198,7 +199,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } }; - NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); System.setProperty(NettyConnector.JAVAX_KEYSTORE_PATH_PROP_NAME, "bad path"); System.setProperty(NettyConnector.JAVAX_KEYSTORE_PASSWORD_PROP_NAME, "bad password"); @@ -246,7 +247,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } }; - NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); connector.start(); Assert.assertTrue(connector.isStarted()); @@ -285,7 +286,7 @@ public class NettyConnectorTest extends ActiveMQTestBase { } }; - NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), Executors.newScheduledThreadPool(5)); + NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newCachedThreadPool(ActiveMQThreadFactory.defaultThreadFactory()), Executors.newScheduledThreadPool(5, ActiveMQThreadFactory.defaultThreadFactory())); connector.start(); Assert.assertTrue(connector.isStarted()); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java index b1432e2776..e21d6d9e38 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/QueueImplTest.java @@ -47,6 +47,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.ServerMessage; import org.apache.activemq.artemis.core.server.impl.QueueImpl; import org.apache.activemq.artemis.core.settings.impl.AddressSettings; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.FutureLatch; import org.apache.activemq.artemis.utils.LinkedListIterator; import org.junit.After; @@ -65,8 +66,8 @@ public class QueueImplTest extends ActiveMQTestBase { @Before public void setUp() throws Exception { super.setUp(); - scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); - executor = Executors.newSingleThreadExecutor(); + scheduledExecutor = Executors.newSingleThreadScheduledExecutor(ActiveMQThreadFactory.defaultThreadFactory()); + executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); } @Override diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeQueueFactory.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeQueueFactory.java index 021915349d..b507d3e814 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeQueueFactory.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/server/impl/fakes/FakeQueueFactory.java @@ -27,12 +27,13 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice; import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.QueueFactory; import org.apache.activemq.artemis.core.server.impl.QueueImpl; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; public class FakeQueueFactory implements QueueFactory { - private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); + private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor(ActiveMQThreadFactory.defaultThreadFactory()); - private final ExecutorService executor = Executors.newSingleThreadExecutor(); + private final ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); private PostOffice postOffice; diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java index b88786c07d..dc81bc6933 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java @@ -30,6 +30,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeoutException; import org.apache.activemq.artemis.tests.unit.UnitTestLogger; +import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.junit.Assert; import static java.util.concurrent.TimeUnit.SECONDS; @@ -160,7 +161,7 @@ public final class SpawnedVMSupport { public static void assertProcessExits(final boolean sameValue, final int value, final Process p) throws InterruptedException, ExecutionException, TimeoutException { - ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); + ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(ActiveMQThreadFactory.defaultThreadFactory()); Future future = executor.submit(new Callable() { @Override