spring-projects/spring-framework — pull request #676 by MoonJongMin (2014-10-25 22:52:22+00:00)
Title: The filed PropertyDescriptor in the org.springframework.beans.PropertyValue needs to be transient to avoid serialization and deserialization failure in case of resolvedDescriptor in the PropertyValue is not null.

org.springframework.beans.PropertyValue is Serializable and has a member PropertyDescriptor.
Even though threre is little possible to have a Exception when serialization and deSerialization
because the access modifier of PropertyDescriptor is defualt,
PropertyDescriptor needs to be transient.

1) Case 1
create a PropertyValue Object. then set resolvedDescriptor in the org.springframework.beans package.
then try to serialize value object.

PropertyValue value = new PropertyValue("a", "b");
value.resolvedDescriptor = new PropertyDescriptor("serializable", PropertyValueTests.class);

in this case PropertyDescriptor is not a Serializable class, when writeObject(value) is called,
Exception occurs like below as you know.

java.io.NotSerializableException: java.beans.PropertyDescriptor
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
...

2) Case 2
For avoiding serialization failure, make SubPropertyDescriptor which is serializable.

PropertyValue value = new PropertyValue("a", "b");
value.resolvedDescriptor = new SubPropertyDescriptor("serializable", PropertyValueTests.class);

public class SubPropertyDescriptor extends PropertyDescriptor implements Serializable {

public SubPropertyDescriptor(String propertyName, Class beanClass)
throws IntrospectionException {
super(propertyName, beanClass);
}

public SubPropertyDescriptor() throws IntrospectionException {
// There is no-args constructor in the PropertyDescriptor.
super("serializable", PropertyValueTests.class);
}

}

in this case SubPropertyDescriptor is a Serializable class, so serialization is successful.
But when ObjectInputStream.readObject is called for deSerialization,
Exception occurs like below as you know because the parent class PropertyDescriptor does not have
no-args default constructor.

java.io.InvalidClassException: org.springframework.beans.PropertyValueTests$SubPropertyDescriptor; no valid constructor
at java.io.ObjectStreamClass$ExceptionInfo.newInvalidClassException(ObjectStreamClass.java:150)
at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:768)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
...

So, I think the filed PropertyDescriptor in the org.springframework.beans.PropertyValue needs to be transient.

ISSUE : SPR-

I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.