Sean-Walker0 commented on PR #7364:
URL: https://github.com/apache/shenyu/pull/7364#issuecomment-5904250546

   Went with **option 2** — the selector-id fallback is folded into this PR now 
(commit `ec1c36f`), since it is the part that actually keeps the bootstrap 
caches consistent.
   
   **What the data plane does on a blank plugin name** (null or empty, 
`StringUtils#isBlank`):
   
   - `BaseDataCache#removeSelectData` — instead of 
`selectorMap.computeIfPresent(null, …)` (NPE on the concurrent map), it sweeps 
every plugin bucket and drops entries whose id matches, via `computeIfPresent` 
per key so the immutable `List.copyOf` buckets are still replaced wholesale.
   - `MatchDataCache#removeSelectorData(name, id)` / 
`#removeRuleDataBySelector(name, id)` — same bucket sweep by selector id; 
`#removeRuleData(name, ruleId)` gets the matching sweep by rule id (the rule 
branch has the identical exposure because `RuleEventPublisher.onDeleted` 
already publishes null-name deletes null-safely).
   - `#removeEmptySelectorData` / `#removeEmptyRuleData` — become no-ops: the 
null-id placeholders belong to real plugins' buckets and a blank-name delete 
must not touch them.
   - `CommonPluginDataSubscriber#removeCacheData` — skips the `handlerMap` 
lookup rather than calling `get(null)` (also an NPE on the concurrent map), so 
the deletion now runs to completion instead of being aborted mid-way.
   
   **Why the sweep targets the historical name's bucket correctly:** a 
null-name selector can never have been *cached* 
(`selectorAccept`/`cacheSelectorData` would have thrown on the null key), so 
its stale entry necessarily sits under the plugin name it had while the plugin 
row still existed — exactly what the per-bucket sweep removes.
   
   **Regression coverage** (all five fail on the previous commit — two 
assertion failures and three NPEs — and pass with the fix):
   
   - 
`CommonPluginDataSubscriberTest#testUnSelectorSubscribeWithMissingPluginName` — 
the requested proof: caches a selector under its real plugin name, publishes a 
blank-name delete, asserts `BaseDataCache` and both `MatchDataCache` maps are 
purged while an unrelated plugin keeps its entries.
   - `#testUnRuleSubscribeWithMissingPluginName` — same shape for the rule path 
(match-cache purge was the pre-fix observable failure).
   - Per-cache sweeps in `BaseDataCacheTest` and `MatchDataCacheTest`.
   
   Full `shenyu-plugin-base` suite (137 tests) + checkstyle green. The textual 
overlap with #7345/#6336/#7319/#7088 is unchanged and will be resolved by 
whichever lands first.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to