Skip to content

[LANG-1452] RecursiveToStringStyle and MultilineRecursiveToStringStyle shouldn't recurse into a java.math.BigDecimal#1582

Closed
chhs2131 wants to merge 1 commit intoapache:masterfrom
chhs2131:LANG-1452
Closed

[LANG-1452] RecursiveToStringStyle and MultilineRecursiveToStringStyle shouldn't recurse into a java.math.BigDecimal#1582
chhs2131 wants to merge 1 commit intoapache:masterfrom
chhs2131:LANG-1452

Conversation

@chhs2131
Copy link
Copy Markdown

@chhs2131 chhs2131 commented Jan 25, 2026

Overview

Addresses LANG-1452 by excluding BigDecimal and BigInteger from recursive formatting in MultilineRecursiveToStringStyle to prevent exposing internal implementation fields.

Changes

  • Override accept(Class<?>) method to return false for BigDecimal and BigInteger
  • Update Javadoc to document the exclusion
  • Add testBigDecimalField() test case
  • Add testBigIntegerField() test case

Why

MultilineRecursiveToStringStyle was recursively formatting BigDecimal and BigInteger objects, exposing internal fields like intVal, scale, mag, and signum instead of their string values. This follows the intended design pattern of RecursiveToStringStyle, where subclasses can override accept() to filter specific classes from recursive processing.

…ng in MultilineRecursiveToStringStyle

Prevent exposing internal fields (intVal, scale, mag, signum) when formatting
BigDecimal and BigInteger objects. Override accept() method to exclude these
immutable value types from recursive formatting.

- Add BigInteger to exclusion list alongside BigDecimal
- Update Javadoc to document the exclusion
- Add testBigIntegerField() test case
@chhs2131 chhs2131 closed this Jan 25, 2026
@chhs2131 chhs2131 reopened this Jan 25, 2026
@chhs2131 chhs2131 changed the title [LANG-1452] Exclude BigDecimal and BigInteger from recursive formatti… [LANG-1452] RecursiveToStringStyle and MultilineRecursiveToStringStyle shouldn't recurse into a java.math.BigDecimal Jan 25, 2026
@garydgregory
Copy link
Copy Markdown
Member

Hello @chhs2131

Thank you for your PR but it's redundant with what I was already working on in #1584, which contains additional cases and tests.

@chhs2131
Copy link
Copy Markdown
Author

@garydgregory
Got it! We use this project regularly in our product development and really appreciate it. Thanks for all your hard work! 😊

@chhs2131 chhs2131 closed this Jan 25, 2026
@garydgregory
Copy link
Copy Markdown
Member

YW! 👋

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