Repository navigation
Conversation
A stream without a listener got no reader, so once the child wrote ~64 KB to it, it blocked in write() forever. Such streams are now redirected to DISCARD, and streams with a listener explicitly to PIPE so a launch retried after a failed start() does not keep a stale DISCARD. A throwing listener ended its reader, closing the pipe and killing the child with SIGPIPE mid-run. On the first exception from the listener (or an Error from readLine()) the failure is recorded, the listener gets no further lines, and the rest of the stream is drained as raw bytes. Once the process has exited the launch future fails with that exception as its cause, taking precedence over the exit code; a CompletionException from the listener is not wrapped again. On the timeout path the TimeoutException is kept, with the failure added as suppressed and logged. Also replace the asserts, which are disabled in production, with explicit checks: IllegalStateException after launch, NullPointerException for a null executor or variable name. An empty variable name is logged and ignored rather than rejected, since it used to be accepted.
Output was decoded with the platform charset, so on Java 17 under LANG=C terraform's box-drawing frame and any non-ASCII text became '?'. A dedicated surefire execution reruns the regression test with -Dfile.encoding=US-ASCII: under C.UTF-8 or on JDK 18+ the default charset already is UTF-8, so the default execution alone cannot catch it.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
ProcessLauncheronly started a reader for a stream that had a listener.errorListenermay be null, and the no-arg client methods use whatever listeners are set. Once the child wrote ~64 KB to an unread pipe it blocked inwrite()forever. Reproduced with 300 KB on stderr and no error listener;TF_LOG=DEBUGis a realistic trigger.LANG=Cterraform's╷ │ ╵frame and any non-ASCII text became?.Changes
Redirect.DISCARD. A stream with a listener is explicitly set toPIPE, so a launch retried after a failedstart()doesn't keep a stale DISCARD.ErrorfromreadLine():TimeoutExceptionis kept, with the listener failure added as suppressed.asserts, which are disabled in production, are replaced with explicit checks. An empty environment variable name is logged and ignored, because it used to be accepted.-Dfile.encoding=US-ASCII, since on JDK 18+ or underC.UTF-8the default run can't catch it.Caller-visible change
A throwing listener already failed the future before this change. The cause is now the listener's own exception instead of
RuntimeException("Failed to capture process output stream"), and the process runs to completion.Tests
maven:3.9-eclipse-temurin-17,--init: 44 tests in terraform-client plus the US-ASCII execution plus the sample pass, in both the default locale andLANG=C.