Open lRawd opened 5 years ago
Thanks for the report @lRawd.
It's seems that our HttpSessionBindingListener
support is actually missing a key piece that's required for @PreDestroy
, and that's removal of attributes on expiration which would trigger HttpSessionBindingListener#valueUnbound
.
What is the status on this? I'm having issues with session-scoped beans not having their @PostConstruct or @PreDestroy methods called with Spring Session, and I'm not sure if the issue is related.
I have the same problem using SpringSession 2.5.1. When on HttpSession is invocked method invalidate() in bean below method after() is not invocked.
@Service
@SessionScope
public class SessionInfoService implements Serializable {
@PreDestroy
public void after() {
System.out.println("!!!! SessionInfoService - PreDestroy");
}
}
When I does not use SpringSession method after() is invocked.
When this will be fix?
Is there any update on this issue? Struggle with DestructionCallbackBindingListener, which has no Creators, like default constructor. Wrote a MixIn which works but now i got
org.springframework.data.redis.serializer.SerializationException: Could not read JSON:Cannot construct instance of `org.springframework.beans.factory.support.DisposableBeanAdapter` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
Using GenericJackson2JsonRedisSerializer
.
It is also not working with JdkSerializationRedisSerializer. The @PreDestroy in a SessionScoped
Bean is not invoked
I see that this problem has been reported for Spring Session 2.1.1 which is out of support at this moment. It would be great if someone could provide a minimal, reproducible sample using any of the supported versions.
@marcusdacoregio thanks for you quick response! We are using Spring Session 3.1.1.
Will try to create a minimal reproducible.
@marcusdacoregio Based on the spring-session-samples/spring-session-sample-boot-redis-json i've created a demonstrator.
Take a look https://github.com/thaarbach/spring-session-1256
I'm not sure if this is really an issue/bug of spring-session or a missunderstanding.
@marcusdacoregio Did you have time to take a look at this?
Spring Session 2.1.1.RELEASE This (https://spring.io/blog/2018/10/31/spring-session-bean-ga-released) mentions that it is now possible to use PreDestroy with Session scoped beans. I do not see the valueUnbound method being called when a Session is destroyed, and therefor PreDestroy is never called.