Skip to content

Commit 0b85e4f

Browse files
committed
* Catch PatternSyntaxException instead of RuntimeException
1 parent 2f96656 commit 0b85e4f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilter.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.LinkedHashMap;
2121
import java.util.Map;
2222
import java.util.regex.Pattern;
23+
import java.util.regex.PatternSyntaxException;
2324

2425
/**
2526
* Utility class that can be used to filter source data using a name regular expression.
@@ -64,7 +65,8 @@ private Pattern getRegexPattern(String name) {
6465
if (name.contains(part)) {
6566
try {
6667
return Pattern.compile(name);
67-
} catch(RuntimeException re){
68+
}
69+
catch (PatternSyntaxException re) {
6870
return null;
6971
}
7072
}

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilterTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package org.springframework.boot.actuate.endpoint.mvc;
1818

19+
import static org.assertj.core.api.Assertions.*;
20+
1921
import java.util.Map;
2022

2123
import org.junit.Test;
2224

23-
import static org.assertj.core.api.Assertions.assertThat;
24-
2525
/**
2626
* Tests for {@link NamePatternFilter}.
2727
*
@@ -38,7 +38,7 @@ public void nonRegex() throws Exception {
3838
"not.a.regex");
3939
assertThat(filter.isGetNamesCalled()).isFalse();
4040
}
41-
41+
4242
@Test
4343
public void nonRegexThatContainsRegexPart() throws Exception {
4444
MockNamePatternFilter filter = new MockNamePatternFilter();

0 commit comments

Comments
 (0)