Skip to content

HDDS-14955. Simplify BigInteger instantiation for improved efficiency.#10035

Draft
ptlrs wants to merge 1 commit intoapache:masterfrom
ptlrs:HDDS-14955-Improve-BigInteger-instantiation
Draft

HDDS-14955. Simplify BigInteger instantiation for improved efficiency.#10035
ptlrs wants to merge 1 commit intoapache:masterfrom
ptlrs:HDDS-14955-Improve-BigInteger-instantiation

Conversation

@ptlrs
Copy link
Copy Markdown
Contributor

@ptlrs ptlrs commented Apr 3, 2026

What changes were proposed in this pull request?

This PR:

  1. Enables BigIntegerInstantiation PMD rule to avoid creating instances of already existing BigInteger
  2. Avoids unnecessary boxing. Use BigInteger.valueOf(<String/primitive>) where possible
  3. Avoids eager instantiation

What is the link to the Apache JIRA

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

How was this patch tested?

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

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. There is one more occurrence with eager instantiation (as linked in the task description). The rest LGTM.

private synchronized void updateCachedSubCAId(String s) {
BigInteger candidateNewId = new BigInteger(s);
if (caCertId == null
|| new BigInteger(caCertId).compareTo(candidateNewId) < 0) {

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