On Oct 20, 2009, at 2:16 PM, Asiri Rathnayake wrote: > Hi, > > > I don't understand why you've used "transient". Can you explain? >> > > Sorry, "mutable servlet field" was not the error. It was "A non- > serializable > value is stored into a non-transient field of a serializable class". > My > mistake. > > This is why I added the transient field thinking it would fix the > problem. > It did fix the problem but I wasn't sure if that is the correct > thing to do.
ok that's better indeed. The reason is that according to the spec a Servlet can be serialized (saved on disk) if the memory becomes low and thus must be able to be loaded back into memory at a later point (the same need for load-balancing). However your change has introduced another problem: transient means the field will not be saved when the servlet is serialized. Thus when it's deserialized these fields will be null and the code will fail... Whereas before the servlet would have failed on serialization, it'll now fail on deserialization... Note: Deserialization will not call the constructor. Solution: either make the field objects serializable or capture deserialization to set up the transient field values. Note that this last solution may potentially cause problems with threading so this might need to be synchronized I think. The best solution is to make the field Objects Serializable IMO. WDYT? Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

