From 9e97dcbb8d9aff2c1c36f95abee02e435af6fb74 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Tue, 23 Jan 2018 09:51:11 -0600 Subject: [PATCH] ARTEMIS-1414 potential PrintStream leak --- .../activemq/artemis/maven/ArtemisCreatePlugin.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java index 86668da7187..74932707811 100644 --- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java +++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java @@ -233,11 +233,10 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { throw new MojoExecutionException(e.getMessage(), e); } - PrintStream commandLineStream = new PrintStream(outputStream); - commandLineStream.println("# These are the commands used to create " + instance.getName()); - commandLineStream.println(getCommandline(listCommands)); + try (PrintStream commandLineStream = new PrintStream(outputStream)) { + commandLineStream.println("# These are the commands used to create " + instance.getName()); + commandLineStream.println(getCommandline(listCommands)); - try { Artemis.execute(home, null, listCommands); if (configuration != null) { @@ -262,8 +261,6 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException { } } - commandLineStream.close(); - FileUtil.makeExec(commandLine); getLog().info("###################################################################################################");