Reserializing a lenient fallback DefaultListableBeanFactory causes an error [SPR-17508] #22040
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
hwanders opened SPR-17508 and commented
In #20321 the deserialization of
DefaultListableBeanFactory.SerializedBeanFactoryReference
was changed:StaticListableBeanFactory
, it is now resolved to aDefaultListableBeanFactory
.The old
StaticListableBeanFactory
does not implementSerializable
whileDefaultListableBeanFactory
indeed does.When obaining such a lenient fallback
DefaultListableBeanFactory
fromSerializedBeanFactoryReference#readResolve
, it does not get aserializationId
assigned.This causes later reserializations [and they may appear, since the class implements
Serializable
] to fail with aNotSerializableException("DefaultListableBeanFactory has no serialization id")
.Maybe the desired ID (which could not be looked up in the static map
serializableFactories
) should be used:But perhaps this causes undesired side-effects because other dead references to the same factory will become alive when they are deserialized in later calls (they will find the registered dummy factory).
This is actually happening in our software when opening our web application, using an old session containing an
OAuth2ClientContext
after changing the application's bean definitions.We are using the
spring-boot-starter-parent
1.5.7 but some tests on 1.5.17 (which uses 4.3.20) indicate that this is still an issue.Affects: 4.3.20
Issue Links:
Referenced from: commits f5aeb81, 37a50d7, 22f4b1c
Backported to: 5.0.11, 4.3.21
The text was updated successfully, but these errors were encountered: