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 2015/05/10 09:09:52 UTC

[1/2] camel git commit: CAMEL-8758: Fix to Camel Cache producer to avoid NPE in race condition

Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 46b571be2 -> 1199d0400
  refs/heads/master 4327d4059 -> b684be16f


CAMEL-8758: Fix to Camel Cache producer to avoid NPE in race condition

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

Branch: refs/heads/master
Commit: b684be16fce360000bad4853666d29a8f7f56781
Parents: 4327d40
Author: Andrew Block <an...@gmail.com>
Authored: Sat May 9 13:02:56 2015 -0500
Committer: Andrew Block <an...@gmail.com>
Committed: Sat May 9 13:02:56 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/camel/component/cache/CacheProducer.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b684be16/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
index d448479..7efbc7b 100755
--- a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
+++ b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
@@ -93,9 +93,10 @@ public class CacheProducer extends DefaultProducer {
             cache.remove(key);
         } else if (checkIsEqual(operation, CacheConstants.CACHE_OPERATION_URL_GET)) {
             LOG.debug("Quering an element with key {} from the Cache", key);
-            if (cache.get(key) != null) {
+            Element element = cache.get(key);
+            if (element != null) {
                 exchange.getIn().setHeader(CacheConstants.CACHE_ELEMENT_WAS_FOUND, true);
-                exchange.getIn().setBody(cache.get(key).getObjectValue());
+                exchange.getIn().setBody(element.getObjectValue());
             } else {
                 exchange.getIn().removeHeader(CacheConstants.CACHE_ELEMENT_WAS_FOUND);
             }


[2/2] camel git commit: CAMEL-8758: Fix to Camel Cache producer to avoid NPE in race condition

Posted by da...@apache.org.
CAMEL-8758: Fix to Camel Cache producer to avoid NPE in race condition


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

Branch: refs/heads/camel-2.14.x
Commit: 1199d04004311d9701911412c78128ff2059033f
Parents: 46b571b
Author: Andrew Block <an...@gmail.com>
Authored: Sat May 9 13:02:56 2015 -0500
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 10 09:13:50 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/cache/CacheProducer.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1199d040/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
index 05d168c..95872c3 100755
--- a/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
+++ b/components/camel-cache/src/main/java/org/apache/camel/component/cache/CacheProducer.java
@@ -93,9 +93,10 @@ public class CacheProducer extends DefaultProducer {
             cache.remove(key);
         } else if (checkIsEqual(operation, CacheConstants.CACHE_OPERATION_URL_GET)) {
             LOG.debug("Quering an element with key {} from the Cache", key);
-            if (cache.get(key) != null) {
+            Element element = cache.get(key);
+            if (element != null) {
                 exchange.getIn().setHeader(CacheConstants.CACHE_ELEMENT_WAS_FOUND, true);
-                exchange.getIn().setBody(cache.get(key).getObjectValue());
+                exchange.getIn().setBody(element.getObjectValue());
             } else {
                 exchange.getIn().removeHeader(CacheConstants.CACHE_ELEMENT_WAS_FOUND);
             }