Lazily initialize jaxb context in NB application
[controller.git] / 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;
             }