Skip to content

Commit 04be4e1

Browse files
authored
Merge pull request #39 from apache/close
use try with resources instead of deprecated method
2 parents 895b91f + 4b4101c commit 04be4e1

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import java.util.Properties;
3939
import java.util.Set;
4040

41-
import org.apache.commons.io.IOUtils;
4241
import org.apache.maven.artifact.Artifact;
4342
import org.apache.maven.artifact.DependencyResolutionRequiredException;
4443
import org.apache.maven.model.Resource;
@@ -496,7 +495,6 @@ private Properties getOverridingProperties( CheckstyleExecutorRequest request )
496495
throws CheckstyleExecutorException
497496
{
498497
Properties p = new Properties();
499-
InputStream in = null;
500498
try
501499
{
502500
if ( request.getPropertiesLocation() != null )
@@ -511,10 +509,10 @@ private Properties getOverridingProperties( CheckstyleExecutorRequest request )
511509

512510
if ( propertiesFile != null )
513511
{
514-
in = new FileInputStream( propertiesFile );
515-
p.load( in );
516-
in.close();
517-
in = null;
512+
try ( InputStream in = new FileInputStream( propertiesFile ) )
513+
{
514+
p.load( in );
515+
}
518516
}
519517
}
520518

@@ -570,10 +568,6 @@ private Properties getOverridingProperties( CheckstyleExecutorRequest request )
570568
{
571569
throw new CheckstyleExecutorException( "Failed to get overriding properties", e );
572570
}
573-
finally
574-
{
575-
IOUtils.closeQuietly( in );
576-
}
577571
if ( request.getSuppressionsFileExpression() != null )
578572
{
579573
String suppressionsFilePath = getSuppressionsFilePath( request );

0 commit comments

Comments
 (0)