simelyWWei opened a new issue, #4237:
URL: https://github.com/apache/shenyu/issues/4237

   ### Is there an existing issue for this?
   
   - [X] I have searched the existing issues
   
   ### Current Behavior
   
   When i delete a rule which belong to a selector,the local cache in a 
currentMap(BaseDataCache#RULE_MAP) will not be removed. This may affect the 
matching of rules when use the same condition as the deleted rules, it will 
chose the wrong config. And it also consume memory. And i found when update the 
rule at NacosCacheHandler#updatePluginMap or in other handler, it will only 
unSubscribe and onSubscribe the current rules, the deleted rules will not be 
handled. 
   `protected void updateRuleMap(final String configInfo) {
           try {
               List<RuleData> ruleDataList = 
GsonUtils.getInstance().toObjectMapList(configInfo, RuleData.class).values()
                       .stream().flatMap(Collection::stream)
                       .collect(Collectors.toList());
               ruleDataList.forEach(ruleData -> 
Optional.ofNullable(pluginDataSubscriber).ifPresent(subscriber -> {
                   subscriber.unRuleSubscribe(ruleData);
                   subscriber.onRuleSubscribe(ruleData);
               }));
           } catch (JsonParseException e) {
               LOG.error("sync rule data have error:", e);
           }
       }`
   
   ### Expected Behavior
   
   the local cache will be removed when delete the rule.
   
   ### Steps To Reproduce
   
   1. create a new selector and add two rule in divide plugin.
   <img width="1656" alt="image" 
src="https://user-images.githubusercontent.com/45253632/205579352-432b4188-12bb-43a3-8755-4ff0d5ae1657.png";>
   2. do invoke and debug at AbstractShenyuPlugin.
   <img width="1640" alt="image" 
src="https://user-images.githubusercontent.com/45253632/205580127-7755b1b7-2380-4bfc-aff1-25c3aa7b0c71.png";>
   Now, there are two cache records for this selector
   3. delete one rule.
   <img width="1438" alt="image" 
src="https://user-images.githubusercontent.com/45253632/205580350-99cc6f96-7763-4517-8038-9e3dcae98a74.png";>
   4. do invoke and debug again.
   <img width="1641" alt="image" 
src="https://user-images.githubusercontent.com/45253632/205580526-0b828717-1408-47e5-a410-be158eb41a14.png";>
   The cache of the rule named intfc2 has not be removed.
   
   ### Environment
   
   ```markdown
   ShenYu version(s):2.5.0,master
   ```
   
   
   ### Debug logs
   
   _No response_
   
   ### Anything else?
   
   _No response_


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