Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Expected error is raised only after second (identical) attempt

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
backend

Research direction

Start by reproducing testHtmlIso with HtmlDocumentBuilder, the ThrowingErrorHandler, and the Encoding ISO.html resource linked in the issue. Trace the first parse(uri) and its error-handler setup; done means the malformed or warning-producing document triggers the registered handler and throws on the first identical parse.

Written by the indexing model from the issue text.

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.

Dominant language
Java
Stars
65
Forks
29
Avg merge
11d 21h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from validator/htmlparser

All issues in validator/htmlparser

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.