Skip to content

Commit 6632d5e

Browse files
ywwanaywwana
andauthored
[fix] fix data sync bug (#6165)
* [fix] Modify the test data of the sample test MotanPluginTest * [fix] Resolve CommonPluginDataSubscriber class conflict --------- Co-authored-by: ywwana <[email protected]>
1 parent 21d6634 commit 6632d5e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/CommonPluginDataSubscriber.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.shenyu.common.enums.PluginHandlerEventEnum;
2828
import org.apache.shenyu.common.enums.TrieCacheTypeEnum;
2929
import org.apache.shenyu.common.enums.TrieEventEnum;
30+
import org.apache.shenyu.common.utils.JsonUtils;
3031
import org.apache.shenyu.common.utils.MapUtils;
3132
import org.apache.shenyu.plugin.api.utils.SpringBeanUtils;
3233
import org.apache.shenyu.plugin.base.event.TrieEvent;
@@ -195,12 +196,16 @@ public void refreshRuleDataSelf(final List<RuleData> ruleDataList) {
195196
}
196197

197198
private <T> void subscribeDataHandler(final T classData, final DataEventTypeEnum dataType) {
198-
if (dataType == DataEventTypeEnum.UPDATE) {
199-
Optional.ofNullable(classData)
200-
.ifPresent(data -> updateCacheData(classData));
201-
} else if (dataType == DataEventTypeEnum.DELETE) {
202-
Optional.ofNullable(classData)
203-
.ifPresent(data -> removeCacheData(classData));
199+
try {
200+
if (dataType == DataEventTypeEnum.UPDATE) {
201+
Optional.ofNullable(classData)
202+
.ifPresent(data -> updateCacheData(classData));
203+
} else if (dataType == DataEventTypeEnum.DELETE) {
204+
Optional.ofNullable(classData)
205+
.ifPresent(data -> removeCacheData(classData));
206+
}
207+
} catch (Exception e) {
208+
LOG.error("subscribe data handler error, classData: {}, dataType: {}", JsonUtils.toJson(classData), dataType, e);
204209
}
205210
}
206211

0 commit comments

Comments
 (0)