Fix error mark position for PatternParseException
PatternParseException.toDetailedString() return a String with a mark to specify the error position in the pattern. The mark takes place in the second line in the String returned. Because PatternParseFailureAnalyzer.analyze appended "Invalid mapping pattern detected:" at the beginning of the returned String, the mark was not well positioned. Now, a "\n" is inserted after "Invalid mapping pattern detected:" and the mark is well positioned See gh-38944
This commit is contained in:
parent
52a4097997
commit
fccce54d52
|
@ -30,7 +30,7 @@ class PatternParseFailureAnalyzer extends AbstractFailureAnalyzer<PatternParseEx
|
|||
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure, PatternParseException cause) {
|
||||
return new FailureAnalysis("Invalid mapping pattern detected: " + cause.toDetailedString(),
|
||||
return new FailureAnalysis("Invalid mapping pattern detected:\n" + cause.toDetailedString(),
|
||||
"Fix this pattern in your application or switch to the legacy parser implementation with "
|
||||
+ "'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.",
|
||||
cause);
|
||||
|
|
|
@ -36,10 +36,14 @@ class PatternParseFailureAnalyzerTests {
|
|||
@Test
|
||||
void patternParseFailureQuotesPattern() {
|
||||
FailureAnalysis failureAnalysis = performAnalysis("/spring/**/framework");
|
||||
assertThat(failureAnalysis.getDescription()).contains("Invalid mapping pattern detected: /spring/**/framework");
|
||||
assertThat(failureAnalysis.getDescription()).contains("""
|
||||
Invalid mapping pattern detected:
|
||||
/spring/**/framework
|
||||
^
|
||||
""");
|
||||
assertThat(failureAnalysis.getAction())
|
||||
.contains("Fix this pattern in your application or switch to the legacy parser"
|
||||
+ " implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.");
|
||||
.contains("Fix this pattern in your application or switch to the legacy parser"
|
||||
+ " implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.");
|
||||
}
|
||||
|
||||
private FailureAnalysis performAnalysis(String pattern) {
|
||||
|
|
Loading…
Reference in New Issue