{"action":"closed","issue":{"url":"https://api.github.com/repos/perwendel/spark/issues/251","repository_url":"https://api.github.com/repos/perwendel/spark","labels_url":"https://api.github.com/repos/perwendel/spark/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/perwendel/spark/issues/251/comments","events_url":"https://api.github.com/repos/perwendel/spark/issues/251/events","html_url":"https://github.com/perwendel/spark/issues/251","id":60696748,"number":251,"title":"Session Invalidation Error","user":{"login":"melvinma","id":3526172,"avatar_url":"https://avatars.githubusercontent.com/u/3526172?v=3","gravatar_id":"","url":"https://api.github.com/users/melvinma","html_url":"https://github.com/melvinma","followers_url":"https://api.github.com/users/melvinma/followers","following_url":"https://api.github.com/users/melvinma/following{/other_user}","gists_url":"https://api.github.com/users/melvinma/gists{/gist_id}","starred_url":"https://api.github.com/users/melvinma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/melvinma/subscriptions","organizations_url":"https://api.github.com/users/melvinma/orgs","repos_url":"https://api.github.com/users/melvinma/repos","events_url":"https://api.github.com/users/melvinma/events{/privacy}","received_events_url":"https://api.github.com/users/melvinma/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/perwendel/spark/labels/Bug","name":"Bug","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-11T17:33:35Z","updated_at":"2016-05-04T19:28:19Z","closed_at":"2016-05-04T19:28:19Z","body":"Session invalidate and then recreated failed for me - The reason is, after invalidate a session, the session and the invalid HttpSession was not cleared out. I recommend the following code change in spark: in Request class, whenever access session variable, check if session is valid, if not valid, create a new session variable.\r\n\r\n---- code having issues ----\r\n\t\t\tSession session = request.session(false);\r\n\t\t\tif (session!= null) session.invalidate();\t\t\t\r\n\t\t\tsession = request.session(true);\r\n\t\t\tsession.attribute(SessionKeys.USER_ACCESS_TOKEN, \"1234567\");\r\n\r\n---- exception I got ----\r\n\r\njava.lang.IllegalStateException: null\r\n\tat org.eclipse.jetty.server.session.AbstractSession.checkValid(AbstractSession.java:104) ~[jetty-server-9.0.2.v20130417.jar:9.2.7.v20150116]\r\n\tat org.eclipse.jetty.server.session.HashedSession.checkValid(HashedSession.java:79) ~[jetty-server-9.0.2.v20130417.jar:9.2.7.v20150116]\r\n\tat org.eclipse.jetty.server.session.AbstractSession.changeAttribute(AbstractSession.java:509) ~[jetty-server-9.0.2.v20130417.jar:9.2.7.v20150116]\r\n\tat org.eclipse.jetty.server.session.AbstractSession.setAttribute(AbstractSession.java:461) ~[jetty-server-9.0.2.v20130417.jar:9.2.7.v20150116]\r\n\tat spark.Session.attribute(Session.java:55) ~[spark-core-2.1.jar:na]\r\n"}}