Repository navigation
Description
Is there an existing issue for this?
- I searched open and closed issues.
Current Behavior
A matched Cache rule with a null handle can enter the gateway rule cache, then turn a successful downstream response into a NullPointerException when the response body is written.
CachePluginDataHandler.handlerRule() skips a null ruleData.handle. CachePlugin.buildRuleHandle() then returns null from the rule-handle cache, but CacheHttpResponse.cacheResponse() unconditionally calls cacheRuleHandle.getTimeoutSeconds().
Expected Behavior
A rule accepted by the configuration/sync path should not crash successful responses. Either initialize documented default Cache settings or explicitly skip caching when no usable handle exists. If a handle is mandatory, reject that configuration consistently before publishing it.
Steps To Reproduce
- Enable the Cache plugin using the memory backend.
- Synchronize an enabled selector and a matching Cache rule with
handle=nullthrough the realCommonPluginDataSubscriber. - Execute
CachePlugin.execute()with a downstream chain that writes a plain-text response body. - Observe an NPE at
CachePlugin.java:146.
An offline harness executed the actual subscriber, handler, matching plugin and decorated response. The same setup with handle={"timeoutSeconds":60} completed successfully:
cachedHandle[valid]=CacheRuleHandle
validHandle=completed
cachedHandle[null]=null
nullHandle=java.lang.NullPointerException: Cannot invoke CacheRuleHandle.getTimeoutSeconds() because this.cacheRuleHandle is null
Reachability And Location
- RuleDTO.java:86: the handle field has no non-null validation constraint.
- RuleServiceImpl.java:418: special handle validation applies only to agentGateway, not Cache.
- CommonPluginDataSubscriber.java:253: accepts the rule into the gateway cache.
- CachePluginDataHandler.java:113: null handles do not populate the specific handle cache.
- CachePlugin.java:107: lookup has no default.
- CachePlugin.java:146: null dereference during response caching.
Impact
Severity: Medium. Confidence: high. Coverage: confirmed by an actual offline plugin execution.
Requests matching an accepted Cache rule without a handle fail during response processing instead of returning the otherwise successful downstream body. This requires absent/uncached rule settings; normal populated settings are the successful control case.
Suggested Fix And Regression Tests
Choose an explicit missing-handle policy: supply CacheRuleHandle.newInstance() defaults, skip caching, or reject invalid Cache rules at the configuration boundary. Verify missing, default and explicit timeout handles through real rule subscription plus CachePlugin.execute() and response writing.
Validation And Related Issues
Reviewed master at 67596c1d228b62da75cd0a0ecb47d0ac5d995384 (2.7.2-SNAPSHOT). Independent review and leader reproduction both confirmed the crash. Existing CachePluginTest: 5 tests passed, but lack this case.
#6877 covered similar absent-handle failures in Hystrix/Resilience4J/Sentinel/RateLimiter. #6772 covered stale handle removal in other handlers. #6505/#6506 cover Cache response restoration/key semantics. This report is the current Cache response-write null-handle path.
No live Admin/dashboard/gateway E2E environment was started. The DTO/service/schema acceptance path was inspected; the offline runtime harness starts at the gateway subscriber.
Activity
github-actions commentedon Oct 7, 2026
👋 Hello @yuluo-yx
A new issue has been opened by @Aias00:
Please review when you have time. Thank you! 🙏
Emryswu commentedon Oct 11, 2026
Hi, I'd like to work on this issue. I plan to skip caching when the cache rule handle is null. Could you assign it to me?
Aias00 commentedon Oct 11, 2026
just comment /assign
Emryswu commentedon Oct 11, 2026
C:/Program Files/Git/assign
Emryswu commentedon Oct 11, 2026
/assign
[ISSUE apache#7452] skip caching when cache rule handle is null (apac…