Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while closing input stream from client #5566

Open
oehme opened this issue May 29, 2018 · 7 comments
Open

Error while closing input stream from client #5566

oehme opened this issue May 29, 2018 · 7 comments
Labels
a:bug in:console output progress tty mintty cygwin cli in:logging

Comments

@oehme
Copy link
Contributor

oehme commented May 29, 2018

Just got this while running gradle sanityCheck on our own repo, but could not reproduce it.

Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.EOFException: No input provided for project
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
        at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:125)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.EOFException: No input provided for project
        at org.apache.tools.ant.Project.defaultInput(Project.java:1304)
        at org.apache.tools.ant.Project.demuxInput(Project.java:1324)
        at org.apache.tools.ant.DemuxInputStream.read(DemuxInputStream.java:71)
        at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:96)
@oehme oehme added from:member in:logging a:bug in:console output progress tty mintty cygwin cli labels May 29, 2018
@UdoW
Copy link

UdoW commented Feb 28, 2019

I got this when stopping Eclipse which includes a Buildship 3.0.1 where I ran a task with the help of the tooling API:

Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.IOException: Input Stream Closed at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61) at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41) at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:125) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: Input Stream Closed at org.eclipse.ui.console.IOConsoleInputStream.available(IOConsoleInputStream.java:271) at org.eclipse.ui.console.IOConsoleInputStream.read(IOConsoleInputStream.java:98) at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:96)

@Vampire
Copy link
Contributor

Vampire commented Aug 7, 2019

The one from Eclipse is slightly different.
I reproduced the one orinally reported here by @oehme.
And I can even relatively reliably reproduce it with 4.10.3.

I just refactored a custom task to use the worker api.
Before in the task directly I did use the Gradle AntBuilder.
But as I'm now in the worker and #2678 is not done yet I use the Groovy AntBuilder directly.

I have the daemon currently disabled locally because I have a slight RAM shortage and build many different projects with different Gradle versions, so the daemons killed it finally.
I think this might be relevant for reproducing.

Now my build also started to show this error and quite regular, after the build already finished successfully:

Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.EOFException: No input provided for project
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
        at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:125)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.EOFException: No input provided for project
        at org.apache.tools.ant.Project.defaultInput(Project.java:1304)
        at org.apache.tools.ant.Project.demuxInput(Project.java:1324)
        at org.apache.tools.ant.DemuxInputStream.read(DemuxInputStream.java:71)
        at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:96)
        ... 1 more

I tracked it down a bit.
I think it is Groovy AntBuilder with saveStreams not disabled fighting with Gradle for who will provide System.in.

As far as I understood the code, AntBuilder (with the option enabled which is the default) remembers before the task is executed the in and out streams and replaces them by demuxing streams, the relevant here is DemuxInputStream for System.in if it is not instanceof DemuxInputStream already.
After the task is finished executing, the original streams are put back in place.

Now in Gradle we have the ContinuousBuildActionExecuter.
This, after the build is already completely finished and written to be successfull calls createCancellableOperationManager in the finally that wraps delegate.execute.
This now replaces System.in if it is not instanceof DisconnectableInputStream by a new DisconnectableInputStream that wraps System.in which strangely still is the DemuxInputStream.

The DisconnectableInputStream continuously reads from the wrapped input stream in a daemon thread, but the wrapped dmux inputstream forwards the demuxing to the Ant project.
The Ant project has no current task, as the task is already finished and the project has no default input stream which then throws this shown exception.

But this is most probably a threading issue.
I added some non-pausing but logging breakpoints to get some info and a sequence of events and that was enough to make it not happen anymore, at least in the last 20 tries.
When I remove the logging in the breakpoints and only log the "breakpoint hit" message, it happens again.

One way to work-around the problem (from what I have seen, but as the problem is intermittent, not sure) is to set saveStreams to false on the AntBuilder. This will then not capture the inputs and outputs and forward them to the Ant logging system, but forward them to whatever is capturing already.

Another work-around (from what I have seen so far) is to set the .project.defaultInputStream = System.in on the ant builder, as then the default input stream is not null and thus the exception does not happen.

A correct fix might maybe be to do the createCancellableOperationManager call in the ContinuousBuildActionExecuter before the delegate.execute call.

@Vampire
Copy link
Contributor

Vampire commented Aug 8, 2019

Hm, .project.defaultInputStream = System.in is not optimal either.
It fixes the problem, but then the demux input streams stack upon each other when executing tasks in parallel for example using the worker api which then produces like

      [jcr]       [jcr]       [jcr] The 'lineSpacing' attribute is deprecated. Use the <paragraph> tag instead.

instead of

      [jcr] The 'lineSpacing' attribute is deprecated. Use the <paragraph> tag instead.

Ah, wait, that makes no sense, the workaround is only about input stream and what is stacked are output streams, so I think I prefer the ant.saveStreams = false work around as it works-around this problem and also the demux output stream stacking. Would be interesting if it were better if the Gradle Ant Builder could be used in the worker.

@stale
Copy link

stale bot commented Oct 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added stale and removed stale labels Oct 6, 2020
@deanhiller
Copy link

deanhiller commented Sep 12, 2021

I see this in gradle 7.1.1 and in 7.2 every time we "./gradlew build" from root of https://github.com/deanhiller/webpieces

It is not impacting the build BUT developers keep looking into it thinking that is what broke the build :( as they do not know it is a red herring.

@martinda
Copy link
Contributor

martinda commented Dec 23, 2022

We have a gradle task that dispatches jobs to jenkins and we wait for the jenkins build to complete before moving on to the next task, and we get a very similar issue. Here is the stacktrace:

Received exception trying to forward client input.
java.io.IOException: Pipe closed
	at java.base/java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
	at java.base/java.io.PipedInputStream.receive(PipedInputStream.java:226)
	at java.base/java.io.PipedOutputStream.write(PipedOutputStream.java:150)
	at java.base/java.io.OutputStream.write(OutputStream.java:127)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$1.onInput(ForwardClientInput.java:54)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$StdinQueue.doHandleCommand(DefaultDaemonConnection.java:299)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$StdinQueue.doHandleCommand(DefaultDaemonConnection.java:286)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$CommandQueue$1.run(DefaultDaemonConnection.java:259)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

> Task :prBuild
Build Url: http://jenkins...
Build Number: 389
Build status: SUCCESS

BUILD SUCCESSFUL in 2m 34s
1 actionable task: 1 executed

Received exception trying to forward client input.
java.io.IOException: Pipe closed
	at java.base/java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
	at java.base/java.io.PipedInputStream.receive(PipedInputStream.java:226)
	at java.base/java.io.PipedOutputStream.write(PipedOutputStream.java:150)
	at java.base/java.io.OutputStream.write(OutputStream.java:127)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$1.onInput(ForwardClientInput.java:54)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$StdinQueue.doHandleCommand(DefaultDaemonConnection.java:299)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$StdinQueue.doHandleCommand(DefaultDaemonConnection.java:286)
	at org.gradle.launcher.daemon.server.DefaultDaemonConnection$CommandQueue$1.run(DefaultDaemonConnection.java:259)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.IOException: Pipe closed
	at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:62)
	at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
	at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:127)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Pipe closed
	at java.base/java.io.PipedInputStream.read(PipedInputStream.java:307)
	at java.base/java.io.PipedInputStream.read(PipedInputStream.java:377)
	at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:98)
	... 1 more

We are using gradle 7.5.1.

@martinda
Copy link
Contributor

Still happens in Gradle 8.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:console output progress tty mintty cygwin cli in:logging
Projects
None yet
Development

No branches or pull requests

6 participants