diff options
author | 2021-10-08 09:21:18 +0200 | |
---|---|---|
committer | 2021-11-19 11:25:38 +0100 | |
commit | 6945b75aac0e6bc2bad6f824769b32842f06bc46 (patch) | |
tree | fb99e802250d9efd8ac5c75df85a76431bff3ba4 /lib/rlock | |
parent | 71031b0b238ee51affd8135fdd648d9a70a6970b (diff) |
Fix sonar Security Hotspots
Issue-ID: CCSDK-3491
Signed-off-by: sliard <samuel.liard@gmail.com>
Change-Id: I33787ccca2a8acd8085db6b2a915e8f2ac2511ec
Signed-off-by: Dan Timoney <dtimoney@att.com>
Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'lib/rlock')
3 files changed, 5 insertions, 1 deletions
diff --git a/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/LockHelperImpl.java b/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/LockHelperImpl.java index 63fe111df..a63b7d481 100644 --- a/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/LockHelperImpl.java +++ b/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/LockHelperImpl.java @@ -84,6 +84,7 @@ public class LockHelperImpl implements LockHelper { try { Thread.sleep(lockWait * 1000L); } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); } } } diff --git a/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/SynchronizedFunction.java b/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/SynchronizedFunction.java index e92700055..419977890 100644 --- a/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/SynchronizedFunction.java +++ b/lib/rlock/src/main/java/org/onap/ccsdk/features/lib/rlock/SynchronizedFunction.java @@ -1,5 +1,6 @@ package org.onap.ccsdk.features.lib.rlock; +import java.security.SecureRandom; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -99,6 +100,7 @@ public abstract class SynchronizedFunction { } private static String generateLockRequester() { - return "SynchronizedFunction-" + (int) (Math.random() * 1000000); + SecureRandom random = new SecureRandom(); + return "SynchronizedFunction-" + (random.nextInt() % 1000000); } } diff --git a/lib/rlock/src/test/java/org/onap/ccsdk/features/lib/rlock/TestLockHelper.java b/lib/rlock/src/test/java/org/onap/ccsdk/features/lib/rlock/TestLockHelper.java index cce377e2c..4f205d16d 100644 --- a/lib/rlock/src/test/java/org/onap/ccsdk/features/lib/rlock/TestLockHelper.java +++ b/lib/rlock/src/test/java/org/onap/ccsdk/features/lib/rlock/TestLockHelper.java @@ -42,6 +42,7 @@ public class TestLockHelper { try { Thread.sleep(500); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); log.warn("Thread interrupted: " + e.getMessage(), e); } |