3 Replies Latest reply on Dec 13, 2006 12:53 AM by Ben Wang

    JBoss PojoCache 2.0: Bug in CachedListImpl?

    Itamar Rogel Newbie

      Hi,
      it seems there's a bug in the latest CVS version of PojoCache 2.0, in CachedListImpl (though it looks like it's probably a bug in another place in the code, that affects CachedListImpl). The bug causes any list which is inserted to the PojoCache to only keep its last item (all other items are discarded).

      How so?

      When attaching a list to the PojoCache, the CollectionClassHandler iterates through it and adds the items from the original list to the List proxy. When an item is added, CacheListImpl inserts the item at an index determined by the current size of the list (which in turn is the number of children of the node). However, the node constantly indicates it has no children - therefore, CachedListImpl.size() constantly returns 0 and all of the items in the list are inserted under '0'. (This is when working in optimistic locking mode).

      What do you say? Any idea for a workaround?

        • 1. Re: JBoss PojoCache 2.0: Bug in CachedListImpl?
          Ben Wang Master

          I do have a test case:
          org.jboss.cache.pojo.collection.CachedListTest that has test for list size after insertion. Can you try that or produce a test case for me?

          Thanks!

          -ben

          • 2. Re: JBoss PojoCache 2.0: Bug in CachedListImpl?
            Itamar Rogel Newbie

            Hi,
            I've ran the test, and indeed it works in its current form - but not when using optimistic locking (e.g. subsistute 'local-service.xml' in 'replAsync-optimistic-service' in the setUp() method). Results of running unit tests from yesterday's CVS version:

            Before (using local-service.xml):
             [junit] Running org.jboss.cache.pojo.collection.CachedListTest
             [junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 15.437 sec
             [junit] Running org.jboss.cache.pojo.collection.CachedListTxTest
             ?
            
            After (using replAsync-optimistic-service.xml):
             [junit] Running org.jboss.cache.pojo.collection.CachedListTest
             [junit] Tests run: 9, Failures: 7, Errors: 0, Time elapsed: 43.203 sec
             [junit] Test org.jboss.cache.pojo.collection.CachedListTest FAILED
            


            I think the problem is that the getChildren() call goes to an OptimisticTreeNode and not to a WorkspaceNode (though WorkspaceNodeImpl doesn't handle getChildren() at all?). The children are not taken from the workspace and so the check of the list size by using getChildren() does not work correctly in optimistic locking mode. Perhaps a simpler way for checking the size (w/o getting the children set) is possible.


            • 3. Re: JBoss PojoCache 2.0: Bug in CachedListImpl?
              Ben Wang Master

              OK, this is a bug we will fix then. I have created a Jira to track it.

              http://jira.jboss.com/jira/browse/JBCACHE-904

              Thanks!