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

Reproduction case of exception thrown when disabling check thats also in XepPatchChecks #2

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

Conversation

oxkitsune
Copy link

When disabling a check using -Xep:XXX:OFF while the check is listed in -XepPatchChecks results in a NoSuchElementException being thrown when EP tries to get the severity level of the check.

This PR introduces code that triggers the StaticImport check to get a reproducible case.

The issue can be reproduced using the following mvn invocation:

mvn clean install \
-Perror-prone \
-Derror-prone.patch-args="-XepPatchLocation:IN_PLACE -XepPatchChecks:StaticImport -Xep:StaticImport:OFF"

And results in the following exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project error-prone-demo: Compilation failure
[ERROR] ~/error-prone-demo/src/main/java/com/example/HelloWorld.java:[22,64] An unhandled exception was thrown by the Error Prone static analysis plugin.
[ERROR]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
[ERROR]
[ERROR]      error-prone version: 2.19.1
[ERROR]      BugPattern: StaticImport
[ERROR]      Stack Trace:
[ERROR]      java.util.NoSuchElementException: No value present
[ERROR]   	at java.base/java.util.Optional.get(Optional.java:143)
[ERROR]   	at com.google.errorprone.matchers.Description.severity(Description.java:78)
[ERROR]   	at com.google.errorprone.ErrorProneAnalyzer.lambda$finished$1(ErrorProneAnalyzer.java:138)
[ERROR]   	at com.google.errorprone.VisitorState.reportMatch(VisitorState.java:301)
[ERROR]   	at com.google.errorprone.scanner.Scanner.reportMatch(Scanner.java:127)
[ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:448)
[ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:726)
[ERROR]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:150)

@rickie
Copy link
Owner

rickie commented Jun 27, 2023

As discussed offline; related Error Prone issue: google/error-prone#3908.

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.

None yet

2 participants