-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Dave Syer opened SPR-14117 and commented
A scoped proxy (e.g. in @Scope("session") with @Lazy) carries a reference to a "serialization id" for the BeanFactory. This is in case, when it is deserialized, it needs to inject a dependency from the Spring context. As such, that can be quite useful, but it is also brittle, and not always necessary, since not all beans have dependencies to re-inject, and sometimes you want to share an instance between two contexts that don't naturally have the same serialization id.
There's quite a bit of discussion in one or two github issues related to Spring Cloud, Spring Boot and Spring OAuth2 (e.g. spring-attic/spring-security-oauth#705).
In the OAuth2 case we are only using @Scope("session") to keep the state segregated between concurrent users, and the data held in those beans is naturally serializable without any reference to the BeanFactory. I imagine this could be quite common, and I would like a way to annotate (or have Spring detect) that this is the case, so that the serialized form of the object does not contain a BeanFactory reference if it is not going to be needed.
Reference URL: spring-attic/spring-security-oauth#705
Issue Links:
- ClassCastException during deserialization of ScopedObject [SPR-15766] #20321 ClassCastException during deserialization of ScopedObject
Referenced from: commits 4024b2f