-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add Documentation About Serialization Between Minor Versions #14409
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
Comments
For those who would like to upgrade to 6.3 but are still on 6.x versions before 6.2.0, you can use the custom ObjectInputStream solution provided by OrangeDog. If you're using Redis, implement your own Deserializer and pass it in to the JdkSerializationRedisSerializer constructor. public class CustomObjectInputStream extends ObjectInputStream {
public CustomObjectInputStream(InputStream in) throws IOException {
super(in);
}
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass descriptor = super.readClassDescriptor();
if (descriptor.getName().startsWith("org.springframework.security.")) {
// Ignore the serialized version and use the current version instead
return ObjectStreamClass.lookupAny(Class.forName(descriptor.getName()));
} else {
return descriptor;
}
}
}
public class CustomDeserializer implements Deserializer<Object> {
@SuppressWarnings("resource")
@Override
public Object deserialize(InputStream inputStream) throws IOException
{
try
{
return new CustomObjectInputStream(inputStream).readObject();
}
catch (ClassNotFoundException ex) {
throw new IOException("Failed to deserialize object type", ex);
}
}
}
@Bean
JdkSerializationRedisSerializer springSessionDefaultRedisSerializer() {
return new JdkSerializationRedisSerializer(new SerializingConverter(), new DeserializingConverter(new CustomDeserializer()));
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Documentation and maybe a blog post should be added for #3737
The text was updated successfully, but these errors were encountered: