Author: ron.sigal(a)jboss.com
Date: 2008-04-22 04:32:22 -0400 (Tue, 22 Apr 2008)
New Revision: 4037
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java
Log:
JBREM-966: Replace getRandomStartingPort() with simple call to SecureRandom.nextInt().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java 2008-04-22
07:14:18 UTC (rev 4036)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java 2008-04-22
08:32:22 UTC (rev 4037)
@@ -162,13 +162,12 @@
}
public static int getRandomStartingPort()
- {
- Object o = new Object();
- String os = o.toString();
- os = os.substring(17);
- int n = Integer.parseInt(os, 16);
- int p = Math.abs(new SecureRandom(String.valueOf(System.currentTimeMillis() +
n).getBytes()).nextInt(2000)) + 2000;
- return p;
+ {
+ int minPort = 2000;
+ int maxPort = 65535;
+ int count = maxPort - minPort + 1;
+ int port = new SecureRandom().nextInt(count) + minPort;
+ return port;
}
public static void main(String args[])
Show replies by date