From 1dc9dffc70308252a00bb56b1b37c67b52ba1ed2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 4 Jul 2023 15:58:46 +0200 Subject: [PATCH] Restore full representation of rejected value in FieldError.toString() We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but revert to the full nullSafeToString representation for strict backwards compatibility (programmatic toString calls as well as exception messages). Closes gh-30799 --- .../main/java/org/springframework/validation/FieldError.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/validation/FieldError.java b/spring-context/src/main/java/org/springframework/validation/FieldError.java index 774f38cb9fb0..e8b03717cf1d 100644 --- a/spring-context/src/main/java/org/springframework/validation/FieldError.java +++ b/spring-context/src/main/java/org/springframework/validation/FieldError.java @@ -124,8 +124,10 @@ public int hashCode() { @Override public String toString() { + // We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but + // keep including the full nullSafeToString representation for backwards compatibility. return "Field error in object '" + getObjectName() + "' on field '" + this.field + - "': rejected value [" + ObjectUtils.nullSafeConciseToString(this.rejectedValue) + "]; " + + "': rejected value [" + ObjectUtils.nullSafeToString(this.rejectedValue) + "]; " + resolvableToString(); }