-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366261: Provide utility methods for sun.security.util.Password #26973
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
Conversation
|
👋 Welcome back naoto! A progress list of the required criteria for merging this PR into |
|
@naotoj 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 195 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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
| private static final boolean istty = istty(); | ||
| static final int TTY_STDIN_MASK = 0x00000001; | ||
| static final int TTY_STDOUT_MASK = 0x00000002; | ||
| static final int TTY_STDERR_MASK = 0x00000004; |
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 recommend marking these fields as @Native.
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.
Good point. Fixed
| public static Optional<JdkConsoleImpl> passwordConsole() { | ||
| return INSTANCE.orElseSet(() -> { | ||
| // If there's already a proper console, throw an exception | ||
| if (System.console() != null) { |
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.
Since this initializes the console, this means the console can only be available when there is no provider and stdin is tty, but stdout is not. Is this intended? (In other words, should we make System.console() lazy, as it is initialized with java.io.Console as Console.cons?)
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.
Yes, this is intentional. This entry is dedicated solely to Password, and it is expected that System.console() will be called beforehand so that normal cases (without redirection) are handled by System.console(). The null check is a safeguard to prevent future Password refactoring from invoking this method without first calling System.console() in the standard case.
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.
It would be good to add comments that describes this precondition. We've all been discussing it so we "know" what it's doing and why. But other readers, like @liach, and future maintainers of the Password class, will know what the requirements are. (EDIT: I meant "will need to know" but I think you understood.)
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.
It would be good to add comments that describes this precondition.
Good point. Explained it in its comment.
Co-authored-by: Francesco Andreuzzi <andreuzzi.francesco@gmail.com>
| /** | ||
| /* | ||
| * @test | ||
| * @bug 8295803 8299689 8351435 8361613 |
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.
Should 8366261 be included?
| new JdkConsoleImpl( | ||
| Charset.forName(StaticProperty.stdinEncoding(), UTF_8.INSTANCE), | ||
| Charset.forName(StaticProperty.stdoutEncoding(), UTF_8.INSTANCE))) : | ||
| Optional.empty(); |
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.
(Finally getting back to this.)
The code returns an Optional containing a JdkConsoleImpl instance, or an empty Optional. However the comment above says it returns a JdkConsoleImpl instance or null. Which do we want it to be? Either is OK, but the comment should agree with the code.
I think @wangweij might want to weigh in here since his code will be calling this.
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.
Ah, yes. Comment does not align with the code. I am fine either way too.
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.
Either is OK. Optional sounds more modern and forces me to consider the empty case.
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.
Fixed the comment to agree with the code
stuart-marks
left a 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.
Looks good.
| }); | ||
| } | ||
|
|
||
| // Dedicated entry for sun.security.util.Password. |
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.
To be more clear, I suggest this comment:
// Dedicated entry for sun.security.util.Password when stdout is redirected.
// This method strictly avoids producing any output by using noNewLine = true
// and an empty format string.
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.
Thanks. Modified the comment as suggested
|
Thanks for the comment change. Approved. |
stuart-marks
left a 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.
Not sure whether I need to re-approve, but I will anyway!
|
Thanks for the reviews! |
|
Going to push as commit a12e9fc.
Your commit was automatically rebased without conflicts. |
Providing a couple of utility methods using the "built-in"
Consoleimplementation to support tools that require password input, such askeytool, ensuring they work even when std0ut is redirected.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26973/head:pull/26973$ git checkout pull/26973Update a local copy of the PR:
$ git checkout pull/26973$ git pull https://git.openjdk.org/jdk.git pull/26973/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26973View PR using the GUI difftool:
$ git pr show -t 26973Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26973.diff
Using Webrev
Link to Webrev Comment