JDK-7057778 : Incompatible behavior of javax.xml.parsers.SAXParser between JDK5 and 6
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.parsers
  • Affected Version: 6u26
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-06-22
  • Updated: 2014-04-11
  • Resolved: 2011-08-01
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 JDK 6 JDK 7
1.4.0 1.4Fixed 6u81Fixed 7u4Fixed
Related Reports
Duplicate :  
Duplicate :  
A customer finds out different behavior in SAXParser between JDK5 and JDK6.
A program executes javax.xml.parsers.SAXParser.parse(File, DefaultHandler)
and tries to delete a specified file as parameter in java.io.File.delete().
Then, the program can delete the file in JDK5 but not in JDK6(and JDK7).

JDK : JDK5u30/JDK6u26/JDK7b143
OS: WindowsXP(SP3, Japanese)

1. Compile the attached Test.java
2. Create a file
   (In this report, "a.txt" is created.)
3. Launch "java Test a.txt" in JDK5u30
  (size of a.txt is 0.)

  Program can delete a.txt with the following message.
F:\licensees\diff-behavior-in-SAXParser>java -showversion Test a.txt
java version "1.5.0_30"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_30-b02)
Java HotSpot(TM) Client VM (build 1.5.0_30-b02, mixed mode)

SAXException: Premature end of file.
Delete: OK

4. Create a.txt and launch "java Test a.txt" in JDK6u25

  The test program do not delete  a.txt.
F:\licensees\diff-behavior-in-SAXParser>java -showversion Test a.txt
 java version "1.6.0_26"
 Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
 Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode)
 SAXException: Premature end of file.
 Delete: NG


EVALUATION I spoke too soon. It's a little more complicated than this. It appeared that the code was removed since a different Entity class was used due to the addition of StAX in jdk6 where the reader attached to an entity can be closed by the entity. But the change was not clean. Because of the change, a call to entity manager's closeReaders now does virtually nothing! In terms of the reported issue, it's possible that an entity may not have been cleaned up.

EVALUATION The relevant code was in XMLEntityManager.java since revision 510, or the merge of Apache Xerces 2.7.1 (released 2005-07-26). But it should have been changed long before 2.7.1, and yet other parts of the class showed that it was indeed 2.7.1. The code that closed the readers was never commented out. Don't know the motivation why it was commented out in jdk6. It's certainly incorrect. The same class in the JDK5 branch was added in the same period of time as in the trunk and contained the correct code as reported. This issue exists in all versions of JDK6.