File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
main/java/com/taobao/arthas/core/util
test/java/com/taobao/arthas/core/util Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ public static RegexCacheManager getInstance() {
2929 * 获取正则表达式Pattern对象,优先从缓存获取,缓存未命中则编译并缓存
3030 */
3131 public Pattern getPattern (String regex ) {
32- if (regex == null || regex . isEmpty () ) {
32+ if (regex == null ) {
3333 return null ;
3434 }
3535
Original file line number Diff line number Diff line change @@ -49,7 +49,10 @@ public void testBasicCacheFunctionality() {
4949 Assert .assertNull (nullPattern );
5050
5151 Pattern emptyPattern = cacheManager .getPattern ("" );
52- Assert .assertNull (emptyPattern );
52+ Assert .assertNotNull (emptyPattern );
53+ Assert .assertTrue (emptyPattern .matcher ("" ).matches ());
54+ Assert .assertFalse (emptyPattern .matcher ("non-empty" ).matches ());
55+ Assert .assertEquals (3 , cacheManager .getCacheSize ());
5356 }
5457
5558 /**
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ public void testMatchingWithNullInputs(){
1616 Assert .assertTrue (new RegexMatcher ("foobar" ).matching ("foobar" ));
1717 }
1818
19+ @ Test
20+ public void testMatchingWithEmptyPattern () {
21+ Assert .assertTrue (new RegexMatcher ("" ).matching ("" ));
22+ Assert .assertFalse (new RegexMatcher ("" ).matching ("foobar" ));
23+ }
24+
1925 /**
2026 * test regux with . | * + ? \s \S \w \W and so on...
2127 */
You can’t perform that action at this time.
0 commit comments