-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
The following code throws only after second call to parse, instead of throwing upon first call as expected.
private static final class ThrowingErrorHandler implements ErrorHandler {
@Override
public void warning(SAXParseException exception) throws SAXParseException {
LOGGER.info("Warning while processing.", exception);
throw exception;
}
@Override
public void fatalError(SAXParseException exception) throws SAXParseException {
LOGGER.info("Fatal while processing.", exception);
throw exception;
}
@Override
public void error(SAXParseException exception) throws SAXParseException {
LOGGER.info("Error while processing.", exception);
throw exception;
}
}
@Test
public void testHtmlIso() throws Exception {
String uri = "https://github.com/oliviercailloux/JARiS/raw/refs/heads/main/src/test/resources/io/github/oliviercailloux/jaris/xml/Html/Encoding%20ISO.html";
HtmlDocumentBuilder builder = new HtmlDocumentBuilder();
builder.setErrorHandler(new ThrowingErrorHandler());
// logs no warning, does not throw
builder.parse(uri);
builder.setErrorHandler(new ThrowingErrorHandler());
// logs a warning then throws
builder.parse(uri);
}Explanation
The document is supposed to raise a warning when parsed, and given the registered ThrowingErrorHandler, it is supposed to log then throw an exception when parsing. But the first parse completes without logging or throwing anything. Only the second one does.
Metadata
Metadata
Assignees
Labels
No labels