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 221f78a761a9e9090fe5ad132ad448d52cc1c74e Author: Otavio Rodolfo Piske <[email protected]> AuthorDate: Mon Jan 15 11:12:38 2024 +0100 CAMEL-20297 camel-xmpp: do not swallow interrupted exceptions --- .../java/org/apache/camel/component/xmpp/XmppDirectProducer.java | 7 ++++--- .../org/apache/camel/component/xmpp/XmppGroupChatProducer.java | 9 +++++++++ .../org/apache/camel/component/xmpp/XmppPrivateChatProducer.java | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppDirectProducer.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppDirectProducer.java index 3b9f0bc6bc5..20fad1159d3 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppDirectProducer.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppDirectProducer.java @@ -75,11 +75,12 @@ public class XmppDirectProducer extends DefaultProducer { } else { throw new Exception("Body does not contain Stanza/Stanza[] object(s)"); } - } catch (XMPPException xmppe) { + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); throw new RuntimeExchangeException( - "Cannot send XMPP direct: from " + endpoint.getUser() + " to: " + "Interrupted while sending XMPP direct: from " + endpoint.getUser() + " to: " + XmppEndpoint.getConnectionMessage(connection), - exchange, xmppe); + exchange, e); } catch (Exception e) { throw new RuntimeExchangeException( diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java index 4b22dc03c06..c6ad065fe2c 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java @@ -52,6 +52,9 @@ public class XmppGroupChatProducer extends DefaultProducer { if (connection == null) { try { connection = endpoint.createConnection(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeExchangeException("Interrupted while connecting to XMPP server.", exchange, e); } catch (Exception e) { throw new RuntimeExchangeException("Could not connect to XMPP server.", exchange, e); } @@ -60,6 +63,9 @@ public class XmppGroupChatProducer extends DefaultProducer { if (chat == null) { try { initializeChat(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeExchangeException("Interrupted while initializing XMPP chat.", exchange, e); } catch (Exception e) { throw new RuntimeExchangeException("Could not initialize XMPP chat.", exchange, e); } @@ -84,6 +90,9 @@ public class XmppGroupChatProducer extends DefaultProducer { // must invoke nextMessage to consume the response from the server // otherwise the client local queue will fill up (CAMEL-1467) chat.pollMessage(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeExchangeException("Interrupted while sending XMPP message: " + message, exchange, e); } catch (Exception e) { throw new RuntimeExchangeException("Could not send XMPP message: " + message, exchange, e); } diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java index 8da40f6dddf..bcd36d4f6d2 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java @@ -61,6 +61,9 @@ public class XmppPrivateChatProducer extends DefaultProducer { if (!connection.isConnected()) { this.reconnect(); } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeCamelException("Interrupted while connecting to XMPP server.", e); } catch (Exception e) { throw new RuntimeCamelException("Could not connect to XMPP server.", e); } @@ -88,6 +91,12 @@ public class XmppPrivateChatProducer extends DefaultProducer { LOG.debug("Sending XMPP message to {} from {} : {}", participant, endpoint.getUser(), message.getBody()); } chat.send(message); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeExchangeException( + "Interrupted while sending XMPP message to " + participant + " from " + endpoint.getUser() + " : " + message + + " to: " + XmppEndpoint.getConnectionMessage(connection), + exchange, e); } catch (Exception e) { throw new RuntimeExchangeException( "Could not send XMPP message to " + participant + " from " + endpoint.getUser() + " : " + message
