On Mon, 13 May 2024 21:32:18 GMT, Naoto Sato <na...@openjdk.org> wrote:

>> Making sure `restoreEcho` correctly reflects the state in the shutdown 
>> thread, which differs from the application's thread that issues the 
>> `readPassword()` method.
>
> Naoto Sato has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Addresses a review comment

Thanks, Stuart.
The shutdown hook in question is in the `java.base`'s JdkConsole 
implementation, so the save/restore responsibility is already pushed down to 
each provider. Thinking that `java.base`'s implementation is now non-default, 
and the possibility of the race condition is quite low, I now think making 
`restoreEcho` as volatile (the current PR) is the most practical solution, 
unless we could find a reasonably simple way to resolve the contention.
BTW, the `java.base`'s shutdown hook has the special slot `0`, which is 
guaranteed to be called first: 
https://github.com/openjdk/jdk/blob/e91492ab4333c61f39b50eb428fa932131a5b908/src/java.base/share/classes/java/lang/Shutdown.java#L47

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

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

Reply via email to