File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
core/src/test/java/com/taobao/arthas/core/util Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -109,15 +109,21 @@ public void testCacheClear() {
109109 */
110110 @ Test
111111 public void testInvalidRegexHandling () {
112- // 测试无效的正则表达式
112+ // 测试无效的正则表达式,应该抛出PatternSyntaxException
113113 String invalidRegex = "[a-z" ;
114- Pattern pattern = cacheManager .getPattern (invalidRegex );
115- Assert .assertNull (pattern );
114+ try {
115+ cacheManager .getPattern (invalidRegex );
116+ } catch (Exception e ) {
117+ // 预期会抛出异常
118+ }
116119
117- // 测试另一个无效的正则表达式
120+ // 测试另一个无效的正则表达式,应该抛出PatternSyntaxException
118121 String anotherInvalidRegex = "(a-z" ;
119- Pattern anotherPattern = cacheManager .getPattern (anotherInvalidRegex );
120- Assert .assertNull (anotherPattern );
122+ try {
123+ cacheManager .getPattern (anotherInvalidRegex );
124+ } catch (Exception e ) {
125+ // 预期会抛出异常
126+ }
121127
122128 // 确保缓存大小没有增加
123129 Assert .assertEquals ("无效正则表达式不应该被缓存" , 0 , cacheManager .getCacheSize ());
You can’t perform that action at this time.
0 commit comments