You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2022/12/05 06:20:34 UTC

[james-project] branch master updated: [JAMES-3841] ActiveMQ: fix potential memory leak -> ensure JMS cleanup (e.g. session, connection) in any case

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 e6e5a3b4ea [JAMES-3841] ActiveMQ: fix potential memory leak -> ensure JMS cleanup (e.g. session, connection) in any case
e6e5a3b4ea is described below

commit e6e5a3b4ea869d5d7f0f412e04fbde8625cd93c6
Author: ouvtam <ou...@8n4.pw>
AuthorDate: Sat Dec 3 22:06:31 2022 +0100

    [JAMES-3841] ActiveMQ: fix potential memory leak -> ensure JMS cleanup (e.g. session, connection) in any case
---
 .../metric/ActiveMQMetricCollectorImpl.java        | 30 ++++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java
index fc002990c9..88dcdbab92 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java
@@ -153,11 +153,19 @@ public class ActiveMQMetricCollectorImpl implements ActiveMQMetricCollector {
             stats.updateMetrics((MapMessage)reply);
         } finally {
             if (producer != null) {
-                producer.close();
+                try {
+                    producer.close();
+                } catch (JMSException e) {
+                    // ignore
+                }
             }
 
             if (consumer != null) {
-                consumer.close();
+                try {
+                    consumer.close();
+                } catch (JMSException e) {
+                    // ignore
+                }
             }
 
             if (replyTo != null) {
@@ -165,15 +173,27 @@ public class ActiveMQMetricCollectorImpl implements ActiveMQMetricCollector {
                 // free up memory if thats not done and a pool is used
                 // its possible that we will register a new mbean in jmx for
                 // every TemporaryQueue which will never get unregistered
-                replyTo.delete();
+                try {
+                    replyTo.delete();
+                } catch (JMSException e) {
+                    // ignore
+                }
             }
 
             if (session != null) {
-                session.close();
+                try {
+                    session.close();
+                } catch (JMSException e) {
+                    // ignore
+                }
             }
 
             if (connection != null) {
-                connection.close();
+                try {
+                    connection.close();
+                } catch (JMSException e) {
+                    // ignore
+                }
             }
         }
         return null;


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org