Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

Commit

Permalink
8322417: Console read line with zero out should zero out when throwin…
Browse files Browse the repository at this point in the history
…g exception

8322772: Clean up code after JDK-8322417

Reviewed-by: mbaesken
Backport-of: 2f917bff5cbb71dccd70960f563ca1a05d109fda
  • Loading branch information
RealCLanger committed Jan 9, 2024
1 parent 75f52ea commit 512cd87
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ public char[] readPassword(String fmt, Object ... args) {
else
ioe.addSuppressed(x);
}
if (ioe != null)
if (ioe != null) {
Arrays.fill(passwd, ' ');
try {
if (reader instanceof LineReader lr) {
lr.zeroOut();
}
} catch (IOException x) {
// ignore
}
throw ioe;
}
}
pw.println();
}
Expand Down

1 comment on commit 512cd87

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.