yangjj-iso opened a new pull request, #7662:
URL: https://github.com/apache/shenyu/pull/7662
Fixes #6506.
The cache plugin reuses path/query-only entries across HTTP methods and
request bodies. For example, a second `POST /orders/quote` with a different SKU
receives the first POST's cached response. Decoding the query before hashing
also collapses distinct raw query strings.
Restrict response-cache reads and writes to GET requests with no body, as
permitted by the issue's request-shape restriction option. Non-GET requests and
requests advertising a body continue through the normal plugin chain. Other GET
requests inspect the first body signal: data bypasses caching and is replayed
to downstream without aggregation; an empty stream uses the cache; a body error
is propagated. Discard handling releases a peeked pooled buffer if downstream
completes, fails, or cancels without consuming it.
Version the cache key and include the method and complete raw URI,
preserving authority and raw query distinctions. Existing entries are not
reused. Add `docs/cache-request-eligibility.md` describing eligibility, normal
forwarding of unsupported requests, and the cold-cache transition. POST and
other non-GET routes now call upstream on every request. Response metadata
replay remains tracked separately by #6505.
Validation:
- On the original implementation, 13 of 14 focused cases fail, including the
two-POST reproduction, non-GET cache hits, GET bodies with
explicit/chunked/absent framing, and method/authority/raw-query key collisions.
- After the fix, all 37 selected cache tests pass with zero
failures/errors/skips, including 25 new cases, ordinary GET miss/hit behavior,
untouched downstream request bodies, no cache writes for unsupported methods,
body errors, and pooled-buffer cleanup on completion/error/cancellation.
- Checkstyle and Apache RAT pass across the affected reactor; `git diff
--check` passes.
- Full-repository install and a deployed gateway/Redis cluster were not run
locally.
```sh
./mvnw -B -ntp -pl
shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler -am test \
'-Dtest=CacheRequestEligibilityTest,CacheUtilsTest,CachePlugin*Test,ApplicationConfigCacheTest,MemoryCacheTest'
\
-Dsurefire.failIfNoSpecifiedTests=false -DskipRemoteResources=true \
-Djacoco.skip=true -Dmaven.javadoc.skip=true
./mvnw -B -ntp -pl
shenyu-plugin/shenyu-plugin-cache/shenyu-plugin-cache-handler -am
apache-rat:check -DskipRemoteResources=true
```
- [x] Read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide/).
- [x] Submit regression tests.
- [ ] Full local `./mvnw clean install -Dmaven.javadoc.skip=true`
(affected-reactor validation above).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]