On Wed, 22 May 2024 18:35:40 GMT, Pavel Rappo <pra...@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.

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

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

Reply via email to