Skip to content

Conversation

@adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Fix findbugs warnings by making VolumeArgs immutable.

M V EI: org.apache.hadoop.ozone.client.VolumeArgs.getAcls() may expose internal representation by returning VolumeArgs.acls  At VolumeArgs.java:[line 107]
M V EI: org.apache.hadoop.ozone.client.VolumeArgs.getMetadata() may expose internal representation by returning VolumeArgs.metadata  At VolumeArgs.java:[line 103]
M V EI2: org.apache.hadoop.ozone.client.VolumeArgs$Builder.setAcls(List) may expose internal representation by storing an externally mutable object into VolumeArgs$Builder.listOfAcls  At VolumeArgs.java:[line 165]

Findbugs complains about get... method even if the corresponding field is initialized using Collections.unmodifiable.... Two possible ways to solve the problem:

  1. wrap in unmodifiable... in get... method
  2. use Immutable... collection (from Guava) and declare the field as such

This patch uses the second approach.

https://issues.apache.org/jira/browse/HDDS-10322

How was this patch tested?

$ hadoop-ozone/dev-support/checks/findbugs.sh -Dspotbugs.version=4.8.3.0
$ grep -c 'client.VolumeArgs' target/findbugs/summary.txt
0

CI:
https://github.com/adoroszlai/ozone/actions/runs/7820568596

@adoroszlai adoroszlai added the code-cleanup Changes that aim to make code better, without changing functionality. label Feb 7, 2024
@adoroszlai adoroszlai self-assigned this Feb 7, 2024
@adoroszlai adoroszlai requested a review from smengcl February 8, 2024 05:10
@Galsza
Copy link
Contributor

Galsza commented Feb 8, 2024

Thank you Attila for the change, looking good to me

Copy link
Contributor

@smengcl smengcl left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks @adoroszlai

@adoroszlai adoroszlai merged commit 601fd41 into apache:master Feb 8, 2024
@adoroszlai adoroszlai deleted the HDDS-10322 branch February 8, 2024 21:57
@adoroszlai
Copy link
Contributor Author

Thanks @Galsza, @smengcl for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-cleanup Changes that aim to make code better, without changing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants