camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] git commit: CAMEL-7885: Restarting a timer endpoint may not trigger at expected time the first time
Date Wed, 01 Oct 2014 09:23:20 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 17a908ad6 -> ce4a93943
  refs/heads/camel-2.13.x 077e1e217 -> 845410e83
  refs/heads/camel-2.14.x 9b6d200ef -> 920cb28b1
  refs/heads/master 3cc05a4bd -> bb41259f6


CAMEL-7885: Restarting a timer endpoint may not trigger at expected time the first time


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

Branch: refs/heads/camel-2.12.x
Commit: ce4a93943d50a4c9581251a79eb6c3841380870d
Parents: 17a908a
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Oct 1 11:22:39 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Oct 1 11:22:39 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/timer/TimerComponent.java     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ce4a9394/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
b/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
index ec67f01..6c6ab01 100644
--- a/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
+++ b/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
@@ -35,7 +35,7 @@ import org.apache.camel.impl.UriEndpointComponent;
  */
 public class TimerComponent extends UriEndpointComponent {
     private final Map<String, Timer> timers = new HashMap<String, Timer>();
-    private final Map<String, AtomicInteger> refCounts = new HashMap<>();
+    private final Map<String, AtomicInteger> refCounts = new HashMap<String, AtomicInteger>();
 
     public TimerComponent() {
         super(TimerEndpoint.class);
@@ -60,7 +60,9 @@ public class TimerComponent extends UriEndpointComponent {
             } else {
                 // increase reference counter
                 AtomicInteger counter = refCounts.get(key);
-                counter.incrementAndGet();
+                if (counter != null) {
+                    counter.incrementAndGet();
+                }
             }
         }
         return answer;
@@ -75,7 +77,7 @@ public class TimerComponent extends UriEndpointComponent {
         synchronized (timers) {
             // decrease reference counter
             AtomicInteger counter = refCounts.get(key);
-            if (counter.decrementAndGet() <= 0) {
+            if (counter != null && counter.decrementAndGet() <= 0) {
                 refCounts.remove(key);
                 // remove timer as its no longer in use
                 Timer timer = timers.remove(key);


Mime
View raw message