zinin / tomcat-redis-session Goto Github PK
View Code? Open in Web Editor NEWRedis HttpSession Implementation for Tomcat
Redis HttpSession Implementation for Tomcat
I recently encountered this stacktrace in a production application that I am involved in maintaining:
java.lang.IllegalStateException: Can't get expireAt from redis.
ru.zinin.redis.RedisHttpSession.getExpireAt(RedisHttpSession.java:717)
ru.zinin.redis.RedisHttpSession.renewAll(RedisHttpSession.java:457)
ru.zinin.redis.RedisHttpSession.access(RedisHttpSession.java:509)
org.apache.catalina.connector.Request.doGetSession(Request.java:2868)
The user who encountered the error was unable to login, and needed to clear their cookies (ie: get a new session token) in order to make the error go away. I'm not sure how the session got into this state, since from briefly looking at the code, it looks like this key should only ever get set when in a transaction that creates the session.
I also thought that maybe the redis server had evicted keys due to running out of memory, but the INFO command told me this was not the case. So - somehow this key became null, and the session was rendered unusable but still existed.
Perhaps instead of just raising an exception, the session should also be destroyed if a fatal error indicating that it is unusable occurs? Then errors like this wouldn't continue to persist until key expiry (or client-side destruction of cookies).
RedisEventListenerThread use tomcat common classloader and know nothing about application classloader.
So it's causes ClassNotFoundException in RedisEventListenerThread if you add to session class that exist only on application classpath.
Consider whether I can do something about it...
Think about:
RedisSerializationUtil is slow.
Serialize base types (Integer, String etc) without RedisSerializationUtil.
Create Serialization interface for objects, so object may implement custom serialization/deserialization to string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.