-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8353698: Output of Simple Web Server is garbled if the console's encoding is not UTF-8 #24437
Conversation
👋 Welcome back tabata-d! A progress list of the required criteria for merging this PR into |
@tabata-d This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 94 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@djelinski, @dfuch) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for addressing the issues!
|
Hi, it's not completely clear to me why |
@dfuch Thank you for your comment.
No, it's related. For example, after this modification, if you run
This is the same in jtreg tests, so if you test it on Japanese Windows, it will fail. |
Upon reconsideration, these tests were failing on Japanese OS even before the fix. |
That's what I suspected. I just wanted to make sure that needing the locale was not a side effect of your changes. I'm good with the changes you're proposing. Please hold on integrating for a bit - I would like to verify that there no regression in our CI. |
@@ -65,7 +63,7 @@ public static void main(String... args) { | |||
setMaxReqTime(); | |||
setMaxConnectionsIfNotSet(); | |||
|
|||
int ec = SimpleFileServerImpl.start(new PrintWriter(System.out, true, UTF_8), "jwebserver", args); | |||
int ec = SimpleFileServerImpl.start(new PrintWriter(System.out, true), "jwebserver", args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are looking for stdout.encoding here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My tests came back green. Thanks for fixing this issue!
Thank you for the reviews! |
LGTM also. |
/sponsor |
Going to push as commit f7fa05f.
Your commit was automatically rebased without conflicts. |
@Michael-Mc-Mahon @tabata-d Pushed as commit f7fa05f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The output
jwebserver
andjava -m jdk.httpserver
uses UTF-8 encoding. Therefore, if the console encoding is not set to UTF-8 (for example, MS932 on Japanese Windows), garbled characters may appear.Since System.out knows the console's encoding, there's no need to specify it again with PrintWriter constructor.
The output
jwebserver
andjava -m jdk.httpserver
is localized in Japanese, German, and Chinese. This bug only occurs in these localized languages, so I haven't added any tests.I have confirmed that the output of the two commands is not garbled in the default command prompts of both Japanese Windows and English Windows.
I tested jdk/com/sun/net/httpserver/simpleserver on English Windows, and all tests passed. However, when running on Japanese Windows, some tests failed because they expected output only in English.
I modified the tests so that
jwebserver
andjava -m jdk.httpserver
within the tests are executed with an English locale. After this modification, all tests passed on Japanese Windows.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24437/head:pull/24437
$ git checkout pull/24437
Update a local copy of the PR:
$ git checkout pull/24437
$ git pull https://git.openjdk.org/jdk.git pull/24437/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24437
View PR using the GUI difftool:
$ git pr show -t 24437
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24437.diff
Using Webrev
Link to Webrev Comment