Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error mark in the log message for PatternParseException is in the wrong place #38944

Conversation

FBibonne
Copy link
Contributor

When a PatternParseException for a regexp path pattern occurs in a Spring MVC application launched by Spring Boot, the PatternParseFailureAnalyzer logs a message like this in console :

Description:

Invalid mapping pattern detected: /{path:\w+/\w+}
          ^
Expected close capture character after variable name }

...

At line 4, the mark '^' which indicates the error in the pattern is misplaced because the string returned by PatternParseException.toDetailedString() is appended to "Invalid mapping pattern detected:".

So this PR proposes to insert a "\n" after "Invalid mapping pattern detected:" . The error mark will be well positioned like this :

Description:

Invalid mapping pattern detected:
/{path:\w+/\w+}
          ^
Expected close capture character after variable name }

The only change in the main code is th addition of "\n". The rest of the changes adapts the test PatternParseFailureAnalyzerTests.

NB : I was not able to run the ./gradlew check for the whole project (8 tests failed for Task :buildSrc:test) but I ran tests for the module spring-boot-project/spring-boot and the number of failling tests is the same after the change

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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 29, 2023
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 29, 2023
@philwebb philwebb added this to the 3.1.x milestone Dec 29, 2023
@wilkinsona wilkinsona changed the title Fix the position of the error mark in the log when PatternParseException occurs Error mark in the log message for PatternParseException is in the wrong place Jan 3, 2024
mhalbritter pushed a commit that referenced this pull request Jan 10, 2024
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
@mhalbritter
Copy link
Contributor

Thank you very much and congratulations on your first contribution 🎉!

@mhalbritter mhalbritter modified the milestones: 3.1.x, 3.1.8 Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants