[GitHub] acheaito closed pull request #1: [MHP-143] Switch to try with resources to avoid NPE on IOUtils.close

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] acheaito closed pull request #1: [MHP-143] Switch to try with resources to avoid NPE on IOUtils.close

GitBox
acheaito closed pull request #1: [MHP-143] Switch to try with resources to avoid NPE on IOUtils.close
URL: https://github.com/apache/maven-help-plugin/pull/1
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
index cbcbd5e..73972ed 100644
--- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
@@ -32,7 +32,6 @@
 import java.util.Set;
 
 import org.apache.commons.lang3.time.DateFormatUtils;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.WriterFactory;
 import org.codehaus.plexus.util.xml.XMLWriter;
 import org.codehaus.plexus.util.xml.XmlWriterUtil;
@@ -57,7 +56,6 @@
      *
      * @param output is the wanted output file.
      * @param content contains the XML content to be written to the file.
-     * @param encoding is the wanted encoding to use when writing file.
      * @throws IOException if any
      * @see AbstractHelpMojo#writeFile(File, String) if encoding is null.
      */
@@ -69,21 +67,11 @@ protected static void writeXmlFile( File output, String content )
             return;
         }
 
-        Writer out = null;
-        try
-        {
-            output.getParentFile().mkdirs();
+        output.getParentFile().mkdirs();
 
-            out = WriterFactory.newXmlWriter( output );
-
-            out.write( content );
-
-            out.close();
-            out = null;
-        }
-        finally
+        try ( Writer out = WriterFactory.newXmlWriter( output ) )
         {
-            IOUtil.close( out );
+            out.write( content );
         }
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services