j-users,
 
I'm finding that Xerces is closing a user managed InputStream which I'm not
expecting.
 
Am I correct in thinking this is a bug and I should proceed with submitting
a JIRA?
 
The following JUnit test demonstrates this:
 
/**
  * Tests that a simple build does not closed the original (user managed)
stream.
  * 
  * @throws Exception
  *             if there were any unexpected errors that occur.
  */
public void testBuildWithErrorsDoesNotCloseStream() throws Exception {
  byte[] XML_BYTES = "<A>a</A>".getBytes();
  XMLReader reader = XMLReaderFactory.createXMLReader();
  reader.parse(new InputSource(new
NonClosableByteArrayInputStream(XML_BYTES)));
}
 

/**
  * Throws an Assertion failure should close be called.
  */
private static class NonClosableByteArrayInputStream extends
ByteArrayInputStream {
 
  public NonClosableByteArrayInputStream(byte[] buf_) {
    super(buf_);
  }
 
  public void close() throws IOException {
    fail("Not expecting close() to be called.");
  }
}
 
junit.framework.AssertionFailedError: Not expecting close() to be called.
 at junit.framework.Assert.fail(Assert.java:47)
 at XercesTest$NonClosableByteArrayInputStream.close(XercesTest.java:203)
 at 
org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.close(Unknown
Source)
 at org.apache.xerces.impl.io.UTF8Reader.close(Unknown Source)
 at org.apache.xerces.impl.XMLEntityManager.closeReaders(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.cleanup(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
 at XercesTest.testBuildDoesNotCloseStream(XercesTest.java:178)

Regards,
 
Jeff Sinclair



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to