Affects: 5.3.27


Hello spring team! I tried to update my spring-boot application, and I found a change of behaviour in bean validation output on how it renders UUID's The old behaviour would show the .toString() version of the UUID, the new version would show the object id instead. I traced it down to this change:

https://github.com/spring-projects/spring-framework/blob/v5.3.26/spring-context/src/main/java/org/springframework/validation/FieldError.java to https://github.com/spring-projects/spring-framework/blob/v5.3.27/spring-context/src/main/java/org/springframework/validation/FieldError.java

in the toString() of FieldError ObjectUtils.nullSafeToString(this.rejectedValue) was changed to ObjectUtils.nullSafeConciseToString(this.rejectedValue)

Here it checks if it is a "isSimpleValueType" and if so, it calls the toString() and otherwise it returns the typename. From reading the issues I think this change happend because otherwhise whole object hierarchies would be included, which is not really useful. UUID's do sound like an exception to this rule. I do not mind making a pull request for this myself (would be nice to help spring :)) but I would like some guidance to where you think it is best to solve this (if you consider this desirable behaviour). I could UUID to the isSimpleValueType method, or should I make a special case for this?

Kind regards

Ties

Comment From: jhoeller

This is a regression caused by #30286. Since we intend to release 6.0.10 and 5.3.28 this week, I'll pick this up directly.

Thanks for the report, and thanks for volunteering! With more lead-up time, I'd be happy to help with a pull request next time.

Comment From: vandeven

Ok :) thank you!

Comment From: jhoeller

@vandeven since we're considering a wider revision here for 6.0.11 / 5.3.29, could you please clarify how you are consuming the FieldError.toString() output for which the UUID rendering mattered above? Are you calling the method directly (like in #30799) or indirectly via Errors/BindingResult/BindException?

Comment From: vandeven

I was doing it indirectly through bean validation. @Valid in combination with a custom ConstraintValidator, resulting in an error message: org.springframework.validation.BeanPropertyBindingResult: 3 errors Field error in object 'MyObject' on field 'myField': rejected value [java.util.UUID@384f0e32]

(omitted some parts because it is code of the client im working for)

and we get this result from just calling mockmvc

mockMvc.perform(post("/myurl").andReturn().getResolvedException();

And I cannot seem to find any error handler for this.

Comment From: sbrannen

Update

Changes made to FieldError#toString will be reverted in:

  • 30799

Improvements to ObjectUtils.nullSafeConciseToString are being made in:

  • 30805

  • 30810