apache / apache/shenyu

[BUG] GeneralContextPlugin NPE on null cached handle

Open Beginner friendly
#6,657 1 comment 0 reactions 0 assignees View on GitHub
plugin: generalContext priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: High
- files: `shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-general-context/src/main/java/org/apache/shenyu/plugin/general/context/GeneralContextPlugin.java:54`
- description: `doExecute` calls `obtainHandle(CacheKeyUtils.INST.getKey(rule))` and immediately dereferences `.isEmpty()` without a null check. `CommonHandleCache.obtainHandle` returns `null` on cache miss. Every other plugin in this set (ContextPathPlugin:55, RewritePlugin:68, etc.) guards with `Objects.isNull(handle)` before use; GeneralContextPlugin is the sole exception.
- impact: NullPointerException at runtime — request fails with 500 instead of passing through the chain.
- suggested_fix: Add `if (Objects.isNull(generalContextHandleMap) || generalContextHandleMap.isEmpty()) { return chain.execute(exchange); }` before line 54.
- confidence: High
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-general-context/src/main/java/org/apache/shenyu/plugin/general/context/GeneralContextPlugin.java at line 54, then compare the null handling in ContextPathPlugin:55 and RewritePlugin:68. Check CommonHandleCache.obtainHandle for its cache-miss behavior. Done means a null or empty handle no longer causes an NPE and the request passes through the chain.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.