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 e97a562..e164aba 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;
             }