0 Replies Latest reply on Jul 17, 2003 1:34 PM by darryl_staflund

    Possible Optimistic Locking Problem

    darryl_staflund

      Hi there,

      I think I have uncovered a possible problem with JBoss's optimistic locking as implemented in JBoss 3.2.x. If two CMP EJBs use optimistic locking and each class can contain instances of each other, although at the object level this circularity won't occur, then the counting mechanism used to manage the clean/dirty states of these classes become out of synch and JBoss eventually throws an exception.

      For instance, say you are using CMP EJB's to implement the elements of a navigation tree, and the following classes are used:

      -----> snip <-----
      public interface BranchItem {}
      public class LeafNode implements BranchItem {} // Implements Optimistic Locking

      public class TreeBranch implements BranchItem // Implements Optimistic Locking
      {
      private BranchItem[] branchItems;
      }
      -----> snip <-----
      Then, if you create a tree structure where one TreeBranch contains another TreeBranch, JBoss will throw an exception -- even though circularity will not occur because of the parent/child relationships between tree elements.

      To summarize my comments on optimistic locking in JBoss 3.2.x, whenever circularity can occur at the class level, JBoss throws an exception even though at the object level circularity will never happen.

      Has anyone encountered this problem? Does anyone have a fix? Am I just not aware that optimistic locking cannot be used in situations like these?
      Darryl