Skip to content

Fix fluent methods on cloned builders#3449

Open
hutiefang76 wants to merge 1 commit into
OpenFeign:masterfrom
hutiefang76:codex/openfeign-2782-builder-clone
Open

Fix fluent methods on cloned builders#3449
hutiefang76 wants to merge 1 commit into
OpenFeign:masterfrom
hutiefang76:codex/openfeign-2782-builder-clone

Conversation

@hutiefang76

Copy link
Copy Markdown

Fixes #2782.

BaseBuilder cached this in a final thisB field. When a builder is cloned, that final field is copied as-is, so fluent methods invoked on the clone still return the original builder instance. This can make chained configuration on cloned builders silently continue on the wrong object.

This keeps the existing self-type helper pattern but makes it resolve this dynamically through one private helper method instead of storing it in a clone-stale field. That avoids the broader refactor from #2783 and keeps the unchecked cast centralized.

Validation:

mvn -pl core -Dtoolchain.skip=true -Dtest=BaseBuilderTest#clonedBuilderFluentMethodsReturnClone test
mvn -pl core -Dtoolchain.skip=true -Dtest=BaseBuilderTest test
git diff --check
mvn -pl core -Dtoolchain.skip=true test

The full core test run passed 635 tests with 0 failures/errors and 3 skipped tests.

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.

BaseBuilder not cloned properly

1 participant