fix(plugin-base): short-circuit cached selector and rule matches#6313
Closed
Aias00 wants to merge 4 commits intoapache:masterfrom
Closed
fix(plugin-base): short-circuit cached selector and rule matches#6313Aias00 wants to merge 4 commits intoapache:masterfrom
Aias00 wants to merge 4 commits intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the shenyu-plugin-base execution path by actually reusing selector/rule match results from MatchDataCache on cache hits (instead of re-running the default matching logic), and adds unit tests to cover the new short-circuit paths.
Changes:
- Short-circuit selector matching when a non-empty cached selector hit is present.
- Short-circuit rule matching when a non-empty cached rule hit is present (while preserving the existing empty-sentinel behavior).
- Add unit tests for selector/rule cache-hit short-circuit paths; update
.gitignoreto ignore local worktrees.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/AbstractShenyuPlugin.java |
Reuses cached selector/rule matches to avoid re-running default matching on cache hits. |
shenyu-plugin/shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java |
Adds coverage for selector/rule cache-hit short-circuit behavior. |
.gitignore |
Ignores .worktrees/ directory used for local worktrees. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java
Show resolved
Hide resolved
...shenyu-plugin-base/src/test/java/org/apache/shenyu/plugin/base/AbstractShenyuPluginTest.java
Show resolved
Hide resolved
moremind
requested changes
Apr 2, 2026
| if (Objects.isNull(selectorData)) { | ||
| return handleSelectorIfNull(pluginName, exchange, chain); | ||
| if (Objects.nonNull(selectorData)) { | ||
| if (StringUtils.isBlank(selectorData.getId())) { |
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.
Summary
AbstractShenyuPlugininstead of re-running default selector matching on a cache hitAbstractShenyuPluginTestcoverage for selector-cache-hit and rule-cache-hit short-circuit pathsTest Plan
./mvnw -q -pl shenyu-plugin/shenyu-plugin-base -am -Dtest=AbstractShenyuPluginTest -DfailIfNoTests=false -DskipITs -Drat.skip=true -Djacoco.skip=true -Dcheckstyle.skip=true -Dspotbugs.skip=true test