-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Revert changes to toString()
in FieldError
#30799
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
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
Jul 3, 2023
sbrannen
added
type: regression
A bug that is also a regression
in: core
Issues in core modules (aop, beans, core, context, expression)
labels
Jul 3, 2023
sbrannen
changed the title
ObjectUtils returns a wrong string representation of an empty collection ("ArrayList@12345" instead of "[]")
Provide explicit support for empty collections and arrays in Jul 3, 2023
ObjectUtils.nullSafeConciseToString()
sbrannen
changed the title
Provide explicit support for empty collections and arrays in
Provide explicit support for empty collections/maps/arrays in Jul 3, 2023
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
This was referenced Jul 3, 2023
sbrannen
added
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged or decided on
type: regression
A bug that is also a regression
labels
Jul 3, 2023
sbrannen
changed the title
Provide explicit support for empty collections/maps/arrays in
Provide explicit support for empty collections/maps/arrays, Jul 3, 2023
ObjectUtils.nullSafeConciseToString()
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
sbrannen
changed the title
Provide explicit support for empty collections/maps/arrays,
Support empty collections/maps/arrays, Jul 3, 2023
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
github-actions
bot
added
status: backported
An issue that has been backported to maintenance branches
and removed
for: backport-to-5.3.x
labels
Jul 3, 2023
9 tasks
sbrannen
changed the title
Support empty collections/maps/arrays,
Support empty collections, maps, and arrays in Jul 4, 2023
Optional
, File
, and Path
in ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
sbrannen
changed the title
Support empty collections, maps, and arrays in
Provide explicit support collections, maps, and arrays in Jul 4, 2023
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
sbrannen
changed the title
Provide explicit support collections, maps, and arrays in
Provide explicit support for collections, maps, and arrays in Jul 4, 2023
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeConciseToString()
sbrannen
changed the title
Provide explicit support for collections, maps, and arrays in
Revert changes to Jul 4, 2023
ObjectUtils.nullSafeConciseToString()
toString()
in FieldError
sbrannen
added
type: regression
A bug that is also a regression
and removed
type: enhancement
A general enhancement
labels
Jul 4, 2023
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
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: