-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
windows_7
FULL PRODUCT VERSION :
java version " 1.6.0_43 "
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Basically, if you parse a poorly formatted xml file using a javax.xml.parsers.DocumentBuilder instance, it will raise a org.xml.sax.SAXParseException but not " close " an internal handle to the file being parsed, which means that, depending on when the GC runs, it may or may not be, for instance, on windows, deletable for some period of time.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
If you run the code sample, for instance with jre6/jdk 6, the problem sporadically reproduces (in this snippet, it outputs " leaked a file handle " ). It more consistently reproduces when java is run as a " system " call from within another process.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
it should output " no leak detected "
ACTUAL -
with jdk6 it outputs " leaked a file handle " see steps to reproduce. with jre7 it always outputs " no leak detected "
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
class Bad {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); // ??
DocumentBuilder builder = factory.newDocumentBuilder();
File fromThisFile = new File( " yo " );
fromThisFile.createNewFile();
try {
builder.parse(fromThisFile);
} finally {
if(!fromThisFile.delete())
System.out.println( "
leaked a file handle " );
else
System.out.println( " no leak detected " );
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
upgrading to jre7
java version " 1.6.0_43 "
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Basically, if you parse a poorly formatted xml file using a javax.xml.parsers.DocumentBuilder instance, it will raise a org.xml.sax.SAXParseException but not " close " an internal handle to the file being parsed, which means that, depending on when the GC runs, it may or may not be, for instance, on windows, deletable for some period of time.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
If you run the code sample, for instance with jre6/jdk 6, the problem sporadically reproduces (in this snippet, it outputs " leaked a file handle " ). It more consistently reproduces when java is run as a " system " call from within another process.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
it should output " no leak detected "
ACTUAL -
with jdk6 it outputs " leaked a file handle " see steps to reproduce. with jre7 it always outputs " no leak detected "
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
class Bad {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); // ??
DocumentBuilder builder = factory.newDocumentBuilder();
File fromThisFile = new File( " yo " );
fromThisFile.createNewFile();
try {
builder.parse(fromThisFile);
} finally {
if(!fromThisFile.delete())
System.out.println( "
leaked a file handle " );
else
System.out.println( " no leak detected " );
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
upgrading to jre7
- duplicates
-
JDK-7057778 Incompatible behavior of javax.xml.parsers.SAXParser between JDK5 and 6
- Closed