spring-projects / spring-projects/spring-session
Customize handling of ConversionFailedException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Description
Expected Behavior
As a developer I am able to customize behavior for ConversionFailedException, e.g. log field name, return null instead of throwing exception during getAttribute operations.
Current Behavior
When a ConversionFailedException is thrown, there is no way to recover other than waiting for session to expire.
Context
We recently started using spring session (transitioning from an old app that used a tomcat session serialization valve). While locally experimenting with changes to a class, I discovered that changes to it's serialized form result in non-recoverable errors. I did expect session.getAttribute to fail - but I was also unable to replace the "broken" value due to setAttribute calling getAttribute to fetch the "old" value.
I am aware that Java standard serialization is a fragile construct - but I am not yet ready to replace this with e.g. JSON serialization.
My current solution is overriding Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) in the GenericConversionService - but in that context I have no knowledge anymore about the field name which makes properly logging the issue very hard.
I am wiling to provide a proof of concept solution for this issue, if:
- there is any interest from spring-session in such a solution at all
- I can get guidance on what level to introduce such a solution (
HttpSessionAdapteror further down in specificSessionRepositoryimplementations)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how GenericConversionService conversion reaches getAttribute and how setAttribute fetches the existing value. Compare the possible extension points named in the issue—HttpSessionAdapter and specific SessionRepository implementations—and determine how recovery and field-name logging should work; done means broken values can be handled or replaced without waiting for session expiry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100