File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
spring-context/src/main/java/org/springframework/validation Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1616
1717package org .springframework .validation ;
1818
19+ import java .util .HexFormat ;
20+
1921import org .jspecify .annotations .Nullable ;
2022
2123import org .springframework .util .Assert ;
@@ -125,8 +127,18 @@ public String toString() {
125127 // We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but
126128 // keep including the full nullSafeToString representation for backwards compatibility.
127129 return "Field error in object '" + getObjectName () + "' on field '" + this .field +
128- "': rejected value [" + ObjectUtils . nullSafeToString ( this . rejectedValue ) + "]; " +
130+ "': rejected value [" + formatRejectedValue ( ) + "]; " +
129131 resolvableToString ();
130132 }
131133
134+ private String formatRejectedValue () {
135+
136+ // Special handling of byte[], to be moved into ObjectUtils in 7.0
137+ if (this .rejectedValue instanceof byte [] bytes && bytes .length != 0 ) {
138+ return "{" + HexFormat .of ().formatHex (bytes ) + "}" ;
139+ }
140+
141+ return ObjectUtils .nullSafeToString (this .rejectedValue );
142+ }
143+
132144}
You can’t perform that action at this time.
0 commit comments