{"record":{"id":"291bc8c69af087c3","repo":"quarkusio/quarkus","slug":"error-reading-stream","errorCode":null,"errorMessage":"Error reading stream.","messagePattern":"Error reading stream\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/OutputFilter.java","lineNumber":29,"sourceCode":"public class OutputFilter implements Function<InputStream, Runnable> {\n    private final StringBuilder builder = new StringBuilder();\n    private static final Logger log = Logger.getLogger(OutputFilter.class);\n\n    @Override\n    public Runnable apply(InputStream is) {\n        return () -> {\n\n            try (InputStreamReader isr = new InputStreamReader(is);\n                    BufferedReader reader = new BufferedReader(isr)) {\n\n                for (String line = reader.readLine(); line != null; line = reader.readLine()) {\n                    builder.append(line);\n                }\n            } catch (IOException e) {\n                if (e.getMessage().contains(\"Stream closed\")) {\n                    log.warn(\"Stream is closed, ignoring and trying to continue\");\n                } else {\n                    throw new RuntimeException(\"Error reading stream.\", e);\n                }\n            }\n        };\n    }\n\n    public String getOutput() {\n        return builder.toString();\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/OutputFilter.java#L11-L39","documentation":"OutputFilter reads a process/log stream line by line; if reading throws an IOException other than the tolerated 'Stream closed' case, it wraps it in a RuntimeException 'Error reading stream.' This usually indicates the underlying stream broke unexpectedly rather than a normal end-of-stream.","triggerScenarios":"The monitored process is killed abruptly or the pipe is closed mid-read; an IOException occurs while BufferedReader.readLine() whose message does not contain 'Stream closed'.","commonSituations":"Forked build/test processes dying unexpectedly; platform pipe breakage in CI; a child process terminating while Quarkus still reads its output.","solutions":["Investigate the cause (the wrapped IOException is attached) — check the child process logs and exit code.","Ensure the process whose output is filtered is not being forcibly killed before it finishes.","Catch the RuntimeException around the augmentation/run call and handle it if reading child output is best-effort in your tooling."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    augmentor.run();\n} catch (RuntimeException e) {\n    if (\"Error reading stream.\".equals(e.getMessage())) {\n        log.warn(\"Child output stream broke; cause: \" + e.getCause(), e);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Ensure child processes are not killed mid-run (check CI timeouts / OOM killers).","Capture child process exit codes and logs to diagnose abrupt termination.","Treat stream filtering as best-effort in tooling and degrade gracefully."],"tags":["io","process","stream","exception"],"backgroundTag":"stream-read-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}