RFR: 8332084: Ensure JdkConsoleImpl.restoreEcho visibility in a shutdown hook [v8]

Pavel Rappo prappo at openjdk.org
Wed May 22 21:09:02 UTC 2024


On Wed, 22 May 2024 19:32:07 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> > I might be confused, but what if the shutdown hook completes and then some application thread enters `readPassword`. If that thread manages to turn off echo before all other shutdown hooks complete, it might never execute `finally`, hence a race.
> 
> Yes, that is possible. However I would say that it is equally unlikely as an app installs a shutdown hook with readPassword(), so I think this is OK too. BTW, if an app issues `Runtime.halt()` while `readPassword()` is waiting, then those shutdown hooks aren't even executed, thus ends up in not restoring the echo without a race, which I think is OK as well.

Okay, but can we call it a best-effort attempt to restore the echo state? I guess, it is a judgement call.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19184#issuecomment-2125744051


More information about the core-libs-dev mailing list