From eb06c3532c133a9126bd45c5485087edf5e3ad54 Mon Sep 17 00:00:00 2001 From: huaxing Date: Fri, 10 Apr 2020 13:16:12 +0800 Subject: Fix sonar issues Issue-ID: POLICY-1913 Signed-off-by: huaxing Change-Id: Id1a9a6b6f7a9c8c74dd69bd0d30af05162a92cd1 --- .../onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'model/basic-model/src/main/java') 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); -- cgit 1.2.3-korg