Skip to content
Permalink
Browse files

[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 dff4212ee1f3c9ec1ed54dda0f2788d0126d2fc1
Showing with 14 additions and 2 deletions.
  1. +14 −2 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;
@@ -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 {
@@ -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);

0 comments on commit dff4212

Please sign in to comment.
You can’t perform that action at this time.