Skip to content

Clarify the intention of toString() usage in error logging #35055

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wonyongg
Copy link

The formatErrorForReturnValue method in ServletInvocableHandlerMethod previously included an unnecessary call to toString() and a dangling "in" at the end of the formatted string.

Since the surrounding context already provides sufficient information, both the toString() call and the " in" suffix have been removed to improve clarity.

No functional changes.

The `formatErrorForReturnValue` method in `ServletInvocableHandlerMethod` previously included an unnecessary call to `toString()` and a dangling "in" at the end of the formatted string.

Since the surrounding context already provides sufficient information, both the `toString()` call and the `" in"` suffix have been removed to improve clarity.

No functional changes.

Signed-off-by: wonyongg <[email protected]>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 15, 2025
@bclozel bclozel added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jun 15, 2025
@wonyongg
Copy link
Author

After revisiting the HandlerMethod implementation, I realized that I misunderstood the original purpose of the toString() call.

Initially, I thought the usage of toString() was redundant or unclear. However, I now understand that it returns the description string, which actually provides useful context like ClassName#methodName(args...). sorry for the confusion.

That said, I'd like to propose a small improvement.

The method name toString() by itself doesn't make the intention very clear to someone unfamiliar with the HandlerMethod class. I believe replacing it with getShortLogMessage() could make the code more readable and self-explanatory, especially for contributors or maintainers not deeply familiar with this class.

The output remains similar, but the method name communicates its purpose more directly.

If this suggestion doesn't align with the direction of the project, please feel free to suggest an alternative approach or close this PR if it's unnecessary.

@wonyongg wonyongg changed the title Remove redundant toString() call and trailing "in" from error message Clarify the intention of toString() usage in error logging Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants