Browse Source

Merge branch '6.2.x'

pull/35696/head
rstoyanchev 3 months ago
parent
commit
af86b30aa7
  1. 14
      spring-context/src/main/java/org/springframework/validation/FieldError.java

14
spring-context/src/main/java/org/springframework/validation/FieldError.java

@ -16,6 +16,8 @@
package org.springframework.validation; package org.springframework.validation;
import java.util.HexFormat;
import org.jspecify.annotations.Nullable; import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -125,8 +127,18 @@ public class FieldError extends ObjectError {
// We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but // We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but
// keep including the full nullSafeToString representation for backwards compatibility. // keep including the full nullSafeToString representation for backwards compatibility.
return "Field error in object '" + getObjectName() + "' on field '" + this.field + return "Field error in object '" + getObjectName() + "' on field '" + this.field +
"': rejected value [" + ObjectUtils.nullSafeToString(this.rejectedValue) + "]; " + "': rejected value [" + formatRejectedValue() + "]; " +
resolvableToString(); resolvableToString();
} }
private String formatRejectedValue() {
// Special handling of byte[], to be moved into ObjectUtils in 7.0
if (this.rejectedValue instanceof byte[] bytes && bytes.length != 0) {
return "{" + HexFormat.of().formatHex(bytes) + "}";
}
return ObjectUtils.nullSafeToString(this.rejectedValue);
}
} }

Loading…
Cancel
Save