From fe6fef993934db230eaf497a5a0ed54cc4fe0556 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 9 Jan 2024 11:53:45 +0000 Subject: [PATCH 1/5] CAMEL-20297 camel-as2: do not swallow interrupted exceptions --- .../org/apache/camel/component/as2/api/AS2ClientManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java index 64a87e92e769f..9ae7c8d919588 100644 --- a/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java +++ b/components/camel-as2/camel-as2-api/src/main/java/org/apache/camel/component/as2/api/AS2ClientManager.java @@ -392,7 +392,10 @@ public HttpCoreContext send( EntityParser.parseAS2MessageEntity(response); } catch (IOException e) { throw new HttpException("Failed to send http request message", e); - } catch (ExecutionException | InterruptedException ex) { + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new HttpException("Interrupted while sending the http request", e); + } catch (ExecutionException ex) { throw new HttpException("Retrieving connection from Pool failed or timed out", ex); } httpContext.setAttribute(HTTP_RESPONSE, response); From 294254c56765b2a6008f7ef6ac6f0467a7c08e06 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 9 Jan 2024 11:53:59 +0000 Subject: [PATCH 2/5] CAMEL-20297 camel-controlbus: do not swallow interrupted exceptions --- .../apache/camel/component/controlbus/ControlBusProducer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/camel-controlbus/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java b/components/camel-controlbus/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java index 9e7ce0508b403..9838263945a6a 100644 --- a/components/camel-controlbus/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java +++ b/components/camel-controlbus/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java @@ -191,7 +191,8 @@ public void run() { LOG.debug("Sleeping {} ms before starting route: {}", delay, id); Thread.sleep(delay); } catch (InterruptedException e) { - // ignore + LOG.info("Interrupted while waiting before starting the route"); + Thread.currentThread().interrupt(); } } getEndpoint().getCamelContext().getRouteController().startRoute(id); From 91ff00b0473ccca17cc150ba2b1d062265517e3f Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 9 Jan 2024 11:54:11 +0000 Subject: [PATCH 3/5] CAMEL-20297 camel-direct: do not swallow interrupted exceptions --- .../org/apache/camel/component/direct/DirectProducer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java index e441881de72ad..714d00e673e90 100644 --- a/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java +++ b/components/camel-direct/src/main/java/org/apache/camel/component/direct/DirectProducer.java @@ -96,6 +96,13 @@ public boolean process(Exchange exchange, AsyncCallback callback) { return consumer.getAsyncProcessor().process(exchange, callback); } } + } catch (InterruptedException e) { + LOG.info("Interrupted while processing the exchange"); + Thread.currentThread().interrupt(); + + exchange.setException(e); + callback.done(true); + return true; } catch (Exception e) { exchange.setException(e); callback.done(true); From f9c492ab4fbc1fd7ef5031eee2c05fd0fa808758 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 9 Jan 2024 11:54:23 +0000 Subject: [PATCH 4/5] CAMEL-20297 camel-disruptor: do not swallow interrupted exceptions --- .../apache/camel/component/disruptor/DisruptorProducer.java | 6 ++++-- .../camel/component/disruptor/DisruptorReference.java | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorProducer.java b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorProducer.java index a778869e6a172..89348a8ed824d 100644 --- a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorProducer.java +++ b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorProducer.java @@ -100,7 +100,8 @@ public boolean process(final Exchange exchange, final AsyncCallback callback) { try { done = latch.await(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { - // ignore + LOG.info("Interrupted while waiting for the task to complete"); + Thread.currentThread().interrupt(); } if (!done) { // Remove timed out Exchange from disruptor endpoint. @@ -127,7 +128,8 @@ public boolean process(final Exchange exchange, final AsyncCallback callback) { try { latch.await(); } catch (InterruptedException e) { - // ignore + LOG.info("Interrupted while waiting for the task to complete"); + Thread.currentThread().interrupt(); } } } else { diff --git a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java index 6331b727c0e84..3922fe8a3e07d 100644 --- a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java +++ b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/DisruptorReference.java @@ -178,7 +178,8 @@ private void start() throws Exception { } eventHandlerStarted = true; } catch (InterruptedException e) { - //just retry + LOGGER.info("Interrupted while waiting for the startup to complete"); + Thread.currentThread().interrupt(); } } } @@ -317,7 +318,8 @@ private synchronized void shutdownDisruptor(boolean isReconfiguring) { } eventHandlerFinished = true; } catch (InterruptedException e) { - //just retry + LOGGER.info("Interrupted while waiting for the shutdown to complete"); + Thread.currentThread().interrupt(); } } } From f4687d6603e741565fe1523893f5abe4174f7d80 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 9 Jan 2024 11:54:32 +0000 Subject: [PATCH 5/5] CAMEL-20297 camel-irc: do not swallow interrupted exceptions --- .../main/java/org/apache/camel/component/irc/IrcConsumer.java | 3 ++- .../main/java/org/apache/camel/component/irc/IrcProducer.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java index b6cf0b303244e..cdc6b22ea2fd0 100644 --- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java +++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java @@ -66,7 +66,8 @@ protected void doStart() throws Exception { try { Thread.sleep(configuration.getCommandTimeout()); } catch (InterruptedException ex) { - // ignore + LOG.info("Interrupted while sleeping before sending commands"); + Thread.currentThread().interrupt(); } if (ObjectHelper.isNotEmpty(configuration.getNickPassword())) { LOG.debug("Identifying and enforcing nick with NickServ."); diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java index b9c5a3a8bb5b4..7026a263fa14d 100644 --- a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java +++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java @@ -99,7 +99,8 @@ protected void reconnect() { try { Thread.sleep(getEndpoint().getConfiguration().getCommandTimeout()); } catch (InterruptedException ex) { - // ignore + LOG.info("Interrupted while sleeping before sending commands"); + Thread.currentThread().interrupt(); } getEndpoint().joinChannels(); }