You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Heath Borders <he...@gmail.com> on 2004/11/24 15:16:14 UTC

Session synchronization

Just wanted to make sure this wasn't a possible problem for us:
http://weblogs.java.net/blog/jfalkner/archive/2004/11/blarg_10_im_con.html


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: Session synchronization

Posted by Craig McClanahan <cr...@gmail.com>.
Jayson's basic point (that applications need to be aware that objects
they store as session attributes may be accessed by mutiple threads is
correct).  But his particular proposed technique:

    synchronized (session) {
        session.setAttribute("foo", bar);
    }

is wrong on two counts:

* It duplicates the same sort of locking already done inside
  the servlet container.

* It is ineffective when the servlet container gives back
  different Java objects (in Tomcat they are called session
  facades) to different requests accessing the same session.

Where you need to be concerned about synchronization is *inside* the
bar object that you stuffed into the session, not the act of stuffing
it.

Craig McClanahan



On Wed, 24 Nov 2004 08:16:14 -0600, Heath Borders
<he...@gmail.com> wrote:
> Just wanted to make sure this wasn't a possible problem for us:
> http://weblogs.java.net/blog/jfalkner/archive/2004/11/blarg_10_im_con.html
> 
> --
> If you don't have a GMail account, I probably have 5 invites.  Just ask!
> -Heath Borders-Wing
> hborders@mail.win.org
>