Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPMD-369] Make integration tests robust against system encoding #122

Merged
merged 2 commits into from
Apr 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/

import java.io.File;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -114,13 +115,12 @@ protected void printError( Duplication item, String severity )
* {@inheritDoc}
*/
@Override
protected List<Duplication> getErrorDetails( File cpdFile )
throws XmlPullParserException, IOException
protected List<Duplication> getErrorDetails( File cpdFile ) throws XmlPullParserException, IOException
{
try ( FileReader fileReader = new FileReader( cpdFile ) )
try ( InputStream in = new FileInputStream( cpdFile ) )
{
CpdXpp3Reader reader = new CpdXpp3Reader();
CpdErrorDetail details = reader.read( fileReader, false );
CpdErrorDetail details = reader.read( in, false );
return details.getDuplications();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
*/

import java.io.File;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -124,14 +125,12 @@ protected void printError( Violation item, String severity )
}

@Override
protected List<Violation> getErrorDetails( File pmdFile )
throws XmlPullParserException, IOException
protected List<Violation> getErrorDetails( File pmdFile ) throws XmlPullParserException, IOException
{
try ( FileReader reader1 = new FileReader( pmdFile ) )
try ( InputStream in = new FileInputStream( pmdFile ) )
{
PmdXpp3Reader reader = new PmdXpp3Reader();
PmdErrorDetail details = reader.read( reader1, false );

PmdErrorDetail details = reader.read( in, false );
List<Violation> violations = new ArrayList<>();
for ( PmdFile file : details.getFiles() )
{
Expand Down