languagetool-org/languagetool · error · RuntimeException

Timeout (" + TIMEOUT_MILLIS + "ms) exhausted getting NER res

Error message

Timeout (" + TIMEOUT_MILLIS + "ms) exhausted getting NER results

What it means

Timeout guard around the HTTP POST to the external NER service: the request task submitted to the executor did not finish within TIMEOUT_MILLIS, so no NER results are available. Fires on slow or unresponsive NER servers (e.g. under load or network issues) — the call fails rather than blocking indefinitely.

Source

Thrown at languagetool-core/src/main/java/org/languagetool/tagging/ner/NERService.java:101

  }

  private static String postTo(URL url, String encodedPostData, Map<String, String> properties) {
    try {
      Future<?> future = executorService.submit(() -> {
        URLConnection connection = url.openConnection();
        for (Map.Entry<String, String> entry : properties.entrySet()) {
          connection.setRequestProperty(entry.getKey(), entry.getValue());
        }
        connection.setDoOutput(true);
        try (Writer writer = new OutputStreamWriter(connection.getOutputStream(), UTF_8)) {
          writer.write(encodedPostData);
          writer.flush();
          return StringTools.streamToString(connection.getInputStream(), "UTF-8");
        }
      });
      return (String) future.get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    } catch (TimeoutException e) {
      throw new RuntimeException("Timeout (" + TIMEOUT_MILLIS + "ms) exhausted getting NER results", e);
    } catch (InterruptedException | ExecutionException e) {
      throw new RuntimeException(e);
    }
  }

  @NotNull
  List<Span> parseBuffer(String buffer) {
    String[] values = buffer.trim().split(" ");
    if (buffer.trim().contains("\n")) {
      logger.warn("Got multiple lines to read from external NER, this should not happen: '" + buffer.trim() + "'" );
    }
    List<Span> res = new ArrayList<>();
    for (String value : values) {
      if (value.isEmpty()) {
        continue;
      }
      int slash3 = getLastSlashFrom(value, value.length()-1);
      int slash2 = getLastSlashFrom(value, slash3-1);

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Check the NER service endpoint's health, latency, and network reachability
  2. Increase TIMEOUT_MILLIS if legitimate processing takes longer
  3. Add retry logic or return partial/no-NER results gracefully when the service is slow
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tagging/ner/NERService.java:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/c39929e2021ae338. Report an issue: GitHub.