You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/01/18 14:16:46 UTC

(camel) branch main updated (ea6c8818467 -> 53cc4633cab)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from ea6c8818467 CAMEL-20345: Simple binary operator should better be detected in predicate parser
     new 47ebb9ff8e8 CAMEL-20297 camel-base-engine: do not swallow interrupted exceptions
     new ff48bbc4d2e CAMEL-20297 camel-support: do not swallow interrupted exceptions
     new 8fd7c5a8eb9 CAMEL-20297 camel-util: do not swallow interrupted exceptions
     new 37825a955eb CAMEL-20297 camel-main: do not swallow interrupted exceptions
     new f65d87e909a CAMEL-20297 camel-management: do not swallow interrupted exceptions
     new 53cc4633cab CAMEL-20297 camel-core-processor: do not swallow interrupted exceptions

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/DefaultShutdownStrategy.java |  1 +
 .../java/org/apache/camel/processor/Throttler.java |  2 ++
 .../camel/processor/ThrottlerMethodCallTest.java   | 37 ++++++++++++++++++----
 .../camel/main/DefaultMainShutdownStrategy.java    |  2 +-
 .../camel/management/mbean/ManagedRoute.java       |  3 +-
 .../camel/support/EventDrivenPollingConsumer.java  |  3 +-
 .../org/apache/camel/support/ExchangeHelper.java   |  2 ++
 .../support/FileWatcherResourceReloadStrategy.java |  2 ++
 .../main/java/org/apache/camel/util/FileUtil.java  |  9 ++++--
 9 files changed, 48 insertions(+), 13 deletions(-)


(camel) 05/06: CAMEL-20297 camel-management: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f65d87e909a3fb762849638c2f354868820ce82a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:02:06 2024 +0100

    CAMEL-20297 camel-management: do not swallow interrupted exceptions
---
 .../src/main/java/org/apache/camel/management/mbean/ManagedRoute.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
index a7a0ec2f1b3..3cb8b1581f4 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
@@ -384,7 +384,8 @@ public class ManagedRoute extends ManagedPerformanceCounter implements TimerList
                 LOG.debug("Sleeping {} seconds before starting route: {}", delay, getRouteId());
                 Thread.sleep(delay * 1000);
             } catch (InterruptedException e) {
-                // ignore
+                LOG.info("Interrupted while waiting before starting the route");
+                Thread.currentThread().interrupt();
             }
         }
         start();


(camel) 03/06: CAMEL-20297 camel-util: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8fd7c5a8eb92a720570422ec1eb23056cf1da7f8
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:01:53 2024 +0100

    CAMEL-20297 camel-util: do not swallow interrupted exceptions
---
 .../camel-util/src/main/java/org/apache/camel/util/FileUtil.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
index 5f06399f077..22e9b732a95 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
@@ -385,7 +385,8 @@ public final class FileUtil {
             try {
                 Thread.sleep(RETRY_SLEEP_MILLIS);
             } catch (InterruptedException ex) {
-                // Ignore Exception
+                LOG.info("Interrupted while trying to delete file {}", f, e);
+                Thread.currentThread().interrupt();
             }
             try {
                 Files.delete(f.toPath());
@@ -424,7 +425,8 @@ public final class FileUtil {
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException e) {
-                    // ignore
+                    LOG.info("Interrupted while trying to rename file from {} to {}", from, to, e);
+                    Thread.currentThread().interrupt();
                 }
             }
             count++;
@@ -511,7 +513,8 @@ public final class FileUtil {
                     try {
                         Thread.sleep(1000);
                     } catch (InterruptedException ie) {
-                        // ignore
+                        LOG.info("Interrupted while trying to delete file {}", file, e);
+                        Thread.currentThread().interrupt();
                     }
                 }
             }


(camel) 04/06: CAMEL-20297 camel-main: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 37825a955eb93386210f4941ea706658a283e0b7
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:01:59 2024 +0100

    CAMEL-20297 camel-main: do not swallow interrupted exceptions
---
 .../main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
index b4602be9760..d66fc9ec146 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
@@ -111,7 +111,7 @@ public class DefaultMainShutdownStrategy extends SimpleMainShutdownStrategy {
                         // wait 1 sec and loop and log activity, so we can see we are waiting
                         done = latch.await(1000, TimeUnit.MILLISECONDS);
                     } catch (InterruptedException e) {
-                        // ignore
+                        Thread.currentThread().interrupt();
                     }
                 }
                 boolean success = done || main.getCamelContext().isStopped();


(camel) 01/06: CAMEL-20297 camel-base-engine: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 47ebb9ff8e8007b1d7b97c16acd26c46e10fedc3
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:01:29 2024 +0100

    CAMEL-20297 camel-base-engine: do not swallow interrupted exceptions
---
 .../main/java/org/apache/camel/impl/engine/DefaultShutdownStrategy.java  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultShutdownStrategy.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultShutdownStrategy.java
