Skip to content

Commit 510071a

Browse files
committed
fix:去除RegexCacheManager同步冗余
1 parent 3aa2058 commit 510071a

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

core/src/main/java/com/taobao/arthas/core/util/RegexCacheManager.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,11 @@ public Pattern getPattern(String regex) {
3939
return pattern;
4040
}
4141

42-
// 使用双重检查锁,避免并发情况下重复编译相同的正则
43-
synchronized (regexCache) {
44-
pattern = regexCache.get(regex);
45-
if (pattern == null) {
46-
// 缓存未命中,编译正则表达式
47-
// 不捕获PatternSyntaxException,让异常向上抛出,以便及时发现无效的正则表达式
48-
pattern = Pattern.compile(regex);
49-
// 缓存编译结果
50-
regexCache.put(regex, pattern);
51-
}
52-
}
42+
// 缓存未命中,编译正则表达式
43+
// 不捕获PatternSyntaxException,让异常向上抛出,以便及时发现无效的正则表达式
44+
pattern = Pattern.compile(regex);
45+
// 缓存编译结果
46+
regexCache.put(regex, pattern);
5347

5448
return pattern;
5549
}

0 commit comments

Comments
 (0)