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

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

commit 4b4101cc43dd103508e184e39d42a322ed904c27
Author: Elliotte Harold <elh...@ibiblio.org>
AuthorDate: Wed Nov 25 14:06:37 2020 -0500

    use try with resources instead of deprecated method
---
 .../plugins/checkstyle/exec/DefaultCheckstyleExecutor.java | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
 
b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
index ce7f213..4481506 100644
--- 
a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
+++ 
b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
@@ -38,7 +38,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.model.Resource;
@@ -496,7 +495,6 @@ public class DefaultCheckstyleExecutor
         throws CheckstyleExecutorException
     {
         Properties p = new Properties();
-        InputStream in = null;
         try
         {
             if ( request.getPropertiesLocation() != null )
@@ -511,10 +509,10 @@ public class DefaultCheckstyleExecutor
 
                 if ( propertiesFile != null )
                 {
-                    in = new FileInputStream( propertiesFile );
-                    p.load( in );
-                    in.close();
-                    in = null;
+                    try ( InputStream in = new FileInputStream( propertiesFile 
) )
+                    {
+                        p.load( in );
+                    }
                 }
             }
 
@@ -570,10 +568,6 @@ public class DefaultCheckstyleExecutor
         {
             throw new CheckstyleExecutorException( "Failed to get overriding 
properties", e );
         }
-        finally
-        {
-            IOUtils.closeQuietly( in );
-        }
         if ( request.getSuppressionsFileExpression() != null )
         {
             String suppressionsFilePath = getSuppressionsFilePath( request );

Reply via email to