Skip to content

Commit 8ee2834

Browse files
committed
Require Java 8
1 parent 0e1eefd commit 8ee2834

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</distributionManagement>
3434

3535
<properties>
36-
<javaVersion>7</javaVersion>
36+
<javaVersion>8</javaVersion>
3737
<sisuVersion>0.3.5</sisuVersion>
3838
</properties>
3939

src/main/java/org/sonatype/plexus/components/sec/dispatcher/DefaultSecDispatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public DefaultSecDispatcher( final PlexusCipher _cipher,
7777
* Ctor to be used in tests and other simplified cases (no decryptors and config).
7878
*/
7979
public DefaultSecDispatcher( final PlexusCipher _cipher ) {
80-
this( _cipher, new HashMap<String, PasswordDecryptor>(), DEFAULT_CONFIGURATION );
80+
this( _cipher, new HashMap<>(), DEFAULT_CONFIGURATION );
8181
}
8282

8383
// ---------------------------------------------------------------

src/main/java/org/sonatype/plexus/components/sec/dispatcher/SecUtil.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
package org.sonatype.plexus.components.sec.dispatcher;
1515

16-
import java.io.FileInputStream;
1716
import java.io.IOException;
1817
import java.io.InputStream;
1918
import java.net.URL;
19+
import java.nio.file.Files;
20+
import java.nio.file.Paths;
2021
import java.util.HashMap;
2122
import java.util.List;
2223
import java.util.Map;
@@ -45,17 +46,15 @@ public static SettingsSecurity read( String location, boolean cycle )
4546
{
4647
if( location == null )
4748
throw new SecDispatcherException("location to read from is null");
48-
49-
InputStream in = null;
49+
50+
SettingsSecurity sec;
5051

5152
try
5253
{
53-
in = toStream( location );
54-
55-
SettingsSecurity sec = new SecurityConfigurationXpp3Reader().read( in );
56-
57-
in.close();
58-
54+
try (InputStream in = toStream( location )) {
55+
sec = new SecurityConfigurationXpp3Reader().read(in);
56+
}
57+
5958
if( cycle && sec.getRelocation() != null )
6059
return read( sec.getRelocation(), true );
6160

@@ -65,11 +64,6 @@ public static SettingsSecurity read( String location, boolean cycle )
6564
{
6665
throw new SecDispatcherException(e);
6766
}
68-
finally
69-
{
70-
if( in != null )
71-
try { in.close(); } catch( Exception e ) {}
72-
}
7367
}
7468
//---------------------------------------------------------------------------------------------------------------
7569
private static InputStream toStream( String resource )
@@ -92,7 +86,7 @@ private static InputStream toStream( String resource )
9286
}
9387
}
9488

95-
return new FileInputStream( resource );
89+
return Files.newInputStream(Paths.get(resource));
9690
}
9791
//---------------------------------------------------------------------------------------------------------------
9892
public static Map<String, String> getConfig( SettingsSecurity sec, String name )

src/test/java/org/sonatype/plexus/components/sec/dispatcher/SecUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testRead()
9292

9393
assertEquals( _pw, sec.getMaster() );
9494

95-
Map conf = SecUtil.getConfig( sec, _confName );
95+
Map<String, String> conf = SecUtil.getConfig( sec, _confName );
9696

9797
assertNotNull( conf );
9898

0 commit comments

Comments
 (0)