Skip to content

Commit 89a0708

Browse files
rsafonsecayadvr
authored andcommitted
Fix findbugs DMI_RANDOM_USED_ONLY_ONCE warning in TransportAddress.java Changed to recommended SecureRandom instead of Random
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes apache#416
1 parent 4e0fe46 commit 89a0708

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎framework/ipc/src/org/apache/cloudstack/framework/transport/TransportAddress.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.apache.cloudstack.framework.transport;
2121

22-
import java.util.Random;
22+
import java.security.SecureRandom;
2323

2424
public class TransportAddress {
2525
public final static String LOCAL_SERVICE_NODE = "";
@@ -29,6 +29,7 @@ public class TransportAddress {
2929
private int _connectionId = LOCAL_SERVICE_CONNECTION;
3030
private String _endpointId;
3131
private int _magic;
32+
private final SecureRandom randomGenerator=new SecureRandom();
3233

3334
public TransportAddress(String nodeId, int connectionId, String endpointId) {
3435
assert (nodeId != null);
@@ -39,7 +40,7 @@ public TransportAddress(String nodeId, int connectionId, String endpointId) {
3940
_nodeId = nodeId;
4041
_connectionId = connectionId;
4142
_endpointId = endpointId;
42-
_magic = new Random().nextInt();
43+
_magic = randomGenerator.nextInt();
4344
}
4445

4546
public TransportAddress(String nodeId, int connectionId, String endpointId, int magic) {

0 commit comments

Comments
 (0)