Skip to content

Align ReflectionDiffBuilder with AbstractReflection and add cycle detection - #1778

Merged
garydgregory merged 1 commit into
apache:masterfrom
Alwaysgaurav1:fix/reflection-diff-builder-cycle-guard
Aug 23, 2026
Merged

Align ReflectionDiffBuilder with AbstractReflection and add cycle detection#1778
garydgregory merged 1 commit into
apache:masterfrom
Alwaysgaurav1:fix/reflection-diff-builder-cycle-guard

Conversation

@Alwaysgaurav1

Copy link
Copy Markdown
Contributor

Summary

  • Align ReflectionDiffBuilder with AbstractReflection:

    • ReflectionDiffBuilder<T> now extends AbstractReflection for consistency with EqualsBuilder, HashCodeBuilder, CompareToBuilder, and ToStringBuilder.
    • ReflectionDiffBuilder.Builder<T> extends AbstractReflection.AbstractBuilder<Builder<T>> and implements Supplier<ReflectionDiffBuilder<T>> via get(), inheriting setForceAccessible(boolean).
    • Replaces custom readField with AbstractReflection.setAccessible(field) and Reflection.getUnchecked(field, target) with runtime module safety.
  • Cycle Detection & StackOverflow Protection:

    • Introduces a thread-local cycle registry (REGISTRY) to track object pairs during reflection diffing.
    • Guards recursive traversal in ReflectionDiffBuilder.build() and DiffBuilder constructor to avoid StackOverflowError on self-referential or mutually-referential object graphs.
  • Tests & Changes:

    • Added unit test cases in ReflectionDiffBuilderTest covering self-referential cycles, mutually-referential cycles, asymmetric cycles, and builder configuration.
    • Added release note entry in src/changes/changes.xml.

@garydgregory
garydgregory merged commit d1e60e0 into apache:master Aug 23, 2026
23 of 24 checks passed
garydgregory added a commit that referenced this pull request Aug 23, 2026
detection (#1778).

- Fix action order.
- Sort members.
garydgregory added a commit that referenced this pull request Aug 23, 2026
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