DestructionCallbackBindingListener on SessionScoped Beans not called
Description
When a @SessionScope bean contains a method annotated with @PreDestroy, the method is not called when using either JdkSerializationRedisSerializer or GenericJackson2JsonRedisSerializer.
Behavior with different serializers:
-
JdkSerializationRedisSerializer: The
@PreDestroymethod is not called, but no errors occur. -
GenericJackson2JsonRedisSerializer: A
SerializationExceptionis thrown byorg.springframework.data.redis.serializer.
To Reproduce
A @SessionScope bean with a method annotated with @PreDestroy is present and in use.
Expected Behavior
The method annotated with @PreDestroy should be invoked when the bean is destroyed, regardless of the serializer used.
Sample Sample project using Spring Boot 3.5.0
See also: Issue #1256