You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/07/08 21:04:09 UTC
svn commit: r1500885 -
/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java
Author: tabish
Date: Mon Jul 8 19:04:09 2013
New Revision: 1500885
URL: http://svn.apache.org/r1500885
Log:
Apply patch for: https://issues.apache.org/jira/browse/AMQ-4588
Modified:
activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java
Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java?rev=1500885&r1=1500884&r2=1500885&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java (original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/IdGenerator.java Mon Jul 8 19:04:09 2013
@@ -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