Removed file handle leak in testcase
authorKristian Rosenvold <krosenvold@apache.org>
Thu, 19 Nov 2015 06:19:18 +0000 (06:19 +0000)
committerKristian Rosenvold <krosenvold@apache.org>
Thu, 19 Nov 2015 06:19:18 +0000 (06:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1715099 13f79535-47bb-0310-9956-ffa450edef68

src/test/java/org/apache/maven/plugin/ant/AntMojoTest.java

index 0940680..6f1ffed 100644 (file)
@@ -125,8 +125,12 @@ public class AntMojoTest
                 new File( antBasedir, "target/" + currentProject.getBuild().getFinalName() + ".jar" ).exists() );
 
             Properties properties = new Properties();
-            properties.load(
-                new FileInputStream( new File( antBasedir, AntBuildWriter.DEFAULT_MAVEN_PROPERTIES_FILENAME ) ) );
+            final FileInputStream inStream = new FileInputStream(new File(antBasedir, AntBuildWriter.DEFAULT_MAVEN_PROPERTIES_FILENAME));
+            try {
+                properties.load(inStream);
+            } finally {
+                inStream.close();
+            }
             String repo = properties.getProperty( "maven.repo.local" );
             assertTrue( repo.equals( new File( getBasedir(), "target/local-repo" ).getAbsolutePath() ) );
         }