1 Reply Latest reply on Sep 26, 2008 5:32 AM by Andrei Markavtsov

    rich:columns tag broken in production environment

    thonis meta Newbie

      dear community,

      we are using the rich:columns tag because the user can choose and rearrange the columns of his report. as long as we were in development phase we had no problems with this tag (we were using RF 3.2.2).

      when we started with performance testing the behaviour of the rich:columns tag immediately was broken.
      when the tag was iterating over the List provided in it's value attribute, it suddenly left out elements of this list, returned them in the wrong order etc., typical symptoms found in non-threadsafe code.

      after patching the richfaces classes with debug outputs, i think we found out the reason:

      the implementation of the org.richfaces.taglib.ComponentHandler (which is a facelet tag handler) uses instance variables to hold the state of the iterations!

      i'm no facelet specialist, but the documentation says: "Just like a Facelet, all of the TagHandlers are stateless for offering a higher degree of performance"
      we could see that even for different sessions and threads there is always only ONE instance of a ComponentHandler;
      as this one ComponentHandler manages the state of the iteration (index and iterator of column elements) via its own member variables this breaks immediately when 2 threads both enter the apply-method at the same time.

      could be that i have misunderstood the inner workings of the facelet mechanism, but if not, this is horrible code!

      we confirmed our suspicion by synchronizing the apply method of org.richfaces.taglib.ComponentHandler as a first quickfix, and it worked!

      whats the best solution? shouldnt TagHandlers just store their state somewhere in the FaceletContext?

      would be nice, if we can discuss the issue here, i am willing to do the fixes if i get feedback. (i found even more classes in the columns-taghandler-package that use similar ways to hold state.)

      best regards tm!