Repository navigation
[type: bug] Fix Cryptor/Sign plugin removeRule to unconditionally cleanup (#6879) - #7009
Conversation
…anup (apache#6879) Signed-off-by: zhang-arvin <[email protected]>
Aias00
left a comment
There was a problem hiding this comment.
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 asString.join("_", ruleData.getSelectorId(), ruleData.getId())— it does not readgetHandle(), so a null handle cannot cause an NPE here.CommonHandleCache.removeHandleisOptional.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.
…anup (apache#6879) (apache#7009) Signed-off-by: zhang-arvin <[email protected]> Co-authored-by: aias00 <[email protected]>
Closes #6879