SONAR suggestion - Synchronize initialization of static fields

Change-Id: I2ddf8220bda49f235ddfc5713174c11a147df354
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/SubjectFactories.java b/core/api/src/main/java/org/onosproject/net/config/basics/SubjectFactories.java
index 1eda703..aeaf84d 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/SubjectFactories.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/SubjectFactories.java
@@ -140,7 +140,7 @@
      *
      * @param service core service reference
      */
-    public static void setCoreService(CoreService service) {
+    public static synchronized void setCoreService(CoreService service) {
         coreService = service;
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/intent/Intent.java b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
index 7a541e7..b7af54f 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/Intent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/Intent.java
@@ -48,6 +48,7 @@
     private final ResourceGroup resourceGroup;
 
     private static IdGenerator idGenerator;
+    private static final Object ID_GENERATOR_LOCK = new Object();
 
     /**
      * Constructor for serializer.
@@ -248,8 +249,10 @@
      * @param newIdGenerator id generator
      */
     public static void bindIdGenerator(IdGenerator newIdGenerator) {
-        checkState(idGenerator == null, "Id generator is already bound.");
-        idGenerator = checkNotNull(newIdGenerator);
+        synchronized (ID_GENERATOR_LOCK) {
+            checkState(idGenerator == null, "Id generator is already bound.");
+            idGenerator = checkNotNull(newIdGenerator);
+        }
     }
 
     /**
@@ -260,8 +263,10 @@
      * @param oldIdGenerator the current id generator
      */
     public static void unbindIdGenerator(IdGenerator oldIdGenerator) {
-        if (idGenerator == oldIdGenerator) {
-            idGenerator = null;
+        synchronized (ID_GENERATOR_LOCK) {
+            if (idGenerator == oldIdGenerator) {
+                idGenerator = null;
+            }
         }
     }
 
diff --git a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
index d94c88c..4b266a8 100644
--- a/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
+++ b/core/common/src/main/java/org/onosproject/common/DefaultTopology.java
@@ -119,7 +119,7 @@
      *
      * @param linkWeigher new default link-weight
      */
-    public static void setDefaultLinkWeigher(LinkWeigher linkWeigher) {
+    public static synchronized void setDefaultLinkWeigher(LinkWeigher linkWeigher) {
         log.info("Setting new default link-weight function to {}", linkWeigher);
         defaultLinkWeigher = linkWeigher;
     }
@@ -130,7 +130,7 @@
      *
      * @param graphPathSearch new default algorithm
      */
-    public static void setDefaultGraphPathSearch(
+    public static synchronized void setDefaultGraphPathSearch(
             GraphPathSearch<TopologyVertex, TopologyEdge> graphPathSearch) {
         log.info("Setting new default graph path algorithm to {}", graphPathSearch);
         defaultGraphPathSearch = graphPathSearch;