From fccce54d52929df243fa65ef1d4bd89c0ba49470 Mon Sep 17 00:00:00 2001 From: Fabrice Bibonne Date: Fri, 29 Dec 2023 14:03:22 +0100 Subject: [PATCH 1/2] 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 --- .../analyzer/PatternParseFailureAnalyzer.java | 2 +- .../analyzer/PatternParseFailureAnalyzerTests.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java index e4cf51746c4..a9eae1eb226 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzer.java @@ -30,7 +30,7 @@ class PatternParseFailureAnalyzer extends AbstractFailureAnalyzer Date: Wed, 10 Jan 2024 09:21:03 +0100 Subject: [PATCH 2/2] Polish "Fix error mark position for PatternParseException" See gh-38944 --- .../analyzer/PatternParseFailureAnalyzerTests.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java index 4b4b55eefb4..87eb14b67d2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/PatternParseFailureAnalyzerTests.java @@ -36,14 +36,11 @@ 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'."); + .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) {