Skip to content

HDDS-14934. Enable BigIntegerInstantiation, ConsecutiveAppendsShouldReuse rule in PMD#10008

Draft
ptlrs wants to merge 2 commits intoapache:masterfrom
ptlrs:HDDS-14934-ConsecutiveAppendsShouldReuse
Draft

HDDS-14934. Enable BigIntegerInstantiation, ConsecutiveAppendsShouldReuse rule in PMD#10008
ptlrs wants to merge 2 commits intoapache:masterfrom
ptlrs:HDDS-14934-ConsecutiveAppendsShouldReuse

Conversation

@ptlrs
Copy link
Copy Markdown
Contributor

@ptlrs ptlrs commented Mar 30, 2026

What changes were proposed in this pull request?

This PR enables new PMD rules:

  1. BigIntegerInstantiation Don’t create instances of already existing BigInteger and BigDecimal
  2. ConsecutiveAppendsShouldReuse Consecutive calls to StringBuffer/StringBuilder .append should be chained, reusing the target object. This can improve the performance by producing a smaller bytecode, reducing overhead and improving inlining

What is the link to the Apache JIRA

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

How was this patch tested?

CI: https://github.com/ptlrs/ozone/actions/runs/23761982025

@ptlrs ptlrs changed the title HDDS-14934. Enable ConsecutiveAppendsShouldReuse rule in PMD HDDS-14934. Enable BigIntegerInstantiation, ConsecutiveAppendsShouldReuse rule in PMD Mar 30, 2026
@adoroszlai adoroszlai added the code-cleanup Changes that aim to make code better, without changing functionality. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@Gargi-jais11 Gargi-jais11 left a comment

Choose a reason for hiding this comment

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

Thanks @ptlrs for the patch.
After you raised the PR there are many places which needs changes for .append chaining in DiskBalancerReportSubcommand. Please update this as well.
Rest LGTM.

Copy link
Copy Markdown
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @ptlrs for the patch. I would like to suggest splitting the change for BigIntegerInstantiation into a separate task. While there is only one exact violation, some other BigInteger creation can also be improved. Created HDDS-14955 for that.

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