Lazily initialize jaxb context in NB application 08/3808/2
authorPrasanth Pallamreddy <ppallamr@cisco.com>
Wed, 18 Dec 2013 05:26:20 +0000 (21:26 -0800)
committerPrasanth Pallamreddy <ppallamr@cisco.com>
Wed, 18 Dec 2013 17:49:46 +0000 (09:49 -0800)
Change-Id: Ibac5614aa1b23ff360bcce3ea29091f0a7a78906
Signed-off-by: Prasanth Pallamreddy <ppallamr@cisco.com>
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;
             }