languagetool-org/languagetool · error · RuntimeException

IOException while synthesizing suggestions (о vocative)

Error message

IOException while synthesizing suggestions (о vocative)

What it means

In the vocative («о» + name) branch of TokenAgreementPrepNounRule.createRuleMatch(), the rule synthesizes vocative forms of the following token and wraps IOException in RuntimeException. The break-in-loop catch pattern means the first synthesis failure aborts suggestion generation for the whole match.

Source

Thrown at languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/TokenAgreementPrepNounRule.java:579

      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    else if( state.prepTokenReadings.getCleanToken().equalsIgnoreCase("о") ) {
      for(AnalyzedToken token: tokenReadings.getReadings()) {
        if( PosTagHelper.hasPosTag(token, NOUN_ANIM_V_NAZ_PATTERN) ) {
          msg += ". Можливо, тут «о» — це вигук і потрібно кличний відмінок?";
          try {
            String newPostag = token.getPOSTag().replace("v_naz", "v_kly");
            String[] synthesized = synthesizer.synthesize(token, newPostag, false);
            for (String string : synthesized) {
              if( ! string.equals(token.getToken()) && ! suggestions.contains(string) ) {
                suggestions.add( string );
              }
            }
            break;
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
      }
    }
    else if( PosTagHelper.hasPosTagStart(tokens[i-1], "adv")) {
      String mergedToken = state.prepTokenReadings.getCleanToken() + tokens[i-1].getCleanToken();
      List<AnalyzedTokenReadings> mergedTagged = ukrainian.getTagger().tag(Arrays.asList(mergedToken));
      if( PosTagHelper.hasPosTagStart(mergedTagged.get(0), "adv") ) {
        msg += ". Можливо, прийменник і прислівник мають бути одним словом?";
//        suggestions.add(mergedToken);
      }
      
    }

    RuleMatch potentialRuleMatch = new RuleMatch(this, sentence, tokenReadings.getStartPos(), tokenReadings.getEndPos(), msg, getShort());

    potentialRuleMatch.setSuggestedReplacements(suggestions);

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Inspect the wrapped IOException (getCause()) to find the failing resource or disk issue.
  2. Verify/repair the Ukrainian synthesizer dictionary in the deployed artifact.
  3. Move synthesis into a helper that returns an empty array on IOException so the rule can still flag the vocative issue without inflected forms.
  4. Check file permissions and disk health on the host running LanguageTool.
  5. Add a CI test exercising the «о» vocative path to detect dictionary problems early.

Example fix

// before
} catch (IOException e) {
  throw new RuntimeException(e);
}
// after
} catch (IOException e) {
  LOG.warn("vocative synthesis failed", e);
  break; // skip synthesized vocative suggestions for this token
}
Defensive patterns

Strategy: try-catch

Validate before calling

try {
  synthesizer.synthesize(new AnalyzedToken("Іване", "noun:anim:v_kly", "Іван"), "noun:anim:v_naz", true);
} catch (IOException e) { LOG.error("Vocative synthesis unavailable", e); }

Try / catch

try { matches = rule.match(tokens); }
catch (RuntimeException e) {
  if (e.getCause() instanceof IOException) { LOG.warn("vocative synthesis failed", e); /* flag issue without suggestions */ }
  else throw e;
}

Prevention

When it happens

Trigger: Token «о» precedes a noun matching the animate nominative pattern; the rule synthesizes vocative inflections and the synthesizer's dictionary read throws IOException.

Common situations: Dictionary resource corruption, unreadable files (permissions), or storage-level I/O failures in the deployment environment; broken language-module builds.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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