United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6446845 Regression in patch 12 of Java 1.4.2: XML parsing behavior changed
JDK-6446845 : Regression in patch 12 of Java 1.4.2: XML parsing behavior changed

Details
Type:
Bug
Submit Date:
2006-07-07
Status:
Closed
Updated Date:
2012-04-25
Project Name:
JDK
Resolved Date:
2007-01-12
Component:
xml
OS:
windows_xp
Sub-Component:
org.xml.sax
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.2_12
Fixed Versions:
1.3.3 (1.3.3)

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
1.4.2_12

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2 and Solaris 8 with recent patches

A DESCRIPTION OF THE PROBLEM :
In Java 1.4.2 up to patch 10, we were able to parse binary data in UTF-16 format without BOM. With patch 12, we are now not able to parse this any more, we get an "content not allowed in prolog". Parsing with specifying the encoding as "UTF-16-LE" works, parsing with "UTF-16" does not work.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run the code below, you will get an SAXParseException in _12, but not in _9 and before.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no exception
ACTUAL -
org.xml.sax.SAXParseException: Content is not allowed in prolog.
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
	at ftisoft.StreetEnterprise.ServiceManager.test.TestServiceRequestImpl.testRegression_Java_1_4_2_12_Bug19000(TestServiceRequestImpl.java:187)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package testjavabug;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;



public class TestServiceRequestImpl extends junit.framework.TestCase
{
    public void testRegression_Java_1_4_2_12_Bug19000() throws Exception
    {
        String xmlinput = "<?xml version=\"1.0\"?>"
            + "<ServiceManagerRequest></ServiceManagerRequest>";

        InputStream is = new ByteArrayInputStream(xmlinput.getBytes("UTF-16LE"));
        assertNotNull(is);

        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        
        // a bug in java 1.4.2_12 results in exceptions when not specifying the BOM if the xml message!
        //Reader r = new InputStreamReader(inputStream/*, "UTF-16LE"*/); // GSEM sends UTF16LE
        //InputSource source = new InputSource(inputStream);
        Document messageDocument = documentBuilder.parse(is);
        assertNotNull(messageDocument);
    }
}

---------- END SOURCE ----------

                                    

Comments
EVALUATION

I have verified that this bug has been fixed in update 13.
                                     
2007-01-12



Hardware and Software, Engineered to Work Together