From c6e3bb846399de4357560aeb905de73688736940 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 1 Dec 2010 10:15:55 +0000 Subject: [PATCH] [MRM-1437] close stream in CLI Submitted by: Dave Brosius git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1040930 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/archiva/cli/ArchivaCli.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java index 0c91aaf2b..cc4d1a156 100644 --- a/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java +++ b/archiva-cli/src/main/java/org/apache/maven/archiva/cli/ArchivaCli.java @@ -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; -- 2.39.5