浏览代码

Fix the bug of misplaced locks in ContextUtil and ClusterNode (#1429)

- which may lead to IllegalMonitorStateException in unlock() when unchecked error occurs during lock()
master
haifeng GitHub 4 年前
父节点
当前提交
04a1d065dd
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/ContextUtil.java
  2. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/ClusterNode.java

+ 1
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/ContextUtil.java 查看文件

@@ -127,8 +127,8 @@ public class ContextUtil {
setNullContext(); setNullContext();
return NULL_CONTEXT; return NULL_CONTEXT;
} else { } else {
LOCK.lock();
try { try {
LOCK.lock();
node = contextNameNodeMap.get(name); node = contextNameNodeMap.get(name);
if (node == null) { if (node == null) {
if (contextNameNodeMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) { if (contextNameNodeMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {


+ 1
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/ClusterNode.java 查看文件

@@ -101,8 +101,8 @@ public class ClusterNode extends StatisticNode {
public Node getOrCreateOriginNode(String origin) { public Node getOrCreateOriginNode(String origin) {
StatisticNode statisticNode = originCountMap.get(origin); StatisticNode statisticNode = originCountMap.get(origin);
if (statisticNode == null) { if (statisticNode == null) {
lock.lock();
try { try {
lock.lock();
statisticNode = originCountMap.get(origin); statisticNode = originCountMap.get(origin);
if (statisticNode == null) { if (statisticNode == null) {
// The node is absent, create a new node for the origin. // The node is absent, create a new node for the origin.


正在加载...
取消
保存