camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/6] camel git commit: https://issues.apache.org/jira/browse/CAMEL-10215 Synchronizing receive methods
Date Tue, 02 Aug 2016 06:49:21 GMT
https://issues.apache.org/jira/browse/CAMEL-10215 Synchronizing receive methods


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

Branch: refs/heads/camel-2.17.x
Commit: 495bcfeb22becf27e00bd64bfd012515c55d2758
Parents: 284cc67
Author: Siddharth Sharma <siddharth.sharma@jobvite-inc.com>
Authored: Mon Aug 1 15:49:16 2016 -0700
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Aug 2 08:48:38 2016 +0200

----------------------------------------------------------------------
 .../camel/impl/EventDrivenPollingConsumer.java  | 40 +++++++++++---------
 1 file changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/495bcfeb/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
b/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
index 624e9b2..117598f 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/EventDrivenPollingConsumer.java
@@ -114,14 +114,17 @@ public class EventDrivenPollingConsumer extends PollingConsumerSupport
implement
         }
 
         while (isRunAllowed()) {
-            try {
-                beforePoll(0);
-                // take will block waiting for message
-                return queue.take();
-            } catch (InterruptedException e) {
-                handleInterruptedException(e);
-            } finally {
-                afterPoll();
+            // CAMEL-10215 - Synchronizing the ordering of beforePoll, poll and afterPoll
as an atomic activity
+            synchronized(this) {
+                try {
+                    beforePoll(0);
+                    // take will block waiting for message
+                    return queue.take();
+                } catch (InterruptedException e) {
+                    handleInterruptedException(e);
+                } finally {
+                    afterPoll();
+                }
             }
         }
         LOG.trace("Consumer is not running, so returning null");
@@ -134,15 +137,18 @@ public class EventDrivenPollingConsumer extends PollingConsumerSupport
implement
             throw new RejectedExecutionException(this + " is not started, but in state: "
+ getStatus().name());
         }
 
-        try {
-            // use the timeout value returned from beforePoll
-            timeout = beforePoll(timeout);
-            return queue.poll(timeout, TimeUnit.MILLISECONDS);
-        } catch (InterruptedException e) {
-            handleInterruptedException(e);
-            return null;
-        } finally {
-            afterPoll();
+        // CAMEL-10215 - Synchronizing the ordering of beforePoll, poll and afterPoll as
an atomic activity
+        synchronized(this) {
+            try {
+                // use the timeout value returned from beforePoll
+                timeout = beforePoll(timeout);
+                return queue.poll(timeout, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+                handleInterruptedException(e);
+                return null;
+            } finally {
+                afterPoll();
+            }
         }
     }
 


Mime
View raw message