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

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new e3ea9f76f2 JAMES-4036 JMS mailQueue should silent interuptedExceptions 
upon shutdown
e3ea9f76f2 is described below

commit e3ea9f76f2fae3cc2fa18ec075b8b34f60b6a014
Author: Benoit TELLIER <[email protected]>
AuthorDate: Tue May 21 21:46:09 2024 +0200

    JAMES-4036 JMS mailQueue should silent interuptedExceptions upon shutdown
---
 .../org/apache/james/queue/jms/JMSCacheableMailQueue.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git 
a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
 
b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
index ed1e0ada7e..aaec36ea11 100644
--- 
a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
+++ 
b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
@@ -253,16 +253,29 @@ public class JMSCacheableMailQueue implements 
ManageableMailQueue, JMSSupport, M
                 closeConsumer(consumer);
                 closeSession(session);
             }
-
         } catch (Exception e) {
             rollback(session);
             closeConsumer(consumer);
             closeSession(session);
+            if (isInterrupt(e)) {
+                Thread.currentThread().interrupt();
+                return Mono.empty();
+            }
             return Mono.error(new MailQueueException("Unable to dequeue next 
message", e));
         }
         return Mono.empty();
     }
 
+    private static boolean isInterrupt(Throwable e) {
+        if (e instanceof InterruptedException) {
+            return true;
+        }
+        if (e == null) {
+            return false;
+        }
+        return isInterrupt(e.getCause());
+    }
+
     @Override
     public void enQueue(Mail mail, Duration delay) throws MailQueueException {
         TimeMetric timeMetric = 
metricFactory.timer(ENQUEUED_TIMER_METRIC_NAME_PREFIX + queueName.asString());


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to