[MNG-6844] Use StandardCharsets and remove outdated @SuppressWarnings

This closes #312
This commit is contained in:
Artem Krosheninnikov 2020-01-09 11:12:22 +03:00 committed by Michael Osipov
parent f3e6641c2e
commit 735b72fcf1
10 changed files with 11 additions and 27 deletions

View File

@ -26,6 +26,7 @@
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
/**
* Tests that the global settings.xml shipped with the distribution is in good state.
@ -44,7 +45,7 @@ public void testValidGlobalSettings()
File globalSettingsFile = new File( basedir, "src/conf/settings.xml" );
assertTrue( globalSettingsFile.getAbsolutePath(), globalSettingsFile.isFile() );
try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), "UTF-8" ) )
try ( Reader reader = new InputStreamReader( new FileInputStream( globalSettingsFile ), StandardCharsets.UTF_8) )
{
new SettingsXpp3Reader().read( reader );
}

View File

@ -22,6 +22,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
* Wraps an ordinary {@link CharSequence} as a source.
@ -62,7 +63,7 @@ public StringSource( CharSequence content, String location )
public InputStream getInputStream()
throws IOException
{
return new ByteArrayInputStream( content.getBytes( "UTF-8" ) );
return new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) );
}
@Override

View File

@ -55,7 +55,6 @@ public class DefaultModelInheritanceAssembler
implements ModelInheritanceAssembler
{
// TODO Remove this!
@SuppressWarnings( "unchecked" )
public void assembleBuildInheritance( Build childBuild, Build parentBuild, boolean handleAsInheritance )
{
// The build has been set but we want to step in here and fill in
@ -307,7 +306,6 @@ private void assembleModelInheritance( Model child, Model parent, String childPa
}
// TODO Remove this!
@SuppressWarnings( "unchecked" )
private void assembleDependencyManagementInheritance( Model child, Model parent )
{
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
@ -527,7 +525,6 @@ else if ( handleAsInheritance && ( parentInherited == null ) )
}
// TODO Remove this!
@SuppressWarnings( "unchecked" )
private void assembleDependencyInheritance( Model child, Model parent )
{
Map<String, Dependency> depsMap = new LinkedHashMap<>();

View File

@ -59,6 +59,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -293,7 +294,7 @@ protected void createArtifact( Artifact artifact, ArtifactRepository repository
{
artifactFile.getParentFile().mkdirs();
}
try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), "ISO-8859-1" ) )
try ( Writer writer = new OutputStreamWriter( new FileOutputStream( artifactFile ), StandardCharsets.ISO_8859_1) )
{
writer.write( artifact.getId() );
}

View File

@ -22,6 +22,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@ -72,14 +73,7 @@ public void fillInputData( InputData inputData )
resource.setContentLength( content.length() );
resource.setLastModified( System.currentTimeMillis() );
try
{
inputData.setInputStream( new ByteArrayInputStream( content.getBytes( "UTF-8" ) ) );
}
catch ( UnsupportedEncodingException e )
{
throw new Error( "broken JVM", e );
}
inputData.setInputStream( new ByteArrayInputStream( content.getBytes( StandardCharsets.UTF_8 ) ) );
}
else
{

View File

@ -33,7 +33,6 @@ public void testAptConsistency()
{
File apt = getTestFile( "src/site/apt/artifact-handlers.apt" );
@SuppressWarnings( "unchecked" )
List<String> lines = FileUtils.loadFile( apt );
for ( String line : lines )

View File

@ -47,7 +47,6 @@ public static DefaultLifecycles createDefaultLifecycles()
List<String> stubSiteCycle =
Arrays.asList( PRE_SITE.getPhase(), SITE.getPhase(), POST_SITE.getPhase(), SITE_DEPLOY.getPhase() );
@SuppressWarnings( "unchecked" )
Iterator<List<String>> lcs = Arrays.asList( stubDefaultCycle, stubCleanCycle, stubSiteCycle ).iterator();
Map<String, Lifecycle> lifeCycles = new HashMap<>();

View File

@ -25,7 +25,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import junit.framework.TestCase;
@ -61,14 +61,7 @@ protected void tearDown()
private InputStream toStream( String xml )
{
try
{
return new ByteArrayInputStream( xml.getBytes( "UTF-8" ) );
}
catch ( UnsupportedEncodingException e )
{
throw new IllegalStateException( e );
}
return new ByteArrayInputStream( xml.getBytes( StandardCharsets.UTF_8 ) );
}
public void testEmptyDescriptor()

View File

@ -107,7 +107,7 @@ public class CLIManager
protected Options options;
@SuppressWarnings( { "static-access", "checkstyle:linelength" } )
@SuppressWarnings( "checkstyle:linelength" )
public CLIManager()
{
options = new Options();

View File

@ -72,7 +72,6 @@ public Object getValue( String expression )
}
@Override
@SuppressWarnings( "unchecked" )
public List getFeedback()
{
return valueSource.getFeedback();