|
Ok, it comes all down to whether this piece of code is valid:
public String getSchemaVersion(String resourceName, InputStream xmlInputStream) {
Contracts.assertNotNull( xmlInputStream, MESSAGES.parameterMustNotBeNull( "xmlInputStream" ) );
xmlInputStream.mark( READ_LIMIT );
try {
XMLEventReader xmlEventReader = createXmlEventReader( xmlInputStream );
StartElement rootElement = getRootElement( xmlEventReader );
return getVersionValue( rootElement );
}
catch ( XMLStreamException e ) {
throw log.getUnableToDetermineSchemaVersionException( resourceName, e );
}
finally {
try {
xmlInputStream.reset();
}
catch ( IOException e ) {
throw log.getUnableToResetXmlInputStreamException( resourceName, e );
}
}
}
The idea being is to read the version information specified in the XML start element in order to determine prior to parsing the rest of the document which schema should be used for validation. Our code checks whether the input streams supports mark&reset and if so, sets a mark prior to reading the version and then calls resets after reading the version, so that later on the unmarshaller can read the whole input stream again. If the input stream does not support mark&reset it gets wrapped into a BufferedInputStream which does support it. IMO this usage looks ok, but apparently the IBM JVM thinks differently in this case.
|