Buggy code:
public class SSHExec extends SSHBase { private String command = null ; private long maxwait = 0 ; private Thread thread = null ; private String outputProperty = null ; private File outputFile = null ; private boolean append = false ; private Resource commandResource = null ; private static final String TIMEOUT_MESSAGE = "Timeout<seq2seq4repair_space>period<seq2seq4repair_space>exceeded,<seq2seq4repair_space>connection<seq2seq4repair_space>dropped." ; public SSHExec ( ) { } public void setCommand ( String command ) { } public void setCommandResource ( String f ) { } public void setTimeout ( long timeout ) { } public void setOutput ( File output ) { } public void setAppend ( boolean append ) { } public void setOutputproperty ( String property ) { } public void execute ( ) throws BuildException { } private void executeCommand ( String cmd ) throws BuildException { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; TeeOutputStream tee = new TeeOutputStream ( out , new KeepAliveOutputStream ( System . out ) ) ; Session session = null ; try { final ChannelExec channel ; session = openSession ( ) ; session . setTimeout ( ( ( int ) ( maxwait ) ) ) ; channel = ( ( ChannelExec ) ( session . openChannel ( "exec" ) ) ) ; channel . setCommand ( cmd ) ; channel . setOutputStream ( tee ) ; channel . setExtOutputStream ( tee ) ; channel . connect ( ) ; thread = new Thread ( ) { public void run ( ) { <START_BUG> while ( ! ( channel . isEOF ( ) ) ) { <END_BUG> if ( ( thread ) == null ) { return ; } try { Thread . sleep ( 500 ) ; } catch ( Exception e ) { } } } } ; thread . start ( ) ; thread . join ( maxwait ) ; if ( thread . isAlive ( ) ) { thread = null ; if ( getFailonerror ( ) ) { throw new BuildException ( SSHExec . TIMEOUT_MESSAGE ) ; } else { log ( SSHExec . TIMEOUT_MESSAGE , MSG_ERR ) ; } } else { if ( ( outputProperty ) != null ) { getProject ( ) . setProperty ( outputProperty , out . toString ( ) ) ; } if ( ( outputFile ) != null ) { writeToFile ( out . toString ( ) , append , outputFile ) ; } int ec = channel . getExitStatus ( ) ; if ( ec != 0 ) { String msg = "Remote<seq2seq4repair_space>command<seq2seq4repair_space>failed<seq2seq4repair_space>with<seq2seq4repair_space>exit<seq2seq4repair_space>status<seq2seq4repair_space>" + ec ; if ( getFailonerror ( ) ) { throw new BuildException ( msg ) ; } else { log ( msg , MSG_ERR ) ; } } } } catch ( BuildException e ) { throw e ; } catch ( JSchException e ) { if ( ( e . getMessage ( ) . indexOf ( "session<seq2seq4repair_space>is<seq2seq4repair_space>down" ) ) >= 0 ) { if ( getFailonerror ( ) ) { throw new BuildException ( SSHExec . TIMEOUT_MESSAGE , e ) ; } else { log ( SSHExec . TIMEOUT_MESSAGE , MSG_ERR ) ; } } else { if ( getFailonerror ( ) ) { throw new BuildException ( e ) ; } else { log ( ( "Caught<seq2seq4repair_space>exception:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , MSG_ERR ) ; } } } catch ( Exception e ) { if ( getFailonerror ( ) ) { throw new BuildException ( e ) ; } else { log ( ( "Caught<seq2seq4repair_space>exception:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , MSG_ERR ) ; } } finally { if ( ( session != null ) && ( session . isConnected ( ) ) ) { session . disconnect ( ) ; } } } private void writeToFile ( String from , boolean append , File to ) throws IOException { } }

Fix:
while ( ! ( channel . isClosed ( ) ) ) {