Hazelcast session updates - Spring Boot
Hi,
Could you please help me to clarify something: I've noticed that all Sessions that are retrieved from HazelcastSessionRepository are the copies of basic sessions that stored in MapProxyImpl instance. So if I change a proxy session's attribute property: (This example is not an actual usage, Its just for clarification)
List list = hazelcastRepository.getSession("1").getAttribute("List");
list.add(new Object()); //list.size = 1
List list1 = hazelcastRepository.getSession("1").getAttribute("List");
list1.size() // 0
The basic session's (in MapProxyImpl) attribute 'List' is not updated as well.
Is there a way to merge original session object inside MapProxyImpl and the proxy (copy) session attributes or enable direct session access, not via proxy?
I know, that I could use HazelcastSessionRepository.save() - but the HazelcastSessionRepository.Session has unreachable access.
Thanks!
I think it is because org.springframework.session.hazelcast.HazelcastIndexedSessionRepository#save will not take a branch if (!session.delta.isEmpty()) {... because it does not go reflectively through all session data, but it relies on delta field management in org.springframework.session.hazelcast.HazelcastIndexedSessionRepository.HazelcastSession#setAttribute.
It means you should get the list, clone it, add a field to the clone and setAttribute(list).
I expect other session repositories to work in the same way.