You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2023/07/06 14:24:29 UTC

[maven-javadoc-plugin] 01/01: [MJAVADOC-755] replace IOUtil.close with try with resources

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

elharo pushed a commit to branch MJAVADOC-755
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit f48448e93910fbb308d150d2362a487b4e37cf11
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Thu Jul 6 10:24:20 2023 -0400

    [MJAVADOC-755] replace IOUtil.close with try with resources
---
 .../java/org/apache/maven/plugins/javadoc/JavadocUtil.java     | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 3333e108..91942bb3 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -98,7 +98,6 @@ import org.apache.maven.wagon.proxy.ProxyUtils;
 import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -983,7 +982,7 @@ public class JavadocUtil {
         InvocationOutputHandler outputHandler = new PrintStreamHandler(ps, false);
         request.setOutputHandler(outputHandler);
 
-        try {
+        try (OutputStream closeMe = os) {
             outputHandler.consumeLine("Invoking Maven for the goals: " + goals + " with "
                     + (properties == null ? "no properties" : "properties=" + properties));
             outputHandler.consumeLine("");
@@ -992,15 +991,10 @@ public class JavadocUtil {
             outputHandler.consumeLine("JAVA_HOME=" + getJavaHome(log));
             outputHandler.consumeLine("JAVA_OPTS=" + getJavaOpts(log));
             outputHandler.consumeLine("");
+            return invoker.execute(request);
         } catch (IOException ioe) {
             throw new MavenInvocationException("IOException while consuming invocation output", ioe);
         }
-
-        try {
-            return invoker.execute(request);
-        } finally {
-            IOUtil.close(os);
-        }
     }
 
     /**