From dff4212ee1f3c9ec1ed54dda0f2788d0126d2fc1 Mon Sep 17 00:00:00 2001 From: Jerome Lacoste Date: Mon, 25 May 2015 07:34:59 +0200 Subject: [PATCH] [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 --- .../org/jenkinsci/plugins/unity3d/io/Pipe.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/unity3d/io/Pipe.java b/src/main/java/org/jenkinsci/plugins/unity3d/io/Pipe.java index 026568f7..899151f4 100644 --- a/src/main/java/org/jenkinsci/plugins/unity3d/io/Pipe.java +++ b/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);