Skip to content

SessionAttributes defined in the controller are not populated from the HttpSession object when the web session fails over to a new server in the cluster [SPR-9047] #13686

Closed
@spring-projects-issues

Description

@spring-projects-issues

Erik Love opened SPR-9047 and commented

We have been working towards implementing a web site using Spring 3.0.5. However, when working in a clustered environment, we have found that variables defined as part of the @SessionAttribute annotation are not populated from the HttpSession when the server instance fails over to a different server in the cluster.

It looks like the org.springframework.web.bind.annotation.support.HandlerMethodInvoker calls the getActualSessionAttributeNames() method of the HandlerMethodResolver in order to get a list of all session attributes/variables that should be placed into the Model. The issue, however, is that the Set used to store the names (actualSessionAttributeNames) is not populated during the init of HandlerMethodResolver. It is only populated as the HandlerMethodResolver.isSessionAttribute method is called which doesn't happen until AFTER the call to the getActualSessionAttributeNames() is made by the HandlerMethodInvoker. This is resulting in the SessionAttribute values being re-initialized and the loss of all conversational data for the Controller.

We have temporarily gotten around this issue by modifying the HandlerMethodResolver code to have it add all session attribute names to the actualSessionAttributeNames during the init (around line 107 in the HandlerMethodResolver code). We have not found any other solution and most forums/posts/blogs/examples suggest using the WebRequest or HttpSession objects directly.


Affects: 3.0.5

Attachments:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions