unmarshalling inputstream will close it although not owner
Brought to you by:
dmegginson
Input source not belonging to sax core gets closed.
When asking to unmarshal on a given inputstream, the
stream gets a call to close(). This should not happen
since the unmarshaller did not open the stream (symetry
reason).
For example:
If you open a zipinputstream, and one zipentry is the
xml you want to parse,
you have to pass the zipinputstream, but since it gets
close(), you can't continue to read other zip entries.
see bug # 5019622 on sun's bug parade:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5019622
Logged In: NO
ZipInputStream zis = new ZipInputStream(someinputstream);
InputStream inputProxy = new FilterInputStream(zis) {
public void close() throws IOException {
System.err.println("!!! proxy input stream close() !!!!!!");
//zis.close();
}
};
ZipEntry ze = zis.getNextEntry();
JAXBContext jc1 = JAXBContext.newInstance("test.MyRoot1");
Unmarshaller reader1 = jc.createUnmarshaller();
reader1.setValidating(true);
Object root1 = reader1.unmarshal(inputProxy); //inputProxy
will get closed here
JAXBContext jc2 = JAXBContext.newInstance("test.MyRoot2");
Unmarshaller reader2 = jc.createUnmarshaller();
reader2.setValidating(true);
Object root2 = reader2.unmarshal(inputProxy); //inputProxy
will get closed here
zis.closeEntry();
zis.close();