New item in a Map set as an attribute in session are not updated in remote cached session with version 14.0.7 #10736
-
In version 14.0.7, the way of save In older versions I can add a new item to an existent Map in session and it is saved in remote cache and can be recovered in next request. The problem is that with new version, the item is only cached if the map is explicitly set as attribute. As example: protected void doGet(final HttpServletRequest request, final HttpServletResponse response) {
final Map<String, String> map;
HttpSession ses = request.getSession(false);
if (ses == null) {
ses = request.getSession(true);
map = new HashMap<>();
ses.setAttribute("MAP", map);
} else {
map = (Map<String, String>) ses.getAttribute("MAP");
if (map.get("new item") == null) {
LOG.info("create item");
map.put("new item", "new value");
}
}
}
} The session is created in the first call. In the following calls the "new item" is always created because it is never found in session. Are there some configuration or workaround to keep the behaviour of previous versions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Maybe I should bring in @thelateperseus who made the latest modifications to the Spring Session code. |
Beta Was this translation helpful? Give feedback.
-
@davidmestr you can call
|
Beta Was this translation helpful? Give feedback.
@davidmestr you can call
setSaveMode(SaveMode.ALWAYS)
onAbstractInfinispanSessionRepository
to ensure that the session is always saved at the end of the request processing. From the Javadoc inSaveMode
: