diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/RmiRegistryFactory.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/RmiRegistryFactory.java index ed505a7d22..2589204f77 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/RmiRegistryFactory.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/RmiRegistryFactory.java @@ -63,7 +63,7 @@ public class RmiRegistryFactory { * Create a server socket for testing purposes. */ ServerSocket createTestSocket() throws IOException { - return socketFactory.createServerSocket(1100); + return socketFactory.createServerSocket(0); } public Object getObject() throws Exception { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXRMIRegistryPortTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXRMIRegistryPortTest.java index c5e7f6002a..ac2741728e 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXRMIRegistryPortTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXRMIRegistryPortTest.java @@ -31,7 +31,7 @@ public class JMXRMIRegistryPortTest extends ActiveMQTestBase { public void explicitLocalhostRegistry() throws IOException { RmiRegistryFactory registryFactory = new RmiRegistryFactory(); registryFactory.setHost("localhost"); - registryFactory.setPort(1099); + registryFactory.setPort(0); registryFactory.init(); runAfter(registryFactory::destroy); try (ServerSocket testSocket = registryFactory.createTestSocket()) { @@ -43,7 +43,7 @@ public class JMXRMIRegistryPortTest extends ActiveMQTestBase { public void unlimitedHostRegistry() throws IOException { RmiRegistryFactory registryFactory = new RmiRegistryFactory(); registryFactory.setHost(null); - registryFactory.setPort(1099); + registryFactory.setPort(0); registryFactory.init(); runAfter(registryFactory::destroy); try (ServerSocket testSocket = registryFactory.createTestSocket()) {