diff options
author | Olivier Lamy <olamy@apache.org> | 2014-04-08 12:03:38 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-04-08 12:03:38 +0000 |
commit | 6b9da927e4bf110d42b90f532c612739245fffd3 (patch) | |
tree | 39a6fe7f4f53ddb27ff81b28b0e7c18d76c36d83 /archiva-cli | |
parent | 751bffaef17a1d41e92f22db34f6cc13aa6506f9 (diff) | |
download | archiva-6b9da927e4bf110d42b90f532c612739245fffd3.tar.gz archiva-6b9da927e4bf110d42b90f532c612739245fffd3.zip |
start using try with resources
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1585697 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-cli')
-rw-r--r-- | archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java b/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java index 031bcac69..a65049597 100644 --- a/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java +++ b/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java @@ -75,22 +75,19 @@ public class ArchivaCli private static String getVersion() throws IOException { - InputStream pomStream = ArchivaCli.class.getResourceAsStream( POM_PROPERTIES ); - if ( pomStream == null ) - { - throw new IOException( "Failed to load " + POM_PROPERTIES ); - } - try + + + try (InputStream pomStream = ArchivaCli.class.getResourceAsStream( POM_PROPERTIES )) { + if ( pomStream == null ) + { + throw new IOException( "Failed to load " + POM_PROPERTIES ); + } Properties properties = new Properties(); properties.load( pomStream ); return properties.getProperty( "version" ); } - finally - { - IOUtils.closeQuietly( pomStream ); - } } private ClassPathXmlApplicationContext applicationContext; @@ -266,16 +263,11 @@ public class ArchivaCli Properties p = new Properties(); - FileInputStream fis = new FileInputStream( properties ); - try + try(FileInputStream fis = new FileInputStream( properties )) { p.load( fis ); } - finally - { - IOUtils.closeQuietly( fis ); - } File oldRepositoryPath = new File( p.getProperty( SOURCE_REPO_PATH ) ); |