RFR: 8332065: Calling readLine(null...) or readPassword(null...) on System.console() hangs jshell
Pavel Rappo
prappo at openjdk.org
Tue May 28 11:13:04 UTC 2024
On Tue, 28 May 2024 09:08:01 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> JShell supports using `System.console()` when running snippets in a separate VM (the agent). This works by re-sending requests from the agent to the main process.
>
> For some `Console` methods, like `readLine`, this has two phases - first a prompt is sent, and then input is received. But, there's a mistake on the way this is handled: the protocol starts a "transaction", and then goes to process the prompt. And if the prompt processing fails, the "transaction" never ends, and the communication locks.
>
> The proposal here is to do the prompt processing before starting the communication, so if it fails, there are no problems with the communication.
Marked as reviewed by prappo (Reviewer).
test/langtools/jdk/jshell/ConsoleTest.java line 194:
> 192: assertEval("System.console().readPassword(null)", DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, chain(added(Status.VALID), null, EvalException.class));
> 193: assertEval("System.console().readLine(\"%d\", \"\")", DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, chain(added(Status.VALID), null, EvalException.class));
> 194: assertEval("System.console().readPassword(\"%d\", \"\")", DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, chain(added(Status.VALID), null, EvalException.class));
Right: `IllegalFormatConversionException` would cause the same hang.
-------------
PR Review: https://git.openjdk.org/jdk/pull/19420#pullrequestreview-2082461840
PR Review Comment: https://git.openjdk.org/jdk/pull/19420#discussion_r1617036747
More information about the kulla-dev
mailing list