activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: NO-JIRA close connection factory in CLI
Date Wed, 10 Oct 2018 22:39:52 GMT
NO-JIRA close connection factory in CLI

Fix warning seen in logs during test case runs, caused by CF not being closed.

Oct 10, 2018 8:53:18 PM org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl
finalize
WARN: AMQ212008: I am closing a core ClientSessionFactory you left open. Please make sure
you close all ClientSessionFactories explicitly before letting them go out of scope! 639,542,871
java.lang.Exception
	at org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.<init>(ClientSessionFactoryImpl.java:171)
	at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:779)
	at org.apache.activemq.artemis.cli.commands.messages.DestAbstract.getManagementSession(DestAbstract.java:103)
	at org.apache.activemq.artemis.cli.commands.messages.DestAbstract.getQueueAttribute(DestAbstract.java:127)
	at org.apache.activemq.artemis.cli.commands.messages.DestAbstract.getQueueIdFromName(DestAbstract.java:116)
	at org.apache.activemq.artemis.cli.commands.messages.Producer.execute(Producer.java:75)
	at org.apache.activemq.artemis.cli.Artemis.internalExecute(Artemis.java:150)
	at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:98)
	at org.apache.activemq.artemis.cli.Artemis.execute(Artemis.java:125)
	at org.apache.activemq.artemis.cli.Artemis.main(Artemis.java:81)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/50f6bb5d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/50f6bb5d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/50f6bb5d

Branch: refs/heads/master
Commit: 50f6bb5d07b5f609befc94fcde1808fdc0448e68
Parents: a65374f
Author: Michael André Pearce <michael.andre.pearce@me.com>
Authored: Wed Oct 10 22:11:21 2018 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Oct 10 18:39:46 2018 -0400

----------------------------------------------------------------------
 .../activemq/artemis/cli/commands/messages/Browse.java       | 4 ++++
 .../activemq/artemis/cli/commands/messages/Consumer.java     | 8 ++++++--
 .../activemq/artemis/cli/commands/messages/Producer.java     | 4 ++++
 3 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/50f6bb5d/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java
index e249cbf..7af3713 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Browse.java
@@ -69,6 +69,10 @@ public class Browse extends DestAbstract {
          }
 
          return received;
+      } finally {
+         if (factory instanceof AutoCloseable) {
+            ((AutoCloseable) factory).close();
+         }
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/50f6bb5d/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java
index 856e82b..c756e60 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Consumer.java
@@ -55,8 +55,6 @@ public class Consumer extends DestAbstract {
 
       System.out.println("Consumer:: filter = " + filter);
 
-      ConnectionFactory factory = createConnectionFactory();
-
       SerialiserMessageListener listener = null;
       MessageSerializer messageSerializer = null;
       if (file != null) {
@@ -83,6 +81,8 @@ public class Consumer extends DestAbstract {
 
       if (messageSerializer != null) messageSerializer.start();
 
+      ConnectionFactory factory = createConnectionFactory();
+
       try (Connection connection = factory.createConnection()) {
          // We read messages in a single thread when persisting to file.
          ConsumerThread[] threadsArray = new ConsumerThread[threads];
@@ -118,6 +118,10 @@ public class Consumer extends DestAbstract {
          if (messageSerializer != null) messageSerializer.stop();
 
          return received;
+      } finally {
+         if (factory instanceof AutoCloseable) {
+            ((AutoCloseable) factory).close();
+         }
       }
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/50f6bb5d/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java
index 0936578..fc60e40 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Producer.java
@@ -137,6 +137,10 @@ public class Producer extends DestAbstract {
             }
             return messagesProduced;
          }
+      } finally {
+         if (factory instanceof AutoCloseable) {
+            ((AutoCloseable) factory).close();
+         }
       }
    }
 


Mime
View raw message