You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/05/09 08:06:47 UTC

git commit: CAMEL-6341 fix the issue that DefaultShutdownStrategy never shutdown if the timeout is 0.

Updated Branches:
  refs/heads/master 939557a2f -> 6c27433e2


CAMEL-6341 fix the issue that DefaultShutdownStrategy never shutdown if the timeout is 0.


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

Branch: refs/heads/master
Commit: 6c27433e25d706cd643c4dec5bb39099d0079ce7
Parents: 939557a
Author: Willem Jiang <ni...@apache.org>
Authored: Thu May 9 13:57:46 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Thu May 9 14:01:39 2013 +0800

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultShutdownStrategy.java |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6c27433e/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
index 4da2d18..a7e9cf8 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
@@ -220,6 +220,9 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
     }
 
     public void setTimeout(long timeout) {
+        if (timeout < 0) {
+            throw new IllegalArgumentException("Timeout must not be lesser than 0.");
+        }
         this.timeout = timeout;
     }
 
@@ -533,9 +536,14 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
                 }
                 if (size > 0) {
                     try {
-                        LOG.info("Waiting as there are still " + size + " inflight and pending exchanges to complete, timeout in "
+                        if (timeout > 0) {
+                            LOG.info("Waiting as there are still " + size + " inflight and pending exchanges to complete, timeout in "
                                  + (TimeUnit.SECONDS.convert(timeout, timeUnit) - (loopCount++ * loopDelaySeconds)) + " seconds.");
-                        Thread.sleep(loopDelaySeconds * 1000);
+                            Thread.sleep(loopDelaySeconds * 1000);
+                        } else {
+                            // we should not wait here 
+                            throw new InterruptedException();
+                        }
                     } catch (InterruptedException e) {
                         if (abortAfterTimeout) {
                             LOG.warn("Interrupted while waiting during graceful shutdown, will abort.");