-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Revert changes to toString()
in FieldError
#30799
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
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Milestone
Comments
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
This was referenced Jul 3, 2023
ObjectUtils.nullSafeConciseToString()
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
9 tasks
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
toString()
in FieldError
Thank you for raising the issue. Due to your feedback and feedback from others in the community, we have decided to revert the changes to |
You're wellcome. |
Spring Boot 2.7.14 will include this, as well as the other upcoming Spring Boot releases in July. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Uh oh!
There was an error while loading. Please reload this page.
Affects: 5.3.27 and later versions
In spring-framework 5.3.27
ObjectUtils.nullSafeConciseToString()
method was introduced (#30287), that changed the way to generate null-safe, concise string representation of a supplied object.We are indirectly using that method from
spring-context
viaFieldError.toString()
, to retrieve the string representation of a field failing JSR303 bean validation.When upgrading from 5.3.24 to 5.3.27 we have had contract tests failing because in case of empty lists that should have at least 1 element, failing validation, the value returned for them was not anymore the expected
[]
, butArrayList@[the_address]
.I'll try to summarize:
Imagine you are in
FieldError
because the Spring validation wrapping stuff has produced aMethodArgumentNotValidException
, the exception handler in the application catches it, and it callsFieldError.toString()
to fill in aProblemDetails
.With 5.3.24:
For something like a list implementation, when empty, all the if's failed and the call to
obj.toString()
before the return statement ended injava.util.AbstractCollection.toString
(that is the case ofjava.util.ArrayList
), which produced the expected result:With 5.3.27 (and onwards):
As before, with an empty list, obj does not enter any of the
instanceof
if's, neither theisSimpleValueType
. As a resultArrayList@12345
is returned, which is wrong and not what we expect as the value making the validation fail, which is an empty list and not something likeArrayList@12345
.The text was updated successfully, but these errors were encountered: