You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/11/30 17:53:39 UTC

[1/6] camel git commit: CAMEL-7785: Fixed potential NPE.

Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 8a67c0297 -> 9df6d8f45
  refs/heads/camel-2.14.x 2d8148efb -> 2fc0f1fab
  refs/heads/master 1ad23d044 -> 6674e4ef4


CAMEL-7785: Fixed potential NPE.


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

Branch: refs/heads/master
Commit: c5296e487884418de8dde15e832ea72b027e073f
Parents: 1ad23d0
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 16:49:38 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 16:49:38 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultExchange.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c5296e48/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
index 340537b..3045838 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
@@ -394,7 +394,7 @@ public final class DefaultExchange implements Exchange {
 
     public void setUnitOfWork(UnitOfWork unitOfWork) {
         this.unitOfWork = unitOfWork;
-        if (onCompletions != null) {
+        if (unitOfWork != null && onCompletions != null) {
             // now an unit of work has been assigned so add the on completions
             // we might have registered already
             for (Synchronization onCompletion : onCompletions) {


[5/6] camel git commit: CAMEL-8095: CaseInsensitiveMap for Camel headers should preserve original key cases in keySet

Posted by da...@apache.org.
CAMEL-8095: CaseInsensitiveMap for Camel headers should preserve original key cases in keySet


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

Branch: refs/heads/master
Commit: b2938951562c220fc1328046acd80c38f6e162cb
Parents: 4309dd1
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 17:26:45 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 17:26:45 2014 +0100

----------------------------------------------------------------------
 .../apache/camel/util/CaseInsensitiveMap.java   | 35 ++++++++++++++++++++
 .../camel/util/CaseInsensitiveMapTest.java      | 15 +++++----
 .../language/jxpath/JXPathFilterHeaderTest.java |  2 +-
 3 files changed, 45 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2938951/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
index b4852d7..0ed2245 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CaseInsensitiveMap.java
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.util;
 
+import java.util.AbstractSet;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
@@ -159,4 +161,37 @@ public class CaseInsensitiveMap extends HashMap<String, Object> {
 
         return entrySetView;
     }
+
+    @Override
+    public Set<String> keySet() {
+        return new CaseInsensitiveKeySet();
+    }
+
+    /**
+     * To use the original keys but support checking if a key exist using case insensitive.
+     */
+    private final class CaseInsensitiveKeySet extends AbstractSet<String> {
+
+        public Iterator<String> iterator() {
+            // use the original case keys, which is stored in as values
+            return originalKeys.values().iterator();
+        }
+
+        public int size() {
+            return CaseInsensitiveMap.this.size();
+        }
+
+        public boolean contains(Object o) {
+            return CaseInsensitiveMap.this.containsKey(o);
+        }
+
+        public boolean remove(Object o) {
+            return CaseInsensitiveMap.this.remove(o) != null;
+        }
+
+        public void clear() {
+            CaseInsensitiveMap.this.clear();
+        }
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/b2938951/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java b/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
index f1c2ab6..17d78bd 100644
--- a/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/CaseInsensitiveMapTest.java
@@ -300,6 +300,10 @@ public class CaseInsensitiveMapTest extends TestCase {
         assertEquals(true, map.containsKey("FOO"));
 
         assertEquals(true, map.keySet().contains("FOO"));
+        assertEquals(true, map.keySet().contains("FoO"));
+        assertEquals(true, map.keySet().contains("Foo"));
+        assertEquals(true, map.keySet().contains("foo"));
+        assertEquals(true, map.keySet().contains("fOO"));
 
         map.put("FOO", "cake");
         assertEquals(1, map.size());
@@ -427,17 +431,16 @@ public class CaseInsensitiveMapTest extends TestCase {
 
         Map<String, Object> other = new HashMap<String, Object>();
 
-        // this is wrong!!! you should use entrySet
         for (String key : map.keySet()) {
             Object value = map.get(key);
             other.put(key, value);
         }
 
-        // now the keys will be in lower case
-        assertEquals(true, other.containsKey("foo"));
-        assertEquals(false, other.containsKey("Foo"));
-        assertEquals(true, other.containsKey("bar"));
-        assertEquals(false, other.containsKey("BAR"));
+        // the original case of the keys should be preserved
+        assertEquals(false, other.containsKey("foo"));
+        assertEquals(true, other.containsKey("Foo"));
+        assertEquals(false, other.containsKey("bar"));
+        assertEquals(true, other.containsKey("BAR"));
         assertEquals(2, other.size());
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b2938951/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java b/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
index 3e2d28d..56de439 100644
--- a/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
+++ b/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
@@ -48,7 +48,7 @@ public class JXPathFilterHeaderTest extends CamelTestSupport {
             public void configure() {
                 // START SNIPPET: example
                 from("direct:start").
-                        filter().jxpath("headers/fooBarBaz='Carlsberg'").
+                        filter().jxpath("in/headers/fooBarBaz='Carlsberg'").
                         to("mock:result");
                 // END SNIPPET: example
             }


[3/6] camel git commit: CAMEL-7785: Fixed potential NPE.

Posted by da...@apache.org.
CAMEL-7785: Fixed potential NPE.


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

Branch: refs/heads/camel-2.14.x
Commit: 2fc0f1fabd8cd242e36af69e0fe602b172758182
Parents: 2d8148e
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 16:49:38 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 16:51:07 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultExchange.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2fc0f1fa/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
index 164ae67..b020184 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
@@ -369,7 +369,7 @@ public final class DefaultExchange implements Exchange {
 
     public void setUnitOfWork(UnitOfWork unitOfWork) {
         this.unitOfWork = unitOfWork;
-        if (onCompletions != null) {
+        if (unitOfWork != null && onCompletions != null) {
             // now an unit of work has been assigned so add the on completions
             // we might have registered already
             for (Synchronization onCompletion : onCompletions) {


[2/6] camel git commit: CAMEL-6807: Added unit test

Posted by da...@apache.org.
CAMEL-6807: Added unit test


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

Branch: refs/heads/master
Commit: 4309dd1d38792e1488244aa023d4b1dd68c8ec1a
Parents: c5296e4
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 16:50:52 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 16:50:52 2014 +0100

----------------------------------------------------------------------
 .../language/jxpath/JXPathFilterHeaderTest.java | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4309dd1d/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java b/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
new file mode 100644
index 0000000..3e2d28d
--- /dev/null
+++ b/components/camel-jxpath/src/test/java/org/apache/camel/language/jxpath/JXPathFilterHeaderTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.language.jxpath;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class JXPathFilterHeaderTest extends CamelTestSupport {
+
+    @Test
+    public void testSendMatchingMessage() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBodyAndHeader("direct:start", new PersonBean("James", "London"), "fooBarBaz", "Carlsberg");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testSendNotMatchingMessage() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        template.sendBodyAndHeader("direct:start", new PersonBean("Hiram", "Tampa"), "fooBarBaz", "Heineken");
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // START SNIPPET: example
+                from("direct:start").
+                        filter().jxpath("headers/fooBarBaz='Carlsberg'").
+                        to("mock:result");
+                // END SNIPPET: example
+            }
+        };
+    }
+}


[4/6] camel git commit: CAMEL-7785: Fixed potential NPE.

Posted by da...@apache.org.
CAMEL-7785: Fixed potential NPE.


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

Branch: refs/heads/camel-2.13.x
Commit: 9df6d8f450d48145a8547c8a9b9925b74ef0f823
Parents: 8a67c02
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 16:49:38 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 16:51:17 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultExchange.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9df6d8f4/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
index 164ae67..b020184 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
@@ -369,7 +369,7 @@ public final class DefaultExchange implements Exchange {
 
     public void setUnitOfWork(UnitOfWork unitOfWork) {
         this.unitOfWork = unitOfWork;
-        if (onCompletions != null) {
+        if (unitOfWork != null && onCompletions != null) {
             // now an unit of work has been assigned so add the on completions
             // we might have registered already
             for (Synchronization onCompletion : onCompletions) {


[6/6] camel git commit: Fixed CS

Posted by da...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: 6674e4ef44c6f03cf94b129d41497690f06cf08a
Parents: b293895
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Nov 30 17:28:11 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Nov 30 17:28:11 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/support/ServiceSupport.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6674e4ef/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java
index a1cf081..976db03 100644
--- a/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/support/ServiceSupport.java
@@ -235,8 +235,9 @@ public abstract class ServiceSupport implements StatefulService {
     @Override
     public boolean isRunAllowed() {
         // if we have not yet initialized, then all options is false
-        if (!started.get() && !starting.get() && !stopping.get() && !stopped.get()
-            && !suspending.get() && !suspended.get() && !shutdown.get() && !shuttingdown.get()) {
+        boolean unused1 = !started.get() && !starting.get() && !stopping.get() && !stopped.get();
+        boolean unused2 = !suspending.get() && !suspended.get() && !shutdown.get() && !shuttingdown.get();
+        if (unused1 && unused2) {
             return false;
         }
         return !isStoppingOrStopped();