Buggy code:
public class Engine extends Thread { private final ExecutorService executor = Executors . newCachedThreadPool ( new ThreadFactory ( ) { private final ThreadFactory defaultFactory = Executors . defaultThreadFactory ( ) ; public Thread newThread ( final Runnable r ) { } } ) ; public final EngineListener listener ; private final EngineListenerSplitter events = new EngineListenerSplitter ( ) ; private List < URL > candidateUrls ; private URL hudsonUrl ; private final String secretKey ; public final String slaveName ; private String credentials ; private String proxyCredentials = System . getProperty ( "proxyCredentials" ) ; private String tunnel ; private boolean noReconnect ; private JarCache jarCache = new FileSystemJarCache ( new File ( System . getProperty ( "user.home" ) , ".jenkins//cache//jars" ) , true ) ; public Engine ( EngineListener listener , List < URL > hudsonUrls , String secretKey , String slaveName ) { } public void setJarCache ( JarCache jarCache ) { } public URL getHudsonUrl ( ) { } public void setTunnel ( String tunnel ) { } public void setCredentials ( String creds ) { } public void setProxyCredentials ( String proxyCredentials ) { } public void setNoReconnect ( boolean noReconnect ) { } public void addListener ( EngineListener el ) { } public void removeListener ( EngineListener el ) { } @ SuppressWarnings ( { "ThrowableInstanceNeverThrown" } ) @ Override public void run ( ) { } private void onConnectionRejected ( String greeting ) throws InterruptedException { } private Socket connect ( String host , String port ) throws IOException , InterruptedException { if ( ( tunnel ) != null ) { String [ ] tokens = tunnel . split ( ":" , 3 ) ; if ( ( tokens . length ) != 2 ) throw new IOException ( ( "Illegal<seq2seq4repair_space>tunneling<seq2seq4repair_space>parameter:<seq2seq4repair_space>" + ( tunnel ) ) ) ; if ( ( tokens [ 0 ] . length ( ) ) > 0 ) host = tokens [ 0 ] ; if ( ( tokens [ 1 ] . length ( ) ) > 0 ) port = tokens [ 1 ] ; } String msg = ( ( "Connecting<seq2seq4repair_space>to<seq2seq4repair_space>" + host ) + ':' ) + port ; events . status ( msg ) ; int retry = 1 ; while ( true ) { try { boolean isProxy = false ; Socket s ; if ( ( System . getProperty ( "http.proxyHost" ) ) != null ) { String proxyHost = System . getProperty ( "http.proxyHost" ) ; String proxyPort = System . getProperty ( "http.proxyPort" , "80" ) ; s = new Socket ( proxyHost , Integer . parseInt ( proxyPort ) ) ; isProxy = true ; } else { String httpProxy = System . getenv ( "http_proxy" ) ; if ( httpProxy != null ) { try { URL url = new URL ( httpProxy ) ; s = new Socket ( url . getHost ( ) , url . getPort ( ) ) ; isProxy = true ; } catch ( MalformedURLException e ) { System . err . println ( ( "Not<seq2seq4repair_space>use<seq2seq4repair_space>http_proxy<seq2seq4repair_space>environment<seq2seq4repair_space>variable<seq2seq4repair_space>which<seq2seq4repair_space>is<seq2seq4repair_space>invalid:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; s = new Socket ( host , Integer . parseInt ( port ) ) ; } } else { s = new Socket ( host , Integer . parseInt ( port ) ) ; } } s . setTcpNoDelay ( true ) ; s . setSoTimeout ( ( ( 30 * 60 ) * 1000 ) ) ; if ( isProxy ) { String connectCommand = String . format ( "CONNECT<seq2seq4repair_space>%s:%s<seq2seq4repair_space>HTTP//1.1\r\nHost:<seq2seq4repair_space>%s\r\n\r\n" , host , port , host ) ; <START_BUG> s . getOutputStream ( ) . write ( connectCommand . getBytes ( ) ) ; <END_BUG> BufferedInputStream is = new BufferedInputStream ( s . getInputStream ( ) ) ; String line = readLine ( is ) ; String [ ] responseLineParts = line . split ( "<seq2seq4repair_space>" ) ; if ( ( ( responseLineParts . length ) < 2 ) || ( ! ( responseLineParts [ 1 ] . equals ( "200" ) ) ) ) throw new IOException ( ( "Got<seq2seq4repair_space>a<seq2seq4repair_space>bad<seq2seq4repair_space>response<seq2seq4repair_space>from<seq2seq4repair_space>proxy:<seq2seq4repair_space>" + line ) ) ; while ( ! ( readLine ( is ) . isEmpty ( ) ) ) { } } return s ; } catch ( IOException e ) { if ( ( retry ++ ) > 10 ) throw ( ( IOException ) ( new IOException ( ( ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>connect<seq2seq4repair_space>to<seq2seq4repair_space>" + host ) + ':' ) + port ) ) . initCause ( e ) ) ) ; Thread . sleep ( ( 1000 * 10 ) ) ; events . status ( ( ( ( msg + "<seq2seq4repair_space>(retrying:" ) + retry ) + ")" ) , e ) ; } } } private void waitForServerToBack ( ) throws InterruptedException { } public static Engine current ( ) { } private static final ThreadLocal < Engine > CURRENT = new ThreadLocal < Engine > ( ) ; private static final Logger LOGGER = Logger . getLogger ( Engine . class . getName ( ) ) ; @ Deprecated public static final String GREETING_SUCCESS = JnlpProtocol . GREETING_SUCCESS ; }

Fix:
s . getOutputStream ( ) . write ( connectCommand . getBytes ( "UTF-8" ) ) ;