This is an automated email from the ASF dual-hosted git repository. rmaucher pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 68937ef36f8d9c4819d4f236eaa8bc2e1e8c73a6 Author: opencode <[email protected]> AuthorDate: Tue Oct 20 13:34:57 2026 +0200 Do not swallow write failures when converting text files to HTML The converted pages were written through a PrintWriter, which swallows IOExceptions raised by the underlying stream. A mid-stream write failure such as a full disk was therefore silently ignored and the build completed successfully with a truncated or empty .html file. Write directly through an OutputStreamWriter instead, so write and close failures propagate and are reported as a BuildException by the existing error handling in execute(). The produced output is unchanged. --- java/org/apache/tomcat/buildutil/Txt2Html.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/java/org/apache/tomcat/buildutil/Txt2Html.java b/java/org/apache/tomcat/buildutil/Txt2Html.java index 60a3c46ddd..a08dd9c6f8 100644 --- a/java/org/apache/tomcat/buildutil/Txt2Html.java +++ b/java/org/apache/tomcat/buildutil/Txt2Html.java @@ -23,7 +23,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.PrintWriter; +import java.io.Writer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -132,11 +132,10 @@ public class Txt2Html extends Task { // Open files: try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(from), SOURCE_ENCODING))) { - try (PrintWriter out = - new PrintWriter(new OutputStreamWriter(new FileOutputStream(to), StandardCharsets.UTF_8))) { + try (Writer out = new OutputStreamWriter(new FileOutputStream(to), StandardCharsets.UTF_8)) { // Output header: - out.print("<!DOCTYPE html><html><head><meta charset=\"UTF-8\" />" + + out.write("<!DOCTYPE html><html><head><meta charset=\"UTF-8\" />" + "<title>Source Code</title></head><body><pre>"); // Convert, line-by-line: @@ -157,11 +156,11 @@ public class Txt2Html extends Task { result.append(c); } } - out.print(result.toString() + LINE_SEPARATOR); + out.write(result.toString() + LINE_SEPARATOR); } // Output footer: - out.print("</pre></body></html>"); + out.write("</pre></body></html>"); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
