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 2018/03/07 18:46:38 UTC

[camel] branch master updated: CAMEL-12327: camel-infinispan - Add GET check before PUT on add operation in idempontent repository

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 29be999  CAMEL-12327: camel-infinispan - Add GET check before PUT on add operation in idempontent repository
29be999 is described below

commit 29be9994177f722634cef53a9938556dd24d891b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 7 19:46:22 2018 +0100

    CAMEL-12327: camel-infinispan - Add GET check before PUT on add operation in idempontent repository
---
 .../processor/idempotent/InfinispanIdempotentRepository.java        | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
index 4d605a8..9e5b85a 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/processor/idempotent/InfinispanIdempotentRepository.java
@@ -65,6 +65,12 @@ public class InfinispanIdempotentRepository extends ServiceSupport implements Id
     @Override
     @ManagedOperation(description = "Adds the key to the store")
     public boolean add(Object key) {
+        // need to check first as put will update the entry lifetime so it can not expire its cache lifespan
+        if (getCache().containsKey(key)) {
+            // there is already an entry so return false
+            return false;
+        }
+        
         Boolean put = getCache().put(key, true);
         return put == null;
     }

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.