瀏覽代碼

Add catch throwable logic in ClusterStateManager to detect fatal error when loading SPI

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 年之前
父節點
當前提交
8e72211db9
共有 1 個檔案被更改,包括 16 行新增11 行删除
  1. +16
    -11
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterStateManager.java

+ 16
- 11
sentinel-core/src/main/java/com/alibaba/csp/sentinel/cluster/ClusterStateManager.java 查看文件

@@ -224,17 +224,22 @@ public final class ClusterStateManager {
if (state == mode) {
return true;
}
switch (state) {
case CLUSTER_CLIENT:
return setToClient();
case CLUSTER_SERVER:
return setToServer();
case CLUSTER_NOT_STARTED:
setStop();
return true;
default:
RecordLog.warn("[ClusterStateManager] Ignoring unknown cluster state: " + state);
return false;
try {
switch (state) {
case CLUSTER_CLIENT:
return setToClient();
case CLUSTER_SERVER:
return setToServer();
case CLUSTER_NOT_STARTED:
setStop();
return true;
default:
RecordLog.warn("[ClusterStateManager] Ignoring unknown cluster state: " + state);
return false;
}
} catch (Throwable t) {
RecordLog.warn("[ClusterStateManager] Fatal error when applying state: " + state, t);
return false;
}
}



Loading…
取消
儲存