From 119fc53d7272184333b0a90fc911b988bc25d5a1 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 29 Apr 2019 11:43:05 -0400 Subject: Fix sonar issue with double compare The gson code to convert Double to Long/Integer use a direct comparison of the original double with a long. However, sonar does not like that so changed the code to use the Double.compare() method instead. Also fixed sonar issue with diamond operator. Addressed some sonar issues in ServiceManager. Addressed some sonar issues in Version. Change-Id: I0959603918d251db671e87e12c295c6ec911f427 Issue-ID: POLICY-1707 Signed-off-by: Jim Hahn --- .../java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java') diff --git a/gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java b/gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java index 3892a07f..e56f9dd3 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java +++ b/gson/src/main/java/org/onap/policy/common/gson/MapDoubleAdapterFactory.java @@ -55,7 +55,7 @@ public class MapDoubleAdapterFactory implements TypeAdapterFactory { TypeAdapter delegate = gson.getDelegateAdapter(this, type); - return new MapAdapter(delegate); + return new MapAdapter<>(delegate); } /** @@ -134,7 +134,7 @@ public class MapDoubleAdapterFactory implements TypeAdapterFactory { Double num = (Double) obj; long longval = num.longValue(); - if (num.doubleValue() == longval) { + if (Double.compare(num.doubleValue(), longval) == 0) { // it's integral - determine if it's an integer or a long int intval = (int) longval; -- cgit 1.2.3-korg