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

Fix for IndexOutOfBoundsException in sarif placeholder #2649

Merged

Conversation

gtoison
Copy link
Contributor

@gtoison gtoison commented Oct 17, 2023

When the bug description has a placeholder for a non-existent annotation the sarif placeholder class causes a IndexOutOfBoundsException

This is most likely a side effect of #2627

Fixes #2632

When the bug description has a placeholder for a non-existent annotation
the sarif placeholder class causes a IndexOutOfBoundsException
edu.umd.cs.findbugs.FindBugsMessageFormat#format handles the case when
the bug description contains a place holder but the corresponding
annotation does not exist. Let the sarif placeholder handle this the
same way
@gtoison gtoison marked this pull request as ready for review October 17, 2023 20:35
@@ -28,6 +28,12 @@ class Placeholder {

@NonNull
String toArgument(List<? extends BugAnnotation> bugAnnotations, @Nullable ClassAnnotation primaryClass) {
return bugAnnotations.get(index).format(key, primaryClass);
if (index < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gtoison Can you combine the 'if' here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two look similar but are different (< vs. >), I used the same format as edu.umd.cs.findbugs.FindBugsMessageFormat#format so the same problem will produce a similar output

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks, I looked at that multiple times but wasn't seeing it. All good.

@hazendaz hazendaz self-assigned this Oct 17, 2023
@hazendaz hazendaz merged commit bb2d705 into spotbugs:master Oct 17, 2023
6 checks passed
@hazendaz hazendaz added this to the Spotbugs 4.8.1 milestone Dec 18, 2023
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.

[4.8.0] SarifBugReporter causes IndexOutOfBoundsException
2 participants