Skip to content

Fix URI fragment replacement and preserve target escapes - #3633

Merged
velo merged 3 commits into
OpenFeign:masterfrom
hutiefang76:frank/thirty-feign-next-20261019
Nov 9, 2026
Merged

velo merged 3 commits into
OpenFeign:masterfrom
hutiefang76:frank/thirty-feign-next-20261019

Conversation

@hutiefang76

Copy link
Copy Markdown
Contributor

Fixes #3095.

Replacing /old#stale with /new?q=v retained #stale, with no API to clear it completely. A target such as https://example.com/a#encoded%20value%2F also lost its percent escapes because the decoded fragment was appended to the URL.

This clears the old fragment on URI replacement and preserves raw target fragments. Append behavior, explicit empty fragments, copying, and normal template resolution retain their existing behavior. The internal resolve path carries the separately stored fragment forward. No public setter or dependency is added.

Nine tests cover both failures and those controls; the changelog records the replacement semantics for 13.18.

Validation on macOS ARM64, using a fixed JDK 8 toolchain for main sources and an actual Temurin JDK 25.0.4.1 toolchain for test compilation/execution:

  • Original code plus the regressions: 58 RequestTemplate tests, 3 failures, 0 errors/skips.
  • ./mvnw -Pdev -pl core clean verify: 781 tests, 0 failures/errors, 4 existing conditional skips. All 58 RequestTemplate tests pass.
  • Root ./mvnw -Pdev validate: passes with the required JDK 8/11/25 toolchains.

Checks ran in an independent checkout of the same base because the license plugin's JGit failed on a Git worktree. License and formatter checks remained enabled; all three tested file hashes match the submitted files. Local toolchain configuration is not part of the patch.

AI assistance: DeepSeek assisted implementation and first-pass review; Codex coordinated reproduction, actual validation, and final diff review.

A replacement URI should not retain a fragment from the previous URI.
Keep the fragment during template resolution and preserve percent escapes
in target fragments so they remain valid URL text.

Fixes OpenFeign#3095

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked against master: clearing the fragment on non-append uri() is offset by resolve() restoring it, contracts that call uri() without append are unaffected, and getRawFragment() keeps the target's escapes. The new tests fail on master and pass here. Nits, not blocking: in resolve() the null check is always true right after uri(), so plain resolved.fragment = this.fragment would do; and the comment in explicitlyEmptyFragmentShouldReplacePreviousFragment says a bare '#' drops the fragment, but the test asserts that it is kept as empty.

@velo
velo enabled auto-merge (squash) November 9, 2026 20:35
@velo

velo commented Nov 9, 2026

Copy link
Copy Markdown
Member

Approved, and auto-merge is enabled. It now conflicts with master, but only in CHANGELOG.md, because master already has a ### Version 13.18 section. Could you merge or rebase master and move your entry under that existing heading? It will merge once CI is green.

velo added 2 commits November 9, 2026 17:56
Signed-off-by: Marvin Froeder <[email protected]>

# Conflicts:
#	CHANGELOG.md
@velo

velo commented Nov 9, 2026

Copy link
Copy Markdown
Member

Merged master; CHANGELOG.md was removed from the repo so the entry was dropped. Also applied the review nits: plain assignment for the fragment in resolve() and a test comment that matches the assertion.

@velo
velo merged commit da84f43 into OpenFeign:master Nov 9, 2026
3 checks passed
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.

How to clear fragment of RequestTemplate (Feign client 11.10)?

2 participants