Browse Source

Merge pull request #38944 from FBibonne

* pr/38944:
  Polish "Fix error mark position for PatternParseException"
  Fix error mark position for PatternParseException

Closes gh-38944
pull/38817/head
Moritz Halbritter 2 years ago
parent
commit
a0b034dfc8
  1. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java
  2. 3
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java

2
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java

@ -30,7 +30,7 @@ class PatternParseFailureAnalyzer extends AbstractFailureAnalyzer<PatternParseEx @@ -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);

3
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java

@ -36,7 +36,8 @@ class PatternParseFailureAnalyzerTests { @@ -36,7 +36,8 @@ 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:\n" + "/spring/**/framework\n" + " ^");
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'.");

Loading…
Cancel
Save