konlue opened a new pull request, #7925:
URL: https://github.com/apache/shenyu/pull/7925

   Fixes #7914.
   
   ## Summary
   
   Admin accepts a rule update whose `handle` is an explicit empty string, and 
Gson parses that input to `null`. The fault-tolerance handlers then diverge: 
`Resilience4J` removes the registry but leaves the previous cached handle in 
place (the next request NPEs in `Resilience4JBuilder` re-parsing the blank raw 
handle), `RateLimiter` keeps the previous handle enforcing in `CACHED_HANDLE`, 
and `Sentinel` NPEs in `handlerRule` before updating anything.
   
   ## Modifications
   
   - Follow the idiom already merged for the 
Request/Rewrite/ModifyResponse/ParamMapping handlers in #7794: a blank (empty 
or whitespace) handle explicitly clears the rule, while a `null` handle 
(omitted field of a selective update) keeps its existing semantics.
     - `Resilience4JHandler` / `RateLimiterPluginDataHandler`: evict the cached 
handle; both plugins already pass through when the cached handle is absent, so 
the stale enforcement and the `Resilience4JBuilder` NPE are both gone.
     - `SentinelRuleHandle`: delegate to `removeRule`, which evicts the cached 
handle and strips the rule's flow/degrade entries from the Sentinel rule 
managers; the parse / `checkData` / reload path only runs for non-blank handles.
   - No runtime code changes: with the cache evicted, every cleared rule 
degrades to the same behavior as a rule without a handle.
   
   ## Verifying this change
   
   - [x] Each handler test: valid handle cached → `handlerRule("")` evicts it 
(fails on the previous code with the issue's stale handle / 
`NullPointerException`), whitespace also clears, and a subsequent valid update 
re-caches; Sentinel additionally asserts the flow/degrade rules for the key are 
stripped.
   - [x] Regression green: `Resilience4JPluginTest` 3/3, 
`RateLimiterPluginTest` 4/4, `SentinelPluginTest` 5/5.
   - [x] Checkstyle passes:
   
     ```bash
     ./mvnw -pl <three modules> checkstyle:check
     ```
     clean.


-- 
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