Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-23958] use jenkins remoting piping streams for piping.…
… java.io.Piped*Stream are not threads friendly and cause 'Pipe is broken' issue when jenkins pool the writing threads
  • Loading branch information
lacostej committed May 25, 2015
1 parent 45e1431 commit dff4212
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/org/jenkinsci/plugins/unity3d/io/Pipe.java
@@ -1,6 +1,8 @@
package org.jenkinsci.plugins.unity3d.io;

import hudson.Launcher;
import hudson.remoting.FastPipedInputStream;
import hudson.remoting.FastPipedOutputStream;
import hudson.remoting.RemoteOutputStream;

import java.io.InputStream;
Expand All @@ -13,6 +15,9 @@
* A Pipe that works for distributed and non distributed scenarios.
* Jenkins's Pipe doesn't work for non distributed scenarios.
*
* Note: that java.io.Piped*Stream are not thread friendly and cause issues like JENKINS-23958.
* See comments in the issue for details.
*
* @author Jerome Lacoste
*/
public class Pipe {
Expand All @@ -32,9 +37,16 @@ public OutputStream getOut() {
return os;
}

/*
// This breaks our PipeTest
public static hudson.remoting.Pipe createRemoteToLocal3(Launcher launcher) throws IOException {
return hudson.remoting.Pipe.createRemoteToLocal();
}
*/

public static Pipe createRemoteToLocal(Launcher launcher) throws IOException {
PipedInputStream is = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream(is);
FastPipedInputStream is = new FastPipedInputStream();
FastPipedOutputStream pos = new FastPipedOutputStream(is);

boolean isLocal = launcher instanceof Launcher.LocalLauncher;
OutputStream os = isLocal ? pos : new RemoteOutputStream(pos);
Expand Down

0 comments on commit dff4212

Please sign in to comment.