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

Handle MavenMetadata parser result NPE as reported by community member #4285

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timtebeek
Copy link
Contributor

What's changed?

Prevent an NPE by adding a null check, and changing the API response to be nullable to handle it downstream.

What's your motivation?

A community member reported seeing an exception that I can't explain otherwise.

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.34.1:run (default-cli) on project xxx-v1: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.34.1:run failed: Error while visiting pom.xml: java.lang.NullPointerException: Cannot invoke "org.openrewrite.maven.tree.MavenMetadata.getVersioning()" because "metadata" is null
[ERROR]   org.openrewrite.maven.tree.MavenMetadata.parse(MavenMetadata.java:85)
[ERROR]   org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:273)
[ERROR]   org.openrewrite.maven.internal.MavenPomDownloader.downloadMetadata(MavenPomDownloader.java:224)
[ERROR]   org.openrewrite.maven.MavenVisitor.downloadMetadata(MavenVisitor.java:363)
[ERROR]   org.openrewrite.maven.MavenVisitor.downloadMetadata(MavenVisitor.java:358)
[ERROR]   org.openrewrite.maven.UpgradeDependencyVersion$2.lambda$findNewerVersion$0(UpgradeDependencyVersion.java:340)
[ERROR]   org.openrewrite.maven.table.MavenMetadataFailures.insertRows(MavenMetadataFailures.java:55)
[ERROR]   org.openrewrite.maven.UpgradeDependencyVersion$2.findNewerVersion(UpgradeDependencyVersion.java:340)
[ERROR]   org.openrewrite.maven.UpgradeDependencyVersion$2.upgradeDependency(UpgradeDependencyVersion.java:217)
[ERROR]   org.openrewrite.maven.UpgradeDependencyVersion$2.visitTag(UpgradeDependencyVersion.java:157)
[ERROR]   org.openrewrite.maven.UpgradeDependencyVersion$2.visitTag(UpgradeDependencyVersion.java:149)
[ERROR]   org.openrewrite.xml.tree.Xml$Tag.acceptXml(Xml.java:466)
[ERROR]   org.openrewrite.xml.tree.Xml.accept(Xml.java:53)
[ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
[ERROR]   org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:324)
[ERROR]   org.openrewrite.xml.XmlVisitor.lambda$visitTag$2(XmlVisitor.java:91)
[ERROR]   ...
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Have you considered any alternatives or workarounds?

Not yet; this was mostly a quick attempt at replicating the issue, which failed, and then a subsequent at preventing the issue to kick off discussion on what avenues to explore.

Any additional context

Tried to replicate this with a test using various values for the byte array, but none immediately lead to MavenMetadata metadata being null, as found in the stack trace above.

In the surrounding code there seem to be some edge cases where it concerns Nexus specifically; I've asked if this is what the user has in their environment.

@timtebeek timtebeek self-assigned this Jun 25, 2024
@timtebeek timtebeek added the bug Something isn't working label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant