camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-9730: NPE in camel-jaxb when using in OSGi running from CamelTestBlueprint
Date Mon, 21 Mar 2016 12:54:17 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.17.x d12f08e54 -> e718b6711
  refs/heads/master 9e0f778cf -> c653828ba


CAMEL-9730: NPE in camel-jaxb when using in OSGi running from CamelTestBlueprint


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c653828b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c653828b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c653828b

Branch: refs/heads/master
Commit: c653828bae3b934fd03d16186a4251554d9b4a80
Parents: 9e0f778
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Mar 21 13:30:47 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Mar 21 13:30:47 2016 +0100

----------------------------------------------------------------------
 .../converter/BaseTypeConverterRegistry.java    |  4 ++-
 .../camel/blueprint/BlueprintCamelContext.java  |  2 +-
 .../core/osgi/OsgiDefaultCamelContext.java      |  2 +-
 .../camel/core/osgi/OsgiTypeConverter.java      |  8 ++++-
 .../converter/jaxb/FallbackTypeConverter.java   | 32 +++++++++++---------
 5 files changed, 29 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c653828b/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
b/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
index 2895001..da15cfb 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
@@ -459,7 +459,9 @@ public abstract class BaseTypeConverterRegistry extends ServiceSupport
implement
         }
         if (typeConverter instanceof CamelContextAware) {
             CamelContextAware camelContextAware = (CamelContextAware) typeConverter;
-            camelContextAware.setCamelContext(getCamelContext());
+            if (camelContext != null) {
+                camelContextAware.setCamelContext(camelContext);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/c653828b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
index 9f5a6cd..f48245d 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
@@ -162,7 +162,7 @@ public class BlueprintCamelContext extends DefaultCamelContext implements
Servic
             ctx = bundleContext;
         }
         FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
-        return new OsgiTypeConverter(ctx, getInjector(), finder);
+        return new OsgiTypeConverter(ctx, this, getInjector(), finder);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/c653828b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
index a48b9d1..0c5e782 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
@@ -73,7 +73,7 @@ public class OsgiDefaultCamelContext extends DefaultCamelContext {
             ctx = bundleContext;
         }
         FactoryFinder finder = new OsgiFactoryFinderResolver(bundleContext).resolveDefaultFactoryFinder(getClassResolver());
-        return new OsgiTypeConverter(ctx, getInjector(), finder);
+        return new OsgiTypeConverter(ctx, this, getInjector(), finder);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c653828b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
index 46767fe..c4813c1 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiTypeConverter.java
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.NoTypeConversionAvailableException;
@@ -49,13 +50,15 @@ public class OsgiTypeConverter extends ServiceSupport implements TypeConverter,
     private static final Logger LOG = LoggerFactory.getLogger(OsgiTypeConverter.class);
 
     private final BundleContext bundleContext;
+    private final CamelContext camelContext;
     private final Injector injector;
     private final FactoryFinder factoryFinder;
     private final ServiceTracker<TypeConverterLoader, Object> tracker;
     private volatile DefaultTypeConverter delegate;
 
-    public OsgiTypeConverter(BundleContext bundleContext, Injector injector, FactoryFinder
factoryFinder) {
+    public OsgiTypeConverter(BundleContext bundleContext, CamelContext camelContext, Injector
injector, FactoryFinder factoryFinder) {
         this.bundleContext = bundleContext;
+        this.camelContext = camelContext;
         this.injector = injector;
         this.factoryFinder = factoryFinder;
         this.tracker = new ServiceTracker<TypeConverterLoader, Object>(bundleContext,
TypeConverterLoader.class.getName(), this);
@@ -197,6 +200,9 @@ public class OsgiTypeConverter extends ServiceSupport implements TypeConverter,
             }
         }, injector, factoryFinder);
 
+        // inject CamelContext
+        answer.setCamelContext(camelContext);
+
         try {
             // only load the core type converters, as OSGi activator will keep track on bundles
             // being installed/uninstalled and load type converters as part of that process

http://git-wip-us.apache.org/repos/asf/camel/blob/c653828b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
index 16220a2..23e9f54 100644
--- a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
+++ b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/FallbackTypeConverter.java
@@ -112,23 +112,25 @@ public class FallbackTypeConverter extends ServiceSupport implements
TypeConvert
     public void setCamelContext(CamelContext camelContext) {
         this.camelContext = camelContext;
 
-        // configure pretty print
-        String property = camelContext.getProperty(PRETTY_PRINT);
-        if (property != null) {
-            if (property.equalsIgnoreCase("false")) {
-                setPrettyPrint(false);
-            } else {
-                setPrettyPrint(true);
+        if (camelContext != null) {
+            // configure pretty print
+            String property = camelContext.getProperty(PRETTY_PRINT);
+            if (property != null) {
+                if (property.equalsIgnoreCase("false")) {
+                    setPrettyPrint(false);
+                } else {
+                    setPrettyPrint(true);
+                }
             }
-        }
 
-        // configure object factory
-        property = camelContext.getProperty(OBJECT_FACTORY);
-        if (property != null) {
-            if (property.equalsIgnoreCase("false")) {
-                setObjectFactory(false);
-            } else {
-                setObjectFactory(true);
+            // configure object factory
+            property = camelContext.getProperty(OBJECT_FACTORY);
+            if (property != null) {
+                if (property.equalsIgnoreCase("false")) {
+                    setObjectFactory(false);
+                } else {
+                    setObjectFactory(true);
+                }
             }
         }
     }


Mime
View raw message