You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/03/02 11:46:33 UTC

[GitHub] [maven] kdebski85 commented on a change in pull request #589: [MNG-7304] - Use try-with-resources Statement

kdebski85 commented on a change in pull request #589:
URL: https://github.com/apache/maven/pull/589#discussion_r817613991



##########
File path: maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
##########
@@ -553,9 +553,8 @@ else if ( cliRequest.commandLine.hasOption( CLIManager.BATCH_MODE )
             logFile = resolveFile( logFile, cliRequest.workingDirectory );
 
             // redirect stdout and stderr to file
-            try
+            try ( PrintStream ps = new PrintStream( new FileOutputStream( logFile ) ) )

Review comment:
       PrintStream `ps` should not be closed here because it is passed to `System.setOut` and `System.setErr`. It will be automatically closed when `try-with-resource` block ends.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org