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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9f839f4bcc9d CAMEL-25929: Restore interrupt status in 
InterruptedException catch blocks (#28245)
9f839f4bcc9d is described below

commit 9f839f4bcc9d035d33e54ccd52f98a6bc2a7cd96
Author: Federico Mariani <[email protected]>
AuthorDate: Wed Oct 21 22:11:11 2026 +0200

    CAMEL-25929: Restore interrupt status in InterruptedException catch blocks 
(#28245)
    
    * CAMEL-25929: Restore interrupt status in InterruptedException catch blocks
    
    When catching InterruptedException, the interrupt flag on the current thread
    is cleared. Code that catches this exception must restore the flag by 
calling
    Thread.currentThread().interrupt() before re-throwing or returning, 
otherwise
    upstream code cannot detect that an interrupt occurred.
    
    This commit fixes 8 catch sites across 6 files in 5 modules:
    
    - camel-core-processor: ConcurrentRequestsThrottler
    - camel-aws2-kinesis: KclKinesis2Consumer
    - camel-smpp: MessageReceiverListenerImpl (3 catch blocks)
    - camel-tahu: TahuEdgeClient
    - camel-cli-debug: CamelCliDebuggerFactory
    - camel-jbang-plugin-kubernetes: KubernetesPodLogs
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    * CAMEL-25929: Fix review findings on restoring the interrupt status
    
    - camel-tahu: give InterruptedException its own catch so that an
      ExecutionException or CancellationException does not flag the
      shutdown thread as interrupted
    - camel-jbang-plugin-kubernetes: stop the pod log retry loop when
      sleepWell() is interrupted, otherwise every later sleep throws at once
      and the loop retries with no backoff
    - camel-smpp: keep the current behaviour, restoring the flag and then
      running the route on the interrupted jsmpp thread would make
      interruptible I/O in the route fail
    
    ---------
    
    Co-authored-by: Timur Rakhmatullin 
<[email protected]>
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../apache/camel/component/aws2/kinesis/KclKinesis2Consumer.java | 1 +
 .../org/apache/camel/component/tahu/handlers/TahuEdgeClient.java | 5 ++++-
 .../org/apache/camel/processor/ConcurrentRequestsThrottler.java  | 1 +
 .../camel/component/cli/debug/CamelCliDebuggerFactory.java       | 1 +
 .../dsl/jbang/core/commands/kubernetes/KubernetesPodLogs.java    | 9 +++++++--
 5 files changed, 14 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/KclKinesis2Consumer.java
 
b/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/KclKinesis2Consumer.java
index d4b04a2b7d0b..9e79aab26a4a 100644
--- 
a/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/KclKinesis2Consumer.java
+++ 
b/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/KclKinesis2Consumer.java
@@ -160,6 +160,7 @@ public class KclKinesis2Consumer extends DefaultConsumer {
             try {
                 gracefulShutdownFuture.get(20, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
                 LOG.debug("Interrupted while waiting for graceful shutdown. 
Continuing.");
             } catch (ExecutionException e) {
                 LOG.debug("Exception while executing graceful shutdown.", e);
diff --git 
a/components/camel-tahu/src/main/java/org/apache/camel/component/tahu/handlers/TahuEdgeClient.java
 
b/components/camel-tahu/src/main/java/org/apache/camel/component/tahu/handlers/TahuEdgeClient.java
index bcf68ed6888d..377526845eea 100644
--- 
a/components/camel-tahu/src/main/java/org/apache/camel/component/tahu/handlers/TahuEdgeClient.java
+++ 
b/components/camel-tahu/src/main/java/org/apache/camel/component/tahu/handlers/TahuEdgeClient.java
@@ -106,7 +106,10 @@ public final class TahuEdgeClient extends EdgeClient {
                 clientSubmittedFuture.get(SHUTDOWN_TIMEOUT.toMillis(), 
TimeUnit.MILLISECONDS);
             } catch (TimeoutException te) {
                 clientSubmittedFuture.cancel(true);
-            } catch (CancellationException | ExecutionException | 
InterruptedException e) {
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                LOG.warn(loggingMarker, "Interrupted waiting for client 
shutdown", e);
+            } catch (CancellationException | ExecutionException e) {
                 LOG.warn(loggingMarker, "Caught exception waiting for client 
shutdown", e);
             }
             this.clientSubmittedFuture = null;
diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java
index f89805341521..2a5f9a0526c5 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java
@@ -96,6 +96,7 @@ public class ConcurrentRequestsThrottler extends 
AbstractThrottler {
             return doProcess(exchange, callback, state, queuedStart, doneSync);
 
         } catch (final InterruptedException e) {
+            Thread.currentThread().interrupt();
             return handleInterrupt(exchange, callback, e, doneSync);
         } catch (final Exception t) {
             return handleException(exchange, callback, t, doneSync);
diff --git 
a/dsl/camel-cli-debug/src/main/java/org/apache/camel/component/cli/debug/CamelCliDebuggerFactory.java
 
b/dsl/camel-cli-debug/src/main/java/org/apache/camel/component/cli/debug/CamelCliDebuggerFactory.java
index 8bb9c3fe3df2..9d440ab982b0 100644
--- 
a/dsl/camel-cli-debug/src/main/java/org/apache/camel/component/cli/debug/CamelCliDebuggerFactory.java
+++ 
b/dsl/camel-cli-debug/src/main/java/org/apache/camel/component/cli/debug/CamelCliDebuggerFactory.java
@@ -97,6 +97,7 @@ public class CamelCliDebuggerFactory implements 
DebuggerFactory {
                         watch.restart();
                     }
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     return null;
                 }
             }
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesPodLogs.java
 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesPodLogs.java
index 5a88a88ff156..60d057a4b609 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesPodLogs.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesPodLogs.java
@@ -84,7 +84,9 @@ public class KubernetesPodLogs extends KubernetesBaseCommand {
 
         var retry = watchLogs();
         while ((retry || retryForReload) && ++retryCount < maxRetryAttempts) {
-            sleepWell();
+            if (!sleepWell()) {
+                break;
+            }
             printer().printf("Retry %d/%d Pod log for label %s%n", retryCount, 
maxRetryAttempts, label);
             retry = watchLogs();
         }
@@ -158,11 +160,14 @@ public class KubernetesPodLogs extends 
KubernetesBaseCommand {
         return "Terminated".equals(phase);
     }
 
-    private void sleepWell() {
+    private boolean sleepWell() {
         try {
             Thread.sleep(2000L);
+            return true;
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             printer().printf("Interrupted while waiting for pod - %s%n", 
e.getMessage());
+            return false;
         }
     }
 }

Reply via email to