This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 3e2b1a747 [ISSUE #4071] fix ConcurrentModificationException (#4155)
3e2b1a747 is described below
commit 3e2b1a747565f395267abcaa755db24bf8e7bff7
Author: moremind <[email protected]>
AuthorDate: Thu Nov 3 08:43:05 2022 +0800
[ISSUE #4071] fix ConcurrentModificationException (#4155)
---
.../java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java
index f661e39f0..df379b486 100644
---
a/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java
+++
b/shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java
@@ -133,7 +133,9 @@ public final class BaseDataCache {
public void removeSelectData(final SelectorData selectorData) {
Optional.ofNullable(selectorData).ifPresent(data -> {
final List<SelectorData> selectorDataList =
SELECTOR_MAP.get(data.getPluginName());
- Optional.ofNullable(selectorDataList).ifPresent(list ->
list.removeIf(e -> e.getId().equals(data.getId())));
+ synchronized (SELECTOR_MAP) {
+ Optional.ofNullable(selectorDataList).ifPresent(list ->
list.removeIf(e -> e.getId().equals(data.getId())));
+ }
});
}
@@ -189,7 +191,9 @@ public final class BaseDataCache {
public void removeRuleData(final RuleData ruleData) {
Optional.ofNullable(ruleData).ifPresent(data -> {
final List<RuleData> ruleDataList =
RULE_MAP.get(data.getSelectorId());
- Optional.ofNullable(ruleDataList).ifPresent(list ->
list.removeIf(rule -> rule.getId().equals(data.getId())));
+ synchronized (RULE_MAP) {
+ Optional.ofNullable(ruleDataList).ifPresent(list ->
list.removeIf(rule -> rule.getId().equals(data.getId())));
+ }
});
}