camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulli...@apache.org
Subject [36/50] git commit: CAMEL-7885: Restarting a timer endpoint may not trigger at expected time the first time
Date Fri, 17 Oct 2014 08:40:29 GMT
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/845410e8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/845410e8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/845410e8

Branch: refs/remotes/origin/camel-2.13.x
Commit: 845410e83ab12f5b88cbdb5891e2ccb241e8608d
Parents: 077e1e2
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:53 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/845410e8/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