camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/6] camel git commit: Issue CAMEL-8640. More safe ensuring of space in queue.
Date Sun, 03 May 2015 09:38:23 GMT
Issue CAMEL-8640. More safe ensuring of space in queue.


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

Branch: refs/heads/camel-2.15.x
Commit: 4556db6335c519228c541b54113858ec5457a8fe
Parents: 2c19b34
Author: Robert Budźko <r.budzko@oberthur.com>
Authored: Sat May 2 13:50:45 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun May 3 11:41:53 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/processor/interceptor/BacklogTracer.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4556db63/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
index e2c51bd..fa0dcda 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
@@ -153,9 +153,12 @@ public class BacklogTracer extends ServiceSupport implements InterceptStrategy
{
             return;
         }
 
-        // ensure there is space on the queue and we need room for ourselves and possible
also a first pseudo message as well
-        if (queue.size() >= backlogSize) {
-            queue.poll();
+        // ensure there is space on the queue by polling until at least single slot is free
+        int drain = queue.size() - backlogSize + 1;
+        if (drain > 0) {
+            for (int i = 0; i < drain; i++) {
+                queue.poll();
+            }
         }
 
         queue.add(event);


Mime
View raw message