Simplified thread-safety for the `getGson` method 63/106063/2
authorChris André <chris.andre@yoppworks.com>
Thu, 16 Apr 2020 00:18:59 +0000 (20:18 -0400)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 19 Apr 2020 08:33:50 +0000 (08:33 +0000)
Issue-ID: SDC-2900
Signed-off-by: Chris Andre <chris.andre@yoppworks.com>
Change-Id: I8c687bb408a5e0b1e95316bdae6d53126bc82696

common-app-api/src/main/java/org/openecomp/sdc/common/util/GsonFactory.java

index 7c3bcb6..882422b 100644 (file)
@@ -26,13 +26,9 @@ import com.google.gson.GsonBuilder;
 public class GsonFactory {
        private static Gson gson = null;
 
-       public static Gson getGson() {
+       public static synchronized Gson getGson() {
                if (gson == null) {
-                       synchronized (GsonFactory.class) {
-                               if (gson == null) {
                                        gson = new GsonBuilder().disableHtmlEscaping().serializeNulls().create();
-                               }
-                       }
                }
 
                return gson;