Skip to content
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

8332084: Ensure JdkConsoleImpl.restoreEcho visibility in a shutdown hook #19184

Closed
wants to merge 12 commits into from
16 changes: 9 additions & 7 deletions src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public char[] readPassword(String fmt, Object ... args) {
if (reader instanceof LineReader lr) {
lr.zeroOut();
}
} catch (IOException x) {
} catch (IOException _) {
// ignore
}
throw ioe;
Expand All @@ -148,14 +148,16 @@ private void installShutdownHook() {
false /* only register if shutdown is not in progress */,
new Runnable() {
public void run() {
try {
if (restoreEcho) {
echo(true);
}
} catch (IOException x) { }
synchronized(readLock) {
try {
if (restoreEcho) {
echo(true);
}
} catch (IOException _) { }
}
}
});
} catch (IllegalStateException e) {
} catch (IllegalStateException _) {
// shutdown is already in progress and readPassword is first used
// by a shutdown hook
}
Expand Down