RFR: 8353698: Output of Simple Web Server is garbled if the console's encoding is not UTF-8 [v3]

Alan Bateman alanb at openjdk.org
Mon Apr 7 09:35:58 UTC 2025


On Mon, 7 Apr 2025 09:25:08 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> src/jdk.httpserver/share/classes/sun/net/httpserver/simpleserver/JWebServer.java line 66:
>> 
>>> 64:         setMaxConnectionsIfNotSet();
>>> 65: 
>>> 66:         int ec = SimpleFileServerImpl.start(new PrintWriter(System.out, true), "jwebserver", args);
>> 
>> I think you are looking for stdout.encoding here.
>
> Are you suggesting changing this line @AlanBateman? The API doc of `PrintWriter(OutputStream, boolean)` says:
> 
>      * Creates a new PrintWriter from an existing OutputStream.  This
>      * convenience constructor creates the necessary intermediate
>      * OutputStreamWriter, which will convert characters into bytes using
>      * the default charset, or where {@code out} is a {@code PrintStream},
>      * the charset used by the print stream.
> 
> Isn't this what we want here?

Just paging in the changes we did in JDK 10. They are the same thing as System.out will be created to use stdout.encoding. So you can ignore my comment.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24437#discussion_r2030855966


More information about the net-dev mailing list