Hello,

I occasionally got ArrayIndexOutOfBoundsExceptions in the
DOMTreeManager, and I think the reason were two loops in the
appendGroup(...) and recycleTopLevelGroup(...) methods where the size of groupManagers was erroneously assumed to be constant during the loop. Attached is a patch against CVS rev. 1.19 of DOMTreeManager.java.


Best wishes
Christian Gawron


Index: sources/org/apache/batik/svggen/DOMTreeManager.java
===================================================================
RCS file: 
/home/cvspublic/xml-batik/sources/org/apache/batik/svggen/DOMTreeManager.java,v
retrieving revision 1.19
diff -C5 -r1.19 DOMTreeManager.java
*** sources/org/apache/batik/svggen/DOMTreeManager.java 18 Aug 2004 07:14:59 
-0000      1.19
--- sources/org/apache/batik/svggen/DOMTreeManager.java 12 Feb 2005 23:28:08 
-0000
***************
*** 172,183 ****
       * @param group new group to be appended to the topLevelGroup
       * @param groupManager DOMTreeManager that produced the group.
       */
      public void appendGroup(Element group, DOMGroupManager groupManager){
          topLevelGroup.appendChild(group);
!         int nManagers = groupManagers.size();
!         for(int i=0; i<nManagers; i++){
              DOMGroupManager gm = (DOMGroupManager)groupManagers.elementAt(i);
              if( gm != groupManager )
                  gm.recycleCurrentGroup();
          }
      }
--- 172,182 ----
       * @param group new group to be appended to the topLevelGroup
       * @param groupManager DOMTreeManager that produced the group.
       */
      public void appendGroup(Element group, DOMGroupManager groupManager){
          topLevelGroup.appendChild(group);
!         for(int i=0; i<groupManagers.size(); i++){
              DOMGroupManager gm = (DOMGroupManager)groupManagers.elementAt(i);
              if( gm != groupManager )
                  gm.recycleCurrentGroup();
          }
      }
***************
*** 193,204 ****
      /**
       * Reset the state of this object to handler a new topLevelGroup
       */
      private void recycleTopLevelGroup(boolean recycleConverters){
          // First, recycle group managers
!         int nManagers = groupManagers.size();
!         for(int i=0; i<nManagers; i++){
              DOMGroupManager gm = (DOMGroupManager)groupManagers.elementAt(i);
              gm.recycleCurrentGroup();
          }
  
          // Create top level group node
--- 192,202 ----
      /**
       * Reset the state of this object to handler a new topLevelGroup
       */
      private void recycleTopLevelGroup(boolean recycleConverters){
          // First, recycle group managers
!         for(int i=0; i<groupManagers.size(); i++){
              DOMGroupManager gm = (DOMGroupManager)groupManagers.elementAt(i);
              gm.recycleCurrentGroup();
          }
  
          // Create top level group node

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to