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:10:11 UTC

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

Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 4d7c21777 -> e1ee912fa


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/e1ee912f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e1ee912f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e1ee912f

Branch: refs/heads/camel-2.15.x
Commit: e1ee912fae2b0db7e1c8cf405369035768c90c65
Parents: 4d7c217
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:14:13 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/e1ee912f/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);
             }