-
Bug
-
Resolution: Fixed
-
P3
-
1.4.2_12
-
1.3.3
-
x86
-
windows_xp
-
Verified
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 ----------
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 ----------