JDK-6446845 : Regression in patch 12 of Java 1.4.2: XML parsing behavior changed
  • Type: Bug
  • Component: xml
  • Sub-Component: org.xml.sax
  • Affected Version: 1.4.2_12
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-07-07
  • Updated: 2012-04-25
  • Resolved: 2007-01-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.3 1.3.3Fixed
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.
12-01-2007