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 .springframework .lang .Nullable ;
2022import org .springframework .util .Assert ;
2123import org .springframework .util .ObjectUtils ;
@@ -126,8 +128,18 @@ public String toString() {
126128 // We would preferably use ObjectUtils.nullSafeConciseToString(rejectedValue) here but
127129 // keep including the full nullSafeToString representation for backwards compatibility.
128130 return "Field error in object '" + getObjectName () + "' on field '" + this .field +
129- "': rejected value [" + ObjectUtils . nullSafeToString ( this . rejectedValue ) + "]; " +
131+ "': rejected value [" + formatRejectedValue ( ) + "]; " +
130132 resolvableToString ();
131133 }
132134
135+ private String formatRejectedValue () {
136+
137+ // Special handling of byte[], to be moved into ObjectUtils in 7.0
138+ if (this .rejectedValue instanceof byte [] bytes && bytes .length != 0 ) {
139+ return "{" + HexFormat .of ().formatHex (bytes ) + "}" ;
140+ }
141+
142+ return ObjectUtils .nullSafeToString (this .rejectedValue );
143+ }
144+
133145}
You can’t perform that action at this time.
0 commit comments