spring-projects / spring-projects/spring-session

DestructionCallbackBindingListener on SessionScoped Beans not called

Open
#3,415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sample project using Spring Boot 3.5.0 and reproduce destruction of a @SessionScope bean with @PreDestroy using each named serializer. Inspect the resulting SerializationException and verify that the callback is invoked for both JdkSerializationRedisSerializer and GenericJackson2JsonRedisSerializer when the issue is fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring-boot
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.