Repository navigation
fix(rewrite): look up rewrite metadata with an empty prefix when context-path is absent (#7796) - #7798
Merged
Conversation
…ext-path is absent (apache#7796)
Aias00
approved these changes
Oct 18, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Approved.
Good fix. When neither the rewrite nor the global context-path attribute is set, the previous code concatenated a null attribute and produced the literal "null" lookup key, so metadata was never found. Wrapping with StringUtils.defaultString converts the absent path to an empty prefix, and the new shouldLookUpMetaDataWithoutContextPath test asserts the bare rewritten path resolves the metadata.
CI is green on this branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7796.
Summary
When the context-path plugin has not run, both the
REWRITE_CONTEXT_PATHand fallbackCONTEXT_PATHexchange attributes are null, soRewritePluginbuilds its metadata lookup key as the literal string"null" + rewriteUri. A rewrite rule withrewriteMetaData=truetherefore never finds metadata cached under the plain rewritten path.Modifications
rewriteMetaData=true, metadata cached under the bare rewritten path — the resolved rpc type must come from the metadata.Verifying this change
New
RewritePluginTest#shouldLookUpMetaDataWithoutContextPath: fails on the current code (lookup misses, rpc type falls back to http) and passes with the fix.Targeted tests pass:
./mvnw -B -ntp -pl shenyu-plugin/shenyu-plugin-rewrite test -Dtest=RewritePluginTest8/8 green.
Checkstyle passes:
clean.
Notes
When a context path IS present the concatenated key is unchanged, so existing dubbo/other-rpc metadata lookups behave identically. No cache structure changes — only the key construction is made null-safe.