spring-session icon indicating copy to clipboard operation
spring-session copied to clipboard

DestructionCallbackBindingListener on SessionScoped Beans not called

Open thaarbach opened this issue 7 months ago • 0 comments

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 @PreDestroy method is not called, but no errors occur.

  • GenericJackson2JsonRedisSerializer: A SerializationException is thrown by org.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

thaarbach avatar Jun 03 '25 16:06 thaarbach