{"record":{"id":"5e87d3c08241a1ac","repo":"languagetool-org/languagetool","slug":"ioexception-while-writing-debug-log-line","errorCode":null,"errorMessage":"IOException while writing debug log line","messagePattern":"IOException while writing debug log line","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/uk/src/main/java/org/languagetool/tagging/uk/CompoundDebugLogger.java","lineNumber":71,"sourceCode":"      return;\n\n    debug_tagged_write(guessedCompoundTags, compoundTaggedDebugWriter);\n\n    guessedCompoundTags.stream().map(t -> t.getLemma()).collect(Collectors.toSet()).forEach( w ->\n        logLine(compoundTaggedLemmaDebugWriter, w)\n    );\n  }\n\n  private static int cnt = 0;\n  public void logLine(BufferedWriter writer, String word) {\n    if( writer == null )\n      return;\n    \n    try {\n      writer.append(word).append('\\n');\n      if( ++cnt % 10 == 0) writer.flush();\n    } catch (IOException e) {\n      throw new RuntimeException(e);\n    }\n  }\n\n  void logUnknownCompound(String word) {\n    logLine(compoundUnknownDebugWriter, word);\n  }\n  \n  private void debug_tagged_write(List<AnalyzedToken> analyzedTokens, BufferedWriter writer) {\n    if( analyzedTokens.isEmpty()\n        || analyzedTokens.get(0).getLemma() == null \n        || analyzedTokens.get(0).getToken().trim().isEmpty() )\n      return;\n\n    try {\n      String prevToken = \"\";\n      String prevLemma = \"\";\n      for (AnalyzedToken analyzedToken : analyzedTokens) {\n        String token = analyzedToken.getToken();","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/uk/src/main/java/org/languagetool/tagging/uk/CompoundDebugLogger.java#L53-L89","documentation":"CompoundDebugLogger.logLine writes a word to an optional debug file writer for Ukrainian compound-word analysis. If the underlying BufferedWriter throws an IOException (disk full, closed stream, permissions), it is wrapped in a RuntimeException with this message. This is a debug-only aid, so failures abort the tagging pipeline rather than being logged.","triggerScenarios":"Calling logTaggedCompound or logUnknownCompound while the debug writer's target file is unwritable (missing directory, no permissions, disk full) or already closed.","commonSituations":"Running LanguageTool Ukrainian tests with compound debug logging enabled on a read-only filesystem or a temp directory that was cleaned up mid-run.","solutions":["Check that the debug output directory exists and is writable before enabling compound debug logging","Ensure the writer is not closed before all log calls finish","Inspect the wrapped IOException cause for the real filesystem error","Disable compound debug logging if you do not need it"],"exampleFix":"// before\n} catch (IOException e) {\n  throw new RuntimeException(e);\n}\n// after\n} catch (IOException e) {\n  LOGGER.warn(\"Failed to write compound debug log line\", e);\n}","handlingStrategy":"try-catch","validationCode":"File dbg = new File(debugPath);\nif (!dbg.getParentFile().canWrite() || !dbg.getParentFile().exists()) {\n    throw new IllegalStateException(\"Debug dir missing/unwritable: \" + debugPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n    logger.logUnknownCompound(word);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        LOGGER.warn(\"compound debug logging disabled\", e.getCause());\n    } else throw e;\n}","preventionTips":["Only enable compound debug logging in controlled test environments","Pre-create and verify the debug output directory","Keep writer lifecycle (open/close) scoped to the logging session","Monitor free disk space in CI"],"tags":["io","java","logging","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}