Skip to content

Forked executor blocks until caller-supplied stdin reaches EOF #50

Description

@slachiewicz

Affected version

1.0.0

Bug description

ForkedMavenExecutor cannot be given an interactive stdin. ProcessBuilderExecutorSupport.pump() starts three pump threads and returns a CountDownLatch(3); execute() then does latch.await() (or await(timeout)) before reading the exit code (ProcessBuilderExecutorSupport.java:83-98,118-160). The stdin pump runs IOTools.transferTo(stdIn, process.getOutputStream()), which blocks in read() on the caller's stream until EOF. With stdIn(System.in):

  • without a timeout, execute() never returns after the child exits, because the console never reaches EOF;
  • with a timeout, await times out and the child is destroyForcibly()-ed, so a build that was already finished is reported as Process timeout.

This is exactly the request maven-invoker's setInputStream(System.in) serves in maven-release's InvokerMavenExecutor (interactive prompts from the forked build, such as a GPG passphrase) and in maven-gpg-plugin's tests, so those two consumers cannot migrate to maven-executor until the pump either stops when the process exits or the executor waits on the process first and then only on the stdout/stderr pumps.

Proposal: waitFor() the process, then await the two output pumps, and interrupt or abandon the stdin pump; do not count it in the latch. Related: #45 (streams closed by the pumps) and the runtime section of #49.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions