camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-7262 fixed the NPE issue of calling String.replaceAll via simple expression in Karaf
Date Tue, 04 Mar 2014 06:02:02 GMT
Repository: camel
Updated Branches:
  refs/heads/master 1ad565543 -> 1a4376925


CAMEL-7262 fixed the NPE issue of calling String.replaceAll via simple expression in Karaf


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

Branch: refs/heads/master
Commit: 1a43769257f84fbb56ab9fbc04dfcb6ad778c83a
Parents: 1ad5655
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Mar 4 13:59:03 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Mar 4 14:00:34 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/language/simple/SimpleTest.java   | 9 +++++++++
 .../test/java/org/apache/camel/util/ObjectHelperTest.java   | 1 +
 .../java/org/apache/camel/core/osgi/OsgiClassResolver.java  | 4 ++++
 3 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1a437692/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index cb634c9..407f755 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -216,6 +216,15 @@ public class SimpleTest extends LanguageTestSupport {
         assertExpression("${in.body[0][code]}", 4321);
         assertExpression("${body[0][code]}", 4321);
     }
+    
+    public void testOGNLCallReplace() throws Exception {
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("cool", "Camel rocks");
+        map.put("dude", "Hey dude");
+        exchange.getIn().setHeaders(map);
+        
+        assertExpression("${headers.cool.replaceAll(\"rocks\", \"is so cool\")}", "Camel
is so cool");
+    }
 
     public void testOGNLBodyListAndMapAndMethod() throws Exception {
         Map<String, Object> map = new HashMap<String, Object>();

http://git-wip-us.apache.org/repos/asf/camel/blob/1a437692/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
index 0b21752..3f2b1cd 100644
--- a/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
@@ -832,6 +832,7 @@ public class ObjectHelperTest extends TestCase {
         assertEquals("Should get the right class name", "my.package-info", ObjectHelper.normalizeClassName("my.package-info"));
         assertEquals("Should get the right class name", "Integer[]", ObjectHelper.normalizeClassName("Integer[]
\r"));
         assertEquals("Should get the right class name", "Hello_World", ObjectHelper.normalizeClassName("Hello_World"));
+        assertEquals("Should get the right class name", "", ObjectHelper.normalizeClassName("////"));
     }
 
     public void testLookupConstantFieldValue() {

http://git-wip-us.apache.org/repos/asf/camel/blob/1a437692/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
index a52ec41..66c4008 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
@@ -45,6 +45,10 @@ public class OsgiClassResolver extends DefaultClassResolver {
     public Class<?> resolveClass(String name) {
         LOG.trace("Resolve class {}", name);
         name = ObjectHelper.normalizeClassName(name);
+        if (ObjectHelper.isEmpty(name)) {
+            return null;
+        }
+        // we need to avoid the NPE issue of loading the class
         Class<?> clazz = ObjectHelper.loadSimpleType(name);
         if (clazz == null) {
             clazz = doLoadClass(name, bundleContext.getBundle());


Mime
View raw message