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-366] Update parent pom to 39 #118

Merged
merged 5 commits into from
Apr 6, 2023
Merged

[MPMD-366] Update parent pom to 39 #118

merged 5 commits into from
Apr 6, 2023

Conversation

elharo
Copy link
Contributor

@elharo elharo commented Apr 1, 2023

No description provided.

@elharo elharo requested a review from michael-o April 1, 2023 01:47
@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

This is failing locally with java 11 on a Mac. Looks like an XML reader or writer might have screwed up encoding somewhere:

\n[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.21.0-SNAPSHOT:check (default) on project mpmd-138-mod-1: Unable to read PMD results xml: /Users/elharo/maven-pmd-plugin/target/it/mpmd-138/mod-1/target/pmd.xml: UTF-8 BOM plus xml decl of ISO-8859-1 is incompatible (position: START_DOCUMENT seen <?xml version="1.0" encoding="ISO-8859-1"... @1:42) -> [Help 1]\n[ERROR] \n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException\n[ERROR] \n[ERROR] After correcting the problems, you can resume the build with the command\n[ERROR] mvn -rf :mpmd-138-mod-1\nRunning post-build script: /Users/elharo/maven-pmd-plugin/target/it/mpmd-138/verify.groovy\n'
| /Users/elharo/maven-pmd-plugin/target/it/mpmd-138/build.log
false

@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

I don't see a byte order mark in the hex dump so the error message is strange.

(base) ~/maven-pmd-plugin$ hexdump /Users/elharo/maven-pmd-plugin/target/it/mpmd-138/mod-1/target/pmd.xml
0000000 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31

@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

specific error likely comes from org.codehaus.plexus.util.xml.pull somewhere. Whether that is buggy or there's an actual problem in this file I'm not yet sure.

@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

specifically the message comes from https://github.com/codehaus-plexus/plexus-utils/blob/bf198ff5d8f3bd5eb90d09826006c4d419884660/src/main/java/org/codehaus/plexus/util/xml/pull/MXParser.java#L3439

           if ( "UTF8".equals( fileEncoding ) && inputEncoding.toUpperCase().startsWith( "ISO-" ) )
            {
                throw new XmlPullParserException( "UTF-8 BOM plus xml decl of " + inputEncoding + " is incompatible",
                                                  this, null );
            }

Just a guess, but it's possible it's not about a byte order mark at all. That is, the encoding is specified as UTF-8 which conflicts with what's defined in the file.

@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

Problem is likely in this and similar code in the several violation check mojos:

    @Override
    protected List<Duplication> getErrorDetails( File cpdFile )
        throws XmlPullParserException, IOException
    {
        try ( FileReader fileReader = new FileReader( cpdFile ) )
        {
            CpdXpp3Reader reader = new CpdXpp3Reader();
            CpdErrorDetail details = reader.read( fileReader, false );
            return details.getDuplications();
        }
    }

It passes or fails depending on the system encoding. Instead it should use an inputstream rather than a reader and rely on the XML parser to detect the encoding.

@elharo
Copy link
Contributor Author

elharo commented Apr 5, 2023

I filed and will have to fix MPMD-369 before this PR can proceed. :-(

@elharo elharo merged commit 690dcbe into master Apr 6, 2023
@elharo elharo deleted the 39 branch April 6, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants