8322417: Console read line with zero out should zero out when throwing exception

Reviewed-by: mbaesken, stuefe, naoto
This commit is contained in:
Goetz Lindenmaier 2023-12-20 08:01:08 +00:00
parent 7db69e6a12
commit 2f917bff5c

View file

@ -119,9 +119,18 @@ public final class JdkConsoleImpl implements JdkConsole {
else else
ioe.addSuppressed(x); ioe.addSuppressed(x);
} }
if (ioe != null) if (ioe != null) {
java.util.Arrays.fill(passwd, ' ');
try {
if (reader instanceof LineReader lr) {
lr.zeroOut();
}
} catch (IOException x) {
// ignore
}
throw ioe; throw ioe;
} }
}
pw.println(); pw.println();
} }
} }