diff options
author | huaxing <huaxing.jin@est.tech> | 2020-04-10 13:16:12 +0800 |
---|---|---|
committer | huaxing <huaxing.jin@est.tech> | 2020-04-15 10:39:36 +0800 |
commit | eb06c3532c133a9126bd45c5485087edf5e3ad54 (patch) | |
tree | c2cd6193b43d3c0fa51d5fa01f81558b9129c865 /model/basic-model/src/main/java | |
parent | 649740ca4ada4bf91f7bc223e5464c51b4d3b93d (diff) |
Fix sonar issues
Issue-ID: POLICY-1913
Signed-off-by: huaxing <huaxing.jin@est.tech>
Change-Id: Id1a9a6b6f7a9c8c74dd69bd0d30af05162a92cd1
Diffstat (limited to 'model/basic-model/src/main/java')
-rw-r--r-- | model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java index a60c609e2..35010bf4b 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java @@ -37,6 +37,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.apache.commons.lang3.StringUtils; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner; import org.onap.policy.apex.model.basicmodel.dao.converters.Uuid2String; @@ -64,6 +65,8 @@ public class AxKeyInfo extends AxConcept { private static final int MAX_DESCRIPTION_LENGTH_8192 = 8192; private static final int UUID_BYTE_LENGTH_16 = 16; + private static final Random sharedRandom = new Random(); + @EmbeddedId @XmlElement(name = "key", required = true) private AxArtifactKey key; @@ -331,11 +334,9 @@ public class AxKeyInfo extends AxConcept { * @return the uuid */ public static UUID generateReproducibleUuid(final String seed) { - final Random random; - if (seed != null && seed.length() > 0) { + Random random = sharedRandom; + if (!StringUtils.isEmpty(seed)) { random = new Random(seed.hashCode()); - } else { - random = new Random(); } final byte[] array = new byte[UUID_BYTE_LENGTH_16]; random.nextBytes(array); |