Skip to content

[type: bug] Fix Cryptor/Sign plugin removeRule to unconditionally cleanup (#6879) - #7009

Merged
Aias00 merged 3 commits into
apache:masterfrom
zhang-arvin:fix/6879-remove-rule
Sep 3, 2026
Merged

Aias00 merged 3 commits into
apache:masterfrom
zhang-arvin:fix/6879-remove-rule

Conversation

@zhang-arvin

Copy link
Copy Markdown
Contributor

Closes #6879

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Fix Cryptor/Sign plugin removeRule to unconditionally remove cache (#6879)

Verdict: APPROVE

Analysis

Both AbstractCryptorPluginDataHandler.removeRule and SignPluginDataHandler.removeRule previously guarded the cache removal with Optional.ofNullable(ruleData.getHandle()):

Optional.ofNullable(ruleData.getHandle()).ifPresent(s -> CACHED_HANDLE.get().removeHandle(CacheKeyUtils.INST.getKey(ruleData)));

When getHandle() was null (e.g. the rule's handle was cleared or never set), the cache entry was never removed, leaving a stale CryptorRuleHandler/SignRuleHandler in CACHED_HANDLE even after the rule was deleted.

The fix removes the guard so removal always happens:

CACHED_HANDLE.get().removeHandle(CacheKeyUtils.INST.getKey(ruleData));

No NPE / safe-removal verification:

  • CacheKeyUtils.getKey(RuleData) builds the key as String.join("_", ruleData.getSelectorId(), ruleData.getId()) — it does not read getHandle(), so a null handle cannot cause an NPE here.
  • CommonHandleCache.removeHandle is Optional.ofNullable(key).ifPresent(cached::remove) — a no-op when the key is absent, so repeated/always-on removal is idempotent and safe.

Behavior change is exactly the intended one: a deleted rule now reliably clears its cached handler regardless of whether its handle payload is currently populated.

Conclusion

Correct, minimal, and safe. The cache key derivation is independent of handle, and removal is idempotent. Approving.

@Aias00
Aias00 merged commit b97d4b1 into apache:master Sep 3, 2026
47 of 53 checks passed
eye-gu pushed a commit to eye-gu/shenyu that referenced this pull request Sep 30, 2026
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Cryptor JsonUtil.parser throws NPE/CCE on JSON-array or non-object bodies and missing nested-field segments — 500s on valid and pre-auth traffic

2 participants