Skip to content

Conversation

@chiacyu
Copy link
Contributor

@chiacyu chiacyu commented Mar 9, 2025

What changes were proposed in this pull request?

Currently we're using thenReturn() statements in the tests, we should change it with doReturn().

What is the link to the Apache JIRA

HDDS-12505

How was this patch tested?

Tested by CI.

Comment on lines +22 to +33
<Match>
<Class name="org.apache.hadoop.hdds.scm.storage.DummyBlockInputStreamWithRetry"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
</Match>
<Match>
<Class name="org.apache.hadoop.hdds.scm.storage.TestBlockInputStream"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
</Match>
<Match>
<Class name="org.apache.hadoop.ozone.client.io.TestBlockInputStreamFactoryImpl"/>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
</Match>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not add these.

  • It is completely non-scalable to add an exclusion for each test class.
  • We should reduce the number of exclusions, not increase it (HDDS-12342).
  • Only 3 classes are added here, but 5 classes are changed similarly. I'm guessing the others were not reported by spotbugs. The problem is that spotbugs analysis is not 100% accurate, and sometimes starts reporting existing problems only later, when making changes in other classes.

This is a spotbugs problem. @peterxcli reported it few weeks ago: #7963 (comment)

I don't know if the problem is fixed by more recent versions of spotbugs. Unfortunately we have to use an older version of spotbugs due to lots of new issues reported by newer one (HDDS-10150).

I think we should either

  • defer mass conversion to doReturn until we have a version of spotbugs where this is fixed, OR
  • add exclusion for this issue in all test classes using pattern matching, AND enable similar rule in PMD (subtask of HDDS-12338).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @adoroszlai
Thanks for the point out, which one would be better? How about we hold on the doReturn() changes, but I would still create a subtask of HDDS-12338 for that? thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

On quick glance I couldn't find similar rule in PMD.

@adoroszlai adoroszlai marked this pull request as draft March 10, 2025 06:30
@adoroszlai
Copy link
Contributor

Thanks again @chiacyu for the patch. Let's revisit this once we get spotbugs fixed.

@adoroszlai adoroszlai closed this Mar 20, 2025
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.

2 participants