camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [01/13] camel git commit: CAMEL-8728: Hazelcast idempotent repository - Should use locks
Date Sun, 03 May 2015 09:03:55 GMT
Repository: camel
Updated Branches:
  refs/heads/master 1c20c435e -> d58024b49


CAMEL-8728: Hazelcast idempotent repository - Should use locks


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

Branch: refs/heads/master
Commit: 5d5c5a4d15a21d0df5b092f5cbcc34411e948540
Parents: 78ccf13
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri May 1 15:34:08 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun May 3 10:52:34 2015 +0200

----------------------------------------------------------------------
 .../hazelcast/map/HazelcastMapProducer.java     |  1 -
 .../HazelcastIdempotentRepository.java          | 31 ++++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5d5c5a4d/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
index 6d0921d..d0911ff 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
@@ -116,7 +116,6 @@ public class HazelcastMapProducer extends HazelcastDefaultProducer {
 
         // finally copy headers
         HazelcastComponentHelper.copyHeaders(exchange);
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/5d5c5a4d/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
index b73757a..a8c1003 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
@@ -48,21 +48,22 @@ public class HazelcastIdempotentRepository extends ServiceSupport implements
Ide
 
     @Override
     public boolean add(String key) {
-
-        Boolean found = this.repo.get(key);
-        if (found == null) {
-            Boolean returned = this.repo.putIfAbsent(key, false);
-            if (returned == null) {
-                return true;
-            }
+        repo.lock(key);
+        try {
+            return repo.putIfAbsent(key, false) == null;
+        } finally {
+            repo.unlock(key);
         }
-        return false;
-
     }
 
     @Override
     public boolean confirm(String key) {
-        return this.repo.replace(key, false, true);
+        repo.lock(key);
+        try {
+            return repo.replace(key, false, true);
+        } finally {
+            repo.unlock(key);
+        }
     }
 
     @Override
@@ -72,11 +73,11 @@ public class HazelcastIdempotentRepository extends ServiceSupport implements
Ide
 
     @Override
     public boolean remove(String key) {
-        if (this.contains(key)) {
-            this.repo.remove(key);
-            return true;
-        } else {
-            return false;
+        repo.lock(key);
+        try {
+            return repo.remove(key) != null;
+        } finally {
+            repo.unlock(key);
         }
     }
 


Mime
View raw message