index b6c4123eca8..d99a0bc1344 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultShutdownStrategy.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultShutdownStrategy.java
@@ -693,6 +693,7 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
 
                         Thread.sleep(loopDelaySeconds * 1000);
                     } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
                         if (abortAfterTimeout) {
                             LOG.warn("Interrupted while waiting during graceful shutdown, will abort.");
                             return;


(camel) 06/06: CAMEL-20297 camel-core-processor: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 53cc4633cab3867823202f68a783d3fcc4ac9c6a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:02:15 2024 +0100

    CAMEL-20297 camel-core-processor: do not swallow interrupted exceptions
---
 .../java/org/apache/camel/processor/Throttler.java |  2 ++
 .../camel/processor/ThrottlerMethodCallTest.java   | 37 ++++++++++++++++++----
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Throttler.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Throttler.java
index edaf2f49ccd..2a7df9052be 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/Throttler.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/Throttler.java
@@ -173,6 +173,7 @@ public class Throttler extends AsyncProcessorSupport implements Traceable, IdAwa
 
     private static boolean handleInterrupt(
             Exchange exchange, AsyncCallback callback, InterruptedException e, boolean doneSync) {
+        Thread.currentThread().interrupt();
         // determine if we can still run, or the camel context is forcing a shutdown
         boolean forceShutdown = exchange.getContext().getShutdownStrategy().isForceShutdown();
         if (forceShutdown) {
@@ -384,6 +385,7 @@ public class Throttler extends AsyncProcessorSupport implements Traceable, IdAwa
                 // honours fairness setting
                 return super.tryAcquire(0L, TimeUnit.NANOSECONDS);
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 return false;
             }
         }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java
index ac51a51197d..16f59048b60 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/ThrottlerMethodCallTest.java
@@ -18,19 +18,28 @@ package org.apache.camel.processor;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spi.Registry;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @DisabledOnOs(OS.WINDOWS)
 public class ThrottlerMethodCallTest extends ContextTestSupport {
+    private static final Logger LOG = LoggerFactory.getLogger(ThrottlerMethodCallTest.class);
     private static final int INTERVAL = 100;
     protected int messageCount = 10;
+    private MockEndpoint resultEndpoint;
+    private ExecutorService executor;
 
     @Override
     protected Registry createRegistry() throws Exception {
@@ -43,21 +52,35 @@ public class ThrottlerMethodCallTest extends ContextTestSupport {
         return 3;
     }
 
-    @Test
-    public void testConfigurationWithMethodCallExpression() throws Exception {
-        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+    @BeforeEach
+    public void prepareTest() {
+        resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         resultEndpoint.expectedMessageCount(messageCount);
 
-        ExecutorService executor = Executors.newFixedThreadPool(messageCount);
+        executor = Executors.newFixedThreadPool(messageCount);
+    }
+
+    @AfterEach
+    public void cleanupTest() throws InterruptedException {
+        executor.shutdown();
+        if (!executor.awaitTermination(2, TimeUnit.SECONDS)) {
+            LOG.warn("The tasks did not finish within the expected time");
+            executor.shutdownNow();
+        }
+    }
 
+    @Test
+    public void testConfigurationWithMethodCallExpression()  {
         for (int i = 0; i < messageCount; i++) {
             executor.execute(() -> template.sendBody("direct:expressionMethod", "<message>payload</message>"));
         }
 
         // let's wait for the exchanges to arrive
-        resultEndpoint.assertIsSatisfied();
-
-        executor.shutdownNow();
+        try {
+            resultEndpoint.assertIsSatisfied();
+        } catch (InterruptedException e) {
+            Assertions.fail(e);
+        }
     }
 
     @Override


(camel) 02/06: CAMEL-20297 camel-support: do not swallow interrupted exceptions

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ff48bbc4d2e4aacdbdb3c4c59d70ab7c8cf9a45a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Jan 16 11:01:43 2024 +0100

    CAMEL-20297 camel-support: do not swallow interrupted exceptions
---
 .../main/java/org/apache/camel/support/EventDrivenPollingConsumer.java | 3 ++-
 .../src/main/java/org/apache/camel/support/ExchangeHelper.java         | 2 ++
 .../org/apache/camel/support/FileWatcherResourceReloadStrategy.java    | 2 ++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EventDrivenPollingConsumer.java b/core/camel-support/src/main/java/org/apache/camel/support/EventDrivenPollingConsumer.java
index ebce7dbba9c..779d8da4b65 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/EventDrivenPollingConsumer.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/EventDrivenPollingConsumer.java
@@ -193,7 +193,7 @@ public class EventDrivenPollingConsumer extends PollingConsumerSupport implement
                     }
                 }
             } catch (InterruptedException e) {
-                // ignore
+                Thread.currentThread().interrupt();
                 LOG.debug("Put interrupted, are we stopping? {}", isStopping() || isStopped());
             }
         } else {
@@ -228,6 +228,7 @@ public class EventDrivenPollingConsumer extends PollingConsumerSupport implement
     }
 
     protected void handleInterruptedException(InterruptedException e) {
+        Thread.currentThread().interrupt();
         getInterruptedExceptionHandler().handleException(e);
     }
 
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
index 81eb2e51647..b1097243892 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
@@ -711,6 +711,7 @@ public final class ExchangeHelper {
         try {
             return doExtractFutureBody(context, future.get(), type);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw RuntimeCamelException.wrapRuntimeCamelException(e);
         } catch (ExecutionException e) {
             // execution failed due to an exception so rethrow the cause
@@ -747,6 +748,7 @@ public final class ExchangeHelper {
             }
         } catch (InterruptedException e) {
             // execution failed due interruption so rethrow the cause
+            Thread.currentThread().interrupt();
             throw CamelExecutionException.wrapCamelExecutionException(null, e);
         } catch (ExecutionException e) {
             // execution failed due to an exception so rethrow the cause
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/FileWatcherResourceReloadStrategy.java b/core/camel-support/src/main/java/org/apache/camel/support/FileWatcherResourceReloadStrategy.java
index 13eba8c0977..35ffa8dfd84 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/FileWatcherResourceReloadStrategy.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/FileWatcherResourceReloadStrategy.java
@@ -277,6 +277,8 @@ public class FileWatcherResourceReloadStrategy extends ResourceReloadStrategySup
                     // wait for a key to be available
                     key = watcher.poll(pollTimeout, TimeUnit.MILLISECONDS);
                 } catch (InterruptedException ex) {
+                    LOG.info("Interrupted while polling for file changes");
+                    Thread.currentThread().interrupt();
                     break;
                 }