You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@artemis.apache.org by jb...@apache.org on 2026/10/08 16:47:38 UTC

(artemis) branch main updated: ARTEMIS-6233 Close imported message input stream

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

jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ed60a78f7 ARTEMIS-6233 Close imported message input stream
6ed60a78f7 is described below

commit 6ed60a78f75a9e91136e7c3908d52f6c1db4dbfc
Author: wellorbetter <92...@users.noreply.github.com>
AuthorDate: Fri Oct 2 19:05:16 2026 +0800

    ARTEMIS-6233 Close imported message input stream
    
    Close the input stream created by the CLI producer after importing
    serialized messages. This releases the imported file on both successful
    and failed imports while preserving existing transaction handling.
---
 .../artemis/cli/commands/messages/Producer.java    | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

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 3e44b2a0be..dd6af8e6d0 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
@@ -176,19 +176,21 @@ public class Producer extends DestAbstract {
                   return null;
                }
 
-               serializer.setInput(in, session);
-               serializer.start();
+               try (in) {
+                  serializer.setInput(in, session);
+                  serializer.start();
 
-               Message message = serializer.read();
+                  Message message = serializer.read();
 
-               while (message != null) {
-                  producer.send(message);
-                  message = serializer.read();
-                  messageCount++;
-               }
+                  while (message != null) {
+                     producer.send(message);
+                     message = serializer.read();
+                     messageCount++;
+                  }
 
-               session.commit();
-               serializer.stop();
+                  session.commit();
+                  serializer.stop();
+               }
             } catch (Exception e) {
                context.err.println("Error occurred during import.  Rolling back.");
                session.rollback();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@artemis.apache.org
For additional commands, e-mail: commits-help@artemis.apache.org