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

LogFormatUtils.formatValue does not leniently handle toString() exceptions [SPR-17397] #21930

Closed
spring-issuemaster opened this issue Oct 17, 2018 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Oct 17, 2018

Hans opened SPR-17397 and commented

Steps to reproduce:

  1. create two entities with a JPA-one-to-many-relationship between the two
  2. annotate both classes with lombok's @Data (generating e.g. toString())
  3. set logging.level.org.springframework.web to DEBUG
  4. POST a new child object with a parent reference
  5. Spot the exception. In my case, backend state was correct, frontend stopped working.

Lombok's autogenerated toString() methods probably result in an endless loop in this call:

String s = (value instanceof CharSequence ? "\"" + value + "\"" : value.toString());

Besides excluding some fields from being toStringified() by lombok, this method probably shouldn't throw an error in any case so you might consider try-catching the call.


Affects: 5.1.1

Referenced from: commits 7ff938b

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 18, 2018

Juergen Hoeller commented

We defensively catch any exception there now, logging the toString() representation of the exception instead in that case (similar to how an IDE does it in the debugger).

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 18, 2018

Hans commented

Thanks a lot to Juergen Hoeller for the instant fix (fix as in: as long as Throwable.toString() won't throw itself)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.