camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/3] camel git commit: CAMEL-8546 Polished the code to avoid NPE when camel-script have some trouble to load the script engine
Date Fri, 27 Mar 2015 14:54:43 GMT
CAMEL-8546 Polished the code to avoid NPE when camel-script have some trouble to load the script
engine


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

Branch: refs/heads/camel-2.15.x
Commit: 4bd6ecdf0dd81898c62f2e20cc32aadcd1f027ef
Parents: 4308fbe
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Mar 27 17:13:52 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Mar 27 22:53:42 2015 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/script/osgi/Activator.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4bd6ecdf/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
b/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
index 4ffb37d..0db41a4 100644
--- a/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
+++ b/components/camel-script/src/main/java/org/apache/camel/script/osgi/Activator.java
@@ -90,7 +90,10 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer,
Serv
             service.register();
         }
         resolvers.put(bundle.getBundleId(), r);
-        updateAvailableScriptLanguages();
+        // Only update the script language engine when the resolver is changed
+        if (r.size() > 0) {
+            updateAvailableScriptLanguages();
+        }
         return bundle;
     }
 
@@ -208,7 +211,13 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer,
Serv
         }
 
         private List<String> getScriptNames(ScriptEngineFactory factory) {
-            List<String> names = factory.getNames();
+            List<String> names = null;
+            if (factory != null) {
+                names = factory.getNames();
+            } else {
+                // return an empty script name list
+                names = new ArrayList<String>(0);
+            }
             return names;
         }
 
@@ -223,7 +232,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer,
Serv
                 }
                 return (ScriptEngineFactory) cls.newInstance();
             } catch (Exception e) {
-                //do something
+                LOG.warn("Cannot create the ScriptEngineFactory: " + e.getClass().getName(),
e);
                 return null;
             }
         }


Mime
View raw message