{"id":"efd30a46d890e387","repo":"junit-team/junit5","slug":"error-redirecting-stdout-to-file-stdoutpath","errorCode":null,"errorMessage":"Error redirecting stdout to file: ${stdoutPath}","messagePattern":"Error redirecting stdout to file: (.+?)","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/command/StandardStreamsHandler.java","lineNumber":60,"sourceCode":"\t */\n\tpublic void redirectStandardStreams(@Nullable Path stdoutPath, @Nullable Path stderrPath) {\n\t\tif (isSameFile(stdoutPath, stderrPath)) {\n\t\t\ttry {\n\t\t\t\tPrintStream commonStream = new PrintStream(Files.newOutputStream(stdoutPath), true);\n\t\t\t\tthis.stdout = commonStream;\n\t\t\t\tthis.stderr = commonStream;\n\t\t\t}\n\t\t\tcatch (IOException ex) {\n\t\t\t\tthrow new JUnitException(\"Error redirecting stdout and stderr to file: \" + stdoutPath, ex);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (stdoutPath != null) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.stdout = new PrintStream(Files.newOutputStream(stdoutPath), true);\n\t\t\t\t}\n\t\t\t\tcatch (IOException ex) {\n\t\t\t\t\tthrow new JUnitException(\"Error redirecting stdout to file: \" + stdoutPath, ex);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (stderrPath != null) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.stderr = new PrintStream(Files.newOutputStream(stderrPath), true);\n\t\t\t\t}\n\t\t\t\tcatch (IOException ex) {\n\t\t\t\t\tthrow new JUnitException(\"Error redirecting stderr to file: \" + stderrPath, ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.stdout != null) {\n\t\t\tSystem.setOut(this.stdout);\n\t\t}\n\t\tif (this.stderr != null) {\n\t\t\tSystem.setErr(this.stderr);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-console/src/main/java/org/junit/platform/console/command/StandardStreamsHandler.java#L42-L78","documentation":"Error \"Error redirecting stdout to file: ${stdoutPath}\" thrown in junit-team/junit5.","triggerScenarios":"Thrown at junit-platform-console/src/main/java/org/junit/platform/console/command/StandardStreamsHandler.java:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}