myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: Session synchronization
Date Wed, 24 Nov 2004 17:30:43 GMT
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
<heath.borders@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
>

Mime
View raw message