Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyDescriptor in PropertyValue needs to be transient to avoid serialization failure [SPR-12377] #16984

spring-projects-issues opened this issue Oct 25, 2014 · 1 comment
in: core type: enhancement


Copy link

@spring-projects-issues spring-projects-issues commented Oct 25, 2014

jongmin moon opened SPR-12377 and commented

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.beans.PropertyDescriptor

  1. 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. org.springframework.beans.PropertyValueTests$SubPropertyDescriptor; no valid constructor

So, I think the filed PropertyDescriptor in the org.springframework.beans.PropertyValue needs to be transient.
I attach a my test code file.

Affects: 4.1.1


Referenced from: commits a13bb69

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 25, 2014

jongmin moon commented

I hava submitted a pull-request in the #676.
Thank you.

@spring-projects-issues spring-projects-issues added type: enhancement in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.2 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core type: enhancement
None yet

No branches or pull requests

2 participants