]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1437] close stream in CLI
authorBrett Porter <brett@apache.org>
Wed, 1 Dec 2010 10:15:55 +0000 (10:15 +0000)
committerBrett Porter <brett@apache.org>
Wed, 1 Dec 2010 10:15:55 +0000 (10:15 +0000)
Submitted by: Dave Brosius

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1040930 13f79535-47bb-0310-9956-ffa450edef68

archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java

index 0c91aaf2b02010820d6764c3980b9ce95ca16e3d..cc4d1a156f76fe6f65bebcbc040a07c165b004a7 100644 (file)
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -66,14 +67,28 @@ public class ArchivaCli
     public static final String TARGET_REPO_PATH = "targetRepositoryPath";
 
     public static final String BLACKLISTED_PATTERNS = "blacklistPatterns";
+    
+    public static final String POM_PROPERTIES = "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties";
 
     private static String getVersion()
         throws IOException
     {
-        Properties properties = new Properties();
-        properties.load(
-            ArchivaCli.class.getResourceAsStream( "/META-INF/maven/org.apache.archiva/archiva-cli/pom.properties" ) );
-        return properties.getProperty( "version" );
+        InputStream pomStream = ArchivaCli.class.getResourceAsStream( POM_PROPERTIES );
+        if ( pomStream == null )
+        {
+            throw new IOException( "Failed to load " + POM_PROPERTIES );
+        }
+
+        try
+        {
+            Properties properties = new Properties();
+            properties.load( pomStream );
+            return properties.getProperty( "version" );
+        }
+        finally
+        {
+            IOUtils.closeQuietly( pomStream );
+        }
     }
 
     private PlexusClassPathXmlApplicationContext applicationContext;