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
Fix for Issue 2040 #2072
base: master
Are you sure you want to change the base?
Fix for Issue 2040 #2072
Conversation
This PR fixes issue spotbugs#2040 by limiting the errors reported by the detector `ThrowingExceptions` to cases where `java.lang.Exception` or `lava.lang.Throwable` appears in the exception specification of th method but it is neither inherited from an overridden method nor is is coming from another method that the method invokes. Syntathic methods are also omitted as well as methods which throw generic exceptions.
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
This PR fixes issue spotbugs#2040 by limiting the errors reported by the detector `ThrowingExceptions` to cases where `java.lang.Exception` or `lava.lang.Throwable` appears in the exception specification of th method but it is neither inherited from an overridden method nor is is coming from another method that the method invokes. Syntathic methods are also omitted as well as methods which throw generic exceptions.
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep adding test cases :)
…e false-positives from the reports
Thank you for your comments, @KengoTODA. You were right in all of them. I fixed every one and also added new test cases. Although I tested this PR on several medium-size projects, something was probably wrong with my CI loop because the tests seemed to have passed which is wrong because they should have crashed. Now with the new test cases I could fix these issues. |
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
Thanks, @ThrawnCA! You have exceptionally good eyes for typos. |
@JuditKnoll I think that this PR got stuck in limbo when Kengo retired from the project, would you have time to review it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to see more testcases, for example:
- one similar to the first example in False positive for THROWS_METHOD_THROWS_CLAUSE_THROWABLE #2040, where there is an Exception throwing method in the lambda,
- one where a RuntimeException is thrown, but it's handled by catching the parent of it.
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ThrowingExceptions.java
Outdated
Show resolved
Hide resolved
spotbugs-tests/src/test/java/edu/umd/cs/findbugs/detect/Issue2040Test.java
Outdated
Show resolved
Hide resolved
…N and THROWS_METHOD_THROWS_CLAUSE_THROWABLE
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
Throw fix
This PR fixes issue #2040 by limiting the errors reported by the detector
ThrowingExceptions
to cases wherejava.lang.Exception
orlava.lang.Throwable
appears in the exception specification of th method but it is neitherinherited from an overridden method nor is is coming from another method that the method invokes. Syntethic
methods are also omitted as well as methods which throw generic exceptions.
Make sure these boxes are checked before submitting your PR -- thank you!
CHANGELOG.md
if you have changed SpotBugs code