United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6946312 XML parser omits characters callback to ContentHandler since 6u18
JDK-6946312 : XML parser omits characters callback to ContentHandler since 6u18

Details
Type:
Bug
Submit Date:
2010-04-22
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2010-04-28
Component:
xml
OS:
generic
Sub-Component:
org.xml.sax
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u18
Fixed Versions:
1.4.0 (1.4)

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
Starting with update 18 of JDK 1.6.0, the bundled XML Parser is omitting a characters callback to the content handler in the following scenario:

-Using XMLReader
-Set a javax.xml.validation.Schema on the XMLReader
-The schema contains an xs:any with processContents="skip"
-Parse an XML document which has an element containing a text node for the any
-The characters method on the ContentHandler is not invoked for the text contianed in the element

If the Schema isn't set on the SAXParserFactory then the characters method is called as expected. Also if the ProcessContents="skip" is removed, then the characters method is also called as expected. Finally in any JDK version previous to jdk1.6.0_18 the characters method is always called as expected.

A testcase has been attached.

How to reproduce:
Extract the attachment of this CR and go to the folder called xmlparser.characters.issue.
Run java test/Test with the JDK of your choice. 6u17 looks fine, but with 6u18 through 6u20 the issue is reproducible.

$ java -showversion test/Test
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)

Parse InputStream:
Characters called:

Characters called: text
Characters called:

$ java -showversion test/Test
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode)

Parse InputStream:

$ java -showversion test/Test
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) Server VM (build 16.2-b04, mixed mode)

Parse InputStream:

$ java -showversion test/Test
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)

Parse InputStream:

                                    

Comments
EVALUATION

This looks like regression introduced by fixes for 6564400 (6545684). In an attempt to improve performance of the 'ignore whitespace' patch, a mechnism was added to avoid complex tests performed in handleCharacters(). However, a flag used to indicate if the character is ignorable whitespace can sometimes fail to reset, thus may cause subsequent charcter event being skipped.

Note that after the patch for 6564400 (6545684), ignorable whitespace will be not be reported unless the feature added in that patch is enabled as demonstrated below:
saxParserFactory.setFeature("http://java.sun.com/xml/schema/features/report-ignored-element-content-whitespace", true);

Without enabling the above-mentioned feature, the testcase submitted in this bug report will report only "text" character event, that is, printing out "Characters called: text". However, ignorableWhitespace will be invoked.
*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2010-04-26



Hardware and Software, Engineered to Work Together