camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8758: Fix to Camel Cache producer to avoid NPE in race condition
Date Sun, 10 May 2015 07:09:52 GMT
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 <andy.block@gmail.com>
Authored: Sat May 9 13:02:56 2015 -0500
Committer: Andrew Block <andy.block@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);
             }


Mime
View raw message