Redis version
6.2.6
Redisson version
redisson-tomcat-9 3.22.0
Redisson configuration
A default config using AWS ElastiCache connection string
What is the Expected behavior?
No response
What is the Actual behavior?
We are seeing this exception consistently in production (~5 times/day) on a Tomcat 9 deployment:
SEVERE [https-jsse-nio-8443-exec-7] org.apache.catalina.core.StandardHostValve.invoke Exception Processing [someUrl]
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
at org.redisson.tomcat.RedissonSession.load(RedissonSession.java:447)
at org.redisson.tomcat.RedissonSessionManager.findSession(RedissonSessionManager.java:188)
at org.redisson.tomcat.RedissonSessionManager.findSession(RedissonSessionManager.java:168)
at org.apache.catalina.connector.Request.doGetSession(Request.java:2975)
at org.apache.catalina.connector.Request.getSessionInternal(Request.java:2695)
...
Root cause
In RedissonSession.java, the load() method performs a hard cast to Long:
// line 447 in 3.22.0 / line 491 in current master
Long creationTime = (Long) attrs.remove(CREATION_TIME_ATTR);
Under concurrent load, session:creationTime can be written as an Integer to Redis, causing the cast to fail.
Previous report — closed without a code fix
This is the same root cause reported in #4254 (closed Apr 2022). The workaround was suggested in the comments (cast to Number then call .longValue()), but it was never applied to the source code. Verified against the current master branch (line 491) — the hard cast to Long is still there, unchanged across all versions from 3.16.0 through 4.3.0.
Suggested fix:
Number creationTime = (Number) attrs.remove(CREATION_TIME_ATTR);
if (creationTime != null) {
this.creationTime = creationTime.longValue();
}
The same defensive cast may be need applied to lastAccessedTime and thisAccessedTime on the adjacent lines.
Steps to reproduce:
Occurs intermittently under high concurrent load. Not easily reproducible locally.
Environment:
Redis version: 6.2.6
Redisson version: redisson-tomcat-9:3.22.0
Java version: Java 11 (Amazon Corretto)
Tomcat version: Tomcat 9
Additional information
No response
Redis version
6.2.6
Redisson version
redisson-tomcat-9 3.22.0
Redisson configuration
A default config using AWS ElastiCache connection string
What is the Expected behavior?
No response
What is the Actual behavior?
We are seeing this exception consistently in production (~5 times/day) on a Tomcat 9 deployment:
Root cause
In RedissonSession.java, the load() method performs a hard cast to Long:
Under concurrent load, session:creationTime can be written as an Integer to Redis, causing the cast to fail.
Previous report — closed without a code fix
This is the same root cause reported in #4254 (closed Apr 2022). The workaround was suggested in the comments (cast to Number then call .longValue()), but it was never applied to the source code. Verified against the current master branch (line 491) — the hard cast to Long is still there, unchanged across all versions from 3.16.0 through 4.3.0.
Suggested fix:
The same defensive cast may be need applied to lastAccessedTime and thisAccessedTime on the adjacent lines.
Steps to reproduce:
Occurs intermittently under high concurrent load. Not easily reproducible locally.
Environment:
Redis version: 6.2.6
Redisson version: redisson-tomcat-9:3.22.0
Java version: Java 11 (Amazon Corretto)
Tomcat version: Tomcat 9
Additional information
No response