Skip to content

[BUG] AbstractNodeDataChangedListener.onSelectorChanged builds config-key prefix with raw getNamespaceId() (no SYS_DEFAULT fallback) — selectors invisible when namespaceId null #6876

Description

@Aias00

Description

Each plugin's doExecute calls CACHED_HANDLE.get().obtainHandle(key) and immediately dereferences the result without a null check. CommonHandleCache.obtainHandle(key) returns cached.get(key) which is null on cache miss. The cache miss occurs when a rule is created with a null/empty handle field — every data handler guards the cache write with Optional.ofNullable(ruleData.getHandle()).ifPresent(...), so a rule with no handle JSON is never cached but CAN still be matched by AbstractShenyuPlugin.execute (matching is condition-based, not handle-based).

Location

  • shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-hystrix/src/main/java/org/apache/shenyu/plugin/hystrix/HystrixPlugin.java:59-60
  • shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/main/java/org/apache/shenyu/plugin/resilience4j/Resilience4JPlugin.java:66-67
  • shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-sentinel/src/main/java/org/apache/shenyu/plugin/sentinel/SentinelPlugin.java:59-60
  • shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/main/java/org/apache/shenyu/plugin/ratelimiter/RateLimiterPlugin.java:72-74
  • shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/CommonHandleCache.java:42-44

Impact

Every request matching a rule that was created without a handle (or whose handle was cleared) receives an unhandled NullPointerException / 500. A single misconfigured rule takes down all traffic matching it.

Suggested fix

Add a null guard at the top of each doExecute, e.g. if (Objects.isNull(handle)) { return chain.execute(exchange); }, mirroring the guard added in ContextPathPlugin and MockPlugin (line 52-54).

Related existing

Distinct from #6657 (GeneralContextPlugin NPE) — that issue was filed only for GeneralContextPlugin.java:54. These are four separate plugins with separate caches and separate doExecute implementations, all of which lack the guard that #6657 added for GeneralContextPlugin only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions