-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Newly created session message can not be deserialized by RedisIndexedSessionRepository correctly when using GenericJackson2JsonRedisSerializer #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @buzzerrookie, thanks for the report. In the meantime, as a workaround, you can register a custom mixin for the Long class: private ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModules(SecurityJackson2Modules.getModules(this.loader));
mapper.addMixIn(Long.class, LongMixin.class);
return mapper;
}
abstract class LongMixin {
@SuppressWarnings("unused")
@JsonProperty("long")
Long value;
} |
I don't think I follow, |
Thank you for the workaround. Currently I wrote a Mixin myself. |
According to the javadoc, the RedisIndexedSessionRepository was introduced in 2.2.0. I mean the method saveDelta is fixed in 2.7.7. |
That's right, it was an oversight from my side, apologies. |
Closing in favor of #2305 |
Issue: Unable to Store Spring Security Managed Objects in Redis after Upgrading Spring Session from 2.x.x to 3.x.xEnvironment:
Problem Description:
private ObjectMapper objectMapper() {
|
Describe the bug
In spring-session-data-redis-3.0.0, when using GenericJackson2JsonRedisSerializer as the default serializer, the newly created session message can not be deserialized by onMessage method in RedisIndexedSessionRepository correctly, and the error message "java.lang.IllegalArgumentException: The class with java.lang.Long and name of java.lang.Long is not in the allowlist. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See spring-projects/spring-security#4370 for details" always appears for new sessions.
To Reproduce
I'm using spring-boot 3.0.1 with dependencies spring-boot-starter-data-redis, spring-boot-starter-security, spring-boot-starter-web and spring-session-data-redis, and I'm using Redis 6.2.10.
Expected behavior
No error message should appear in the console.
Sample
session-demo3.zip
I tried to find the reason, and the followings are what I have found:
Should I register a Mixin for Long by myself ? Or would you please add Long to the allowlist in class SecurityJackson2Modules ? Thank you very much.
The text was updated successfully, but these errors were encountered: