From 55ee25065976780b58cbce8078a976851f1dbbaf Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 10 Feb 2018 17:41:30 +0100 Subject: [PATCH] Object/FieldError stores source object as transient (not serialized) Issue: SPR-16372 --- .../java/org/springframework/validation/ObjectError.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/validation/ObjectError.java b/spring-context/src/main/java/org/springframework/validation/ObjectError.java index 23cf35c3721..ef3378ea2f1 100644 --- a/spring-context/src/main/java/org/springframework/validation/ObjectError.java +++ b/spring-context/src/main/java/org/springframework/validation/ObjectError.java @@ -38,7 +38,7 @@ public class ObjectError extends DefaultMessageSourceResolvable { private final String objectName; @Nullable - private Object source; + private transient Object source; /** @@ -77,6 +77,8 @@ public class ObjectError extends DefaultMessageSourceResolvable { * Initialize the source behind this error: possibly an {@link Exception} * (typically {@link org.springframework.beans.PropertyAccessException}) * or a Bean Validation {@link javax.validation.ConstraintViolation}. + *

Note that any such source object is being stored as transient: + * that is, it won't be part of a serialized error representation. * @param source the source object * @since 5.0.4 */ @@ -89,7 +91,8 @@ public class ObjectError extends DefaultMessageSourceResolvable { * Return the source behind this error: possibly an {@link Exception} * (typically {@link org.springframework.beans.PropertyAccessException}) * or a Bean Validation {@link javax.validation.ConstraintViolation}. - * @return the source object, or {@code null} if none + * @return the source object, or {@code null} if none available + * (none specified or not available anymore after deserialization) * @since 5.0.4 */ @Nullable