Bug 40686 - ArrayIndexOutOfBoundsException in DOMTreeManager.appendGroup
Summary: ArrayIndexOutOfBoundsException in DOMTreeManager.appendGroup
Status: RESOLVED FIXED
Alias: None
Product: Batik - Now in Jira
Classification: Unclassified
Component: SVG DOM (show other bugs)
Version: 1.6
Hardware: Other Linux
: P2 major
Target Milestone: ---
Assignee: Batik Developer's Mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-05 07:06 UTC by Bernd Fechner
Modified: 2007-03-25 10:07 UTC (History)
0 users



Attachments
Modified class DOMTreeManager (14.27 KB, text/plain)
2006-10-13 07:08 UTC, Bernd Fechner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Fechner 2006-10-05 07:06:18 UTC
I'm getting the following exception from time to time, when generating a complex
chart graphic:

java.lang.ArrayIndexOutOfBoundsException: 28 >= 10
	at java.util.Vector.elementAt(Vector.java:432)
	at org.apache.batik.svggen.DOMTreeManager.appendGroup(DOMTreeManager.java:175)
	at org.apache.batik.svggen.DOMGroupManager.addElement(DOMGroupManager.java:159)
	at org.apache.batik.svggen.SVGGraphics2D.fill(SVGGraphics2D.java:1384)
	at
org.apache.batik.ext.awt.g2d.AbstractGraphics2D.drawGlyphVector(AbstractGraphics2D.java:960)
	at sun.font.ExtendedTextSourceLabel.handleDraw(ExtendedTextSourceLabel.java:131)
	at sun.font.Decoration.drawTextAndDecorations(Decoration.java:99)
	at sun.font.ExtendedTextSourceLabel.draw(ExtendedTextSourceLabel.java:135)
	at java.awt.font.TextLine.draw(TextLine.java:550)
	at java.awt.font.TextLayout.draw(TextLayout.java:2699)
	at com.werum.chartgen.Axis.drawYAxis(Axis.java:313)
	at com.werum.chartgen.Axis.draw(Axis.java:130)
	at com.werum.chartgen.CoordPlane.drawAxes(CoordPlane.java:165)
	at com.werum.chartgen.CoordPlane.draw(CoordPlane.java:138)
	at com.werum.chartgen.Chart.draw(Chart.java:144)
	at com.werum.chartgen.Chart.draw(Chart.java:155)
	at com.werum.chartgen.test.TestChart02.run(TestChart02.java:87)
	at com.werum.chartgen.test.TestChart02.main(TestChart02.java:261)

The code of method DOMTreeManager.appendGroup is rather short:

    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();
        }
    }

I think the problem has something to do with the disposer thread running in the
background and modifying the 'groupManagers' Vector during the iteration. This
happens when SVGGraphics2D objects are disposed:

    public void dispose() {
        this.domTreeManager.removeGroupManager(this.domGroupManager);
    }

My proposal is to protect the 'groupManagers' Vector against modifications
during iterations in class DOMTreeManager. Because I have compiled batik from
source, I will make the modification and test it in my environment.

Currently I'm working on a Fedora Core5 Linux using Eclipse 3.2 and JDK
1.5.0_09, but I have seen the same problem on a Windows XP environment.

Bernd
Comment 1 Bernd Fechner 2006-10-13 07:08:55 UTC
Created attachment 18999 [details]
Modified class DOMTreeManager

This is the modified DOMTreeManager with synchronization around the
groupManagers member. It works in my test environment.
Comment 2 info 2007-03-25 10:07:35 UTC
fixed in svn 522302