Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</distributionManagement>

<properties>
<javaVersion>7</javaVersion>
<javaVersion>8</javaVersion>
<sisuVersion>0.3.5</sisuVersion>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public DefaultSecDispatcher( final PlexusCipher _cipher,
* Ctor to be used in tests and other simplified cases (no decryptors and config).
*/
public DefaultSecDispatcher( final PlexusCipher _cipher ) {
this( _cipher, new HashMap<String, PasswordDecryptor>(), DEFAULT_CONFIGURATION );
this( _cipher, new HashMap<>(), DEFAULT_CONFIGURATION );
}

// ---------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

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

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -45,17 +46,15 @@ public static SettingsSecurity read( String location, boolean cycle )
{
if( location == null )
throw new SecDispatcherException("location to read from is null");
InputStream in = null;

SettingsSecurity sec;

try
{
in = toStream( location );

SettingsSecurity sec = new SecurityConfigurationXpp3Reader().read( in );

in.close();

try (InputStream in = toStream( location )) {
sec = new SecurityConfigurationXpp3Reader().read(in);
}

if( cycle && sec.getRelocation() != null )
return read( sec.getRelocation(), true );

Expand All @@ -65,11 +64,6 @@ public static SettingsSecurity read( String location, boolean cycle )
{
throw new SecDispatcherException(e);
}
finally
{
if( in != null )
try { in.close(); } catch( Exception e ) {}
}
}
//---------------------------------------------------------------------------------------------------------------
private static InputStream toStream( String resource )
Expand All @@ -92,7 +86,7 @@ private static InputStream toStream( String resource )
}
}

return new FileInputStream( resource );
return Files.newInputStream(Paths.get(resource));
}
//---------------------------------------------------------------------------------------------------------------
public static Map<String, String> getConfig( SettingsSecurity sec, String name )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testRead()

assertEquals( _pw, sec.getMaster() );

Map conf = SecUtil.getConfig( sec, _confName );
Map<String, String> conf = SecUtil.getConfig( sec, _confName );

assertNotNull( conf );

Expand Down