I was reading Tapestry In Action and did not understand the implication of 
clustering a mutable object. Hope you can explain.
 
To set the stage, the section states that an app server -- such as Web Logic -- 
broadcasts a change to all servers in a cluster in response to an invocation of 
the setAttribute method of an HttpSession.  The article goes on differentiate 
mutable and immutable objects placed in a session.  It says that depending on 
the sequence of the steps, the value of a session attribute on server in a 
cluster can be stale.  For example:
 
session.setAttribute("some token", x);
x.setSomeValue("some value");
 
In this case, since the object referred to by 'x' is being modified *after* a 
call to setAttribute, it may not get propagated to all servers in a cluster.  
The cagey *may not* is because we may get lucky if the app server hasn't got 
around to serializing 'x' and broadcasting it, before the application invokes 
the setSomeValue method.
 
My question is: How is this any different if x were an immutable object -- such 
as a String?  Wouldn't we have the same problem?
 
Sri

Reply via email to