You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by "Thorsten J. Krause" <th...@datenwerke.net> on 2014/10/22 23:55:06 UTC

Different behavior of Session Object after switching to Shiro

Hi all,

I'm trying to integrate Shiro into an existing web application, but there are some issues with regards to session handling: 
Whenever I call session.getAttribute(key) I get a new instance of the associated object, so even inside the same request consecutive calls
to getAttribute return different objects. Is this the intended behavior, or is there something wrong with my configuration?
We are using Cassandra for session storage (with a SessionDAO similar to the on described by Les in his shiro+cassandra blogpost)

For illustration (sess being the httpSession), this returns an empty list: 

1:    ArrayList<String> myList = sess.getAttribute("MYLIST");
2:        if(null == myList){
3:            myList = new ArrayList<String>();
4:            sess.setAttribute("MYLIST", myList);
5:        }
6:    myList.add("dummy");
7:    return sess.getAttribute("MYLIST");

Thank you for your help, 
kind regards
Thorsten