Merge "Lazily initialize jaxb context in NB application"
authorAlessandro Boch <aboch@cisco.com>
Wed, 18 Dec 2013 20:13:50 +0000 (20:13 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 18 Dec 2013 20:13:50 +0000 (20:13 +0000)
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java

index e97a562620771ddf8d1a9bab0e873a89a58dc0b2..e164abaf95c0ccd3adb07e3bb55d32b8f9f22ec8 100644 (file)
@@ -46,9 +46,12 @@ public class NorthboundApplication extends Application {
     public NorthboundApplication() {
         _singletons = new HashSet<Object>();
         _singletons.add(new ContextResolver<JAXBContext>() {
-            JAXBContext jaxbContext = newJAXBContext();
+            JAXBContext jaxbContext;
             @Override
-            public JAXBContext getContext(Class<?> type) {
+            public synchronized JAXBContext getContext(Class<?> type) {
+                if (jaxbContext == null) {
+                    jaxbContext = newJAXBContext();
+                }
                 return jaxbContext;
             }