camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7262 fixed the NPE issue of calling String.replaceAll via simple expression in Karaf
Date Tue, 04 Mar 2014 06:04:47 GMT
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/5d183c82
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5d183c82
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5d183c82

Branch: refs/heads/camel-2.11.x
Commit: 5d183c82527299a256a6d4c5e3d26d6e37b76251
Parents: 789f092
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:03:01 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/5d183c82/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 f2e9bb0..f0b2585 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
@@ -213,6 +213,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/5d183c82/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/5d183c82/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 9f351b9..3a71f6b 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
@@ -42,6 +42,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