A Spring Boot application with a Vaadin front-end that shows how to use Spring Session to replace the standard HttpSession with Redis.
- Download, install, and start Redis (this demo uses the default configuration).
git clone https://github.com/alejandro-du/vaadin-spring-session-demo.git
cd vaadin-spring-session-demo
mvn package spring-boot:run
- Browse http://localhost:8080
Spring Session with Redis doesn't work out-of-the-box with Vaadin. The issue is that the objects in the session are sent to Redis before the VaadinSession
instance has been fully configured which causes an old version of the instance to be persisted in Redis. The problem resides in the RedisOperationsSessionRepository
class which unfortunatelly doesn't have enough extension options to fix the problem with inheritance for example.
In order to overcome this, I found this project that included a "dirty hack" that fixes the issue. The hack requires you to use a modified version of the RedisOperationsSessionRepository
class placed in the same package as the original one.
This "hack", inspired the spring-session-redis Vaadin add-on that includes a filter that does the trick without having to replace any class from Spring Session.
Thanks to Karsten Ludwig Hauser for the original idea!