United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6205431 : Attributes2Impl addAttribute throws ArrayIndexOutOfBoundsException

Details
Type:
Bug
Submit Date:
2004-12-07
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2007-06-28
Component:
xml
OS:
windows_xp
Sub-Component:
org.xml.sax
CPU:
x86
Priority:
P4
Resolution:
Cannot Reproduce
Affected Versions:
5.0
Fixed Versions:
1.4.0

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The test to determine whether to grow the specified and declared arrays is backwards. Specifically in the addAttribute method, the comparison on line 232 of the file org.xml.sax.ext.Attributes2Impl.java currently reads:

	if (length < specified.length) {

This is incorrect and should be:

	if (length > specified.length) {

The incorrect comparison results in the "specified" and "declared" arrays being reallocated when they do not need to be, and not being reallocated when it needs to be thereby throwing an ArrayIndexOutOfBoundsException exception in line 244.

In addition, as a performance enhancement, I would suggest reallocating in chunks larger 1.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Instantiate an Attributes2Impl object. Call its addAttribute method. See the ArrayIndexOutOfBoundsException exception get thrown.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROND :
Create private copy of Attributes2Impl with the correct comparison.
###@###.### 2004-12-07 22:45:06 GMT
###@###.### 2005-2-01 08:36:14 GMT

                                    

Comments
EVALUATION

Fix understood and in process of fixing
###@###.### 2005-2-01 09:14:20 GMT
                                     
2005-02-01
EVALUATION

This bug appeared to have been fixed two years ago. Refer to this change:
http://fisheye5.cenqua.com/browse/jaxp-sources/jaxp-api/src/org/xml/sax/ext/Attributes2Impl.java?r1=1.1&r2=1.2
The comment was "sync with JAXP 1.4 CVS."
                                     
2007-06-28



Hardware and Software, Engineered to Work Together