From b3e58a5b33ecf3c1c0c7a8a99e4cd9ec71097ccb Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Mon, 8 Jul 2013 19:04:09 +0000 Subject: [PATCH] Apply patch for: https://issues.apache.org/jira/browse/AMQ-4588 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1500885 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/util/IdGenerator.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java b/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java index 049a684c11..954b48d9d3 100755 --- a/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java +++ b/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java @@ -35,6 +35,7 @@ public class IdGenerator { private String seed; private AtomicLong sequence = new AtomicLong(1); private int length; + public static final String PROPERTY_IDGENERATOR_PORT ="activemq.idgenerator.port"; static { String stub = ""; @@ -50,13 +51,19 @@ public class IdGenerator { if (canAccessSystemProps) { try { + int idGeneratorPort = Integer.parseInt(System.getProperty(PROPERTY_IDGENERATOR_PORT, "0")); + LOG.trace("Using port {}", idGeneratorPort); hostName = InetAddressUtil.getLocalHostName(); - ServerSocket ss = new ServerSocket(0); + ServerSocket ss = new ServerSocket(idGeneratorPort); stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-"; Thread.sleep(100); ss.close(); } catch (Exception ioe) { - LOG.warn("could not generate unique stub by using DNS and binding to local port", ioe); + if (LOG.isTraceEnabled()) { + LOG.trace("could not generate unique stub by using DNS and binding to local port", ioe); + } else { + LOG.warn("could not generate unique stub by using DNS and binding to local port: {} {}", ioe.getClass().getCanonicalName(), ioe.getMessage()); + } } } // fallback