-
Notifications
You must be signed in to change notification settings - Fork 629
Fix CT_CONSTRUCTOR_THROW
FP in private and public ctor with private ctor first
#3424
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
Conversation
@Override | ||
public void visit(Method obj) { | ||
hadObjectConstructor = false; | ||
super.visit(obj); | ||
} | ||
|
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.
The fix to the issue is this function and deleting line 89. The other changes in this class are only cleanup. The bug is reported if hadObjectConstructor
field is true in the second visit in reportConstructorThrow
, which is set in the second visit, but it was only set back to false during the first visit.
private static boolean verify() throws IOException { | ||
// Returns true if data entered is valid, else throws an Exception | ||
// Assume that the attacker just enters invalid data, so this method always throws the exception | ||
throw new IOException("Invalid data!"); | ||
} | ||
|
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 looks like this code example and ConstructorThrowNegativeTest16 were completely the same. So I'm changing it slightly.
Small cleanup in the
ConstructorThrow
detector and fix #3417.Make sure these boxes are checked before submitting your PR -- thank you!
CHANGELOG.md
if you have changed SpotBugs code