Customize handling of ConversionFailedException
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)