Program: 110888
Project: 110888
Buggy source:
@Override public synchronized void handle(Event event){
  try {
    if (debugAllEvents) {
      clearProgressBar();
      terminal.flush();
      outErr.getOutputStream().write((event + "String_Node_Str").getBytes(StandardCharsets.UTF_8));
      outErr.getOutputStream().flush();
      addProgressBar();
      terminal.flush();
    }
 else {
switch (event.getKind()) {
case STDOUT:
case STDERR:
        OutputStream stream=event.getKind() == EventKind.STDOUT ? outErr.getOutputStream() : outErr.getErrorStream();
      if (buildComplete) {
        stream.write(event.getMessageBytes());
        stream.flush();
      }
 else {
        byte[] message=event.getMessageBytes();
        int eolIndex=Bytes.lastIndexOf(message,(byte)'\n');
        if (eolIndex >= 0) {
          clearProgressBar();
          terminal.flush();
          stream.write(event.getKind() == EventKind.STDOUT ? stdoutBuffer : stderrBuffer);
          stream.write(Arrays.copyOf(message,eolIndex + 1));
          byte[] restMessage=Arrays.copyOfRange(message,eolIndex + 1,message.length + 1);
          if (event.getKind() == EventKind.STDOUT) {
            stdoutBuffer=restMessage;
          }
 else {
            stderrBuffer=restMessage;
          }
          stream.flush();
          if (cursorControl) {
            addProgressBar();
          }
          terminal.flush();
        }
 else {
          if (event.getKind() == EventKind.STDOUT) {
            stdoutBuffer=Bytes.concat(stdoutBuffer,message);
          }
 else {
            stderrBuffer=Bytes.concat(stderrBuffer,message);
          }
        }
      }
    break;
case ERROR:
case WARNING:
case INFO:
case SUBCOMMAND:
  if (!buildComplete) {
    clearProgressBar();
  }
outErr.getOutputStream().write(stdoutBuffer);
outErr.getOutputStream().flush();
stdoutBuffer=new byte[]{};
outErr.getErrorStream().write(stderrBuffer);
outErr.getErrorStream().flush();
stderrBuffer=new byte[]{};
crlf();
setEventKindColor(event.getKind());
terminal.writeString(event.getKind() + "String_Node_Str");
terminal.resetTerminal();
if (event.getLocation() != null) {
terminal.writeString(event.getLocation() + "String_Node_Str");
}
if (event.getMessage() != null) {
terminal.writeString(event.getMessage());
}
crlf();
if (!buildComplete) {
addProgressBar();
}
terminal.flush();
break;
case PROGRESS:
if (stateTracker.progressBarTimeDependent()) {
refresh();
}
}
}
}
 catch (IOException e) {
LOG.warning("String_Node_Str" + e);
}
}

Fixed version (ground truth):
@Override public synchronized void handle(Event event){
  try {
    if (debugAllEvents) {
      clearProgressBar();
      terminal.flush();
      outErr.getOutputStream().write((event + "String_Node_Str").getBytes(StandardCharsets.UTF_8));
      outErr.getOutputStream().flush();
      addProgressBar();
      terminal.flush();
    }
 else {
switch (event.getKind()) {
case STDOUT:
case STDERR:
        OutputStream stream=event.getKind() == EventKind.STDOUT ? outErr.getOutputStream() : outErr.getErrorStream();
      if (buildComplete) {
        stream.write(event.getMessageBytes());
        stream.flush();
      }
 else {
        byte[] message=event.getMessageBytes();
        int eolIndex=Bytes.lastIndexOf(message,(byte)'\n');
        if (eolIndex >= 0) {
          clearProgressBar();
          terminal.flush();
          stream.write(event.getKind() == EventKind.STDOUT ? stdoutBuffer : stderrBuffer);
          stream.write(Arrays.copyOf(message,eolIndex + 1));
          byte[] restMessage=Arrays.copyOfRange(message,eolIndex + 1,message.length);
          if (event.getKind() == EventKind.STDOUT) {
            stdoutBuffer=restMessage;
          }
 else {
            stderrBuffer=restMessage;
          }
          stream.flush();
          if (cursorControl) {
            addProgressBar();
          }
          terminal.flush();
        }
 else {
          if (event.getKind() == EventKind.STDOUT) {
            stdoutBuffer=Bytes.concat(stdoutBuffer,message);
          }
 else {
            stderrBuffer=Bytes.concat(stderrBuffer,message);
          }
        }
      }
    break;
case ERROR:
case WARNING:
case INFO:
case SUBCOMMAND:
  if (!buildComplete) {
    clearProgressBar();
  }
outErr.getOutputStream().write(stdoutBuffer);
outErr.getOutputStream().flush();
stdoutBuffer=new byte[]{};
outErr.getErrorStream().write(stderrBuffer);
outErr.getErrorStream().flush();
stderrBuffer=new byte[]{};
crlf();
setEventKindColor(event.getKind());
terminal.writeString(event.getKind() + "String_Node_Str");
terminal.resetTerminal();
if (event.getLocation() != null) {
terminal.writeString(event.getLocation() + "String_Node_Str");
}
if (event.getMessage() != null) {
terminal.writeString(event.getMessage());
}
crlf();
if (!buildComplete) {
addProgressBar();
}
terminal.flush();
break;
case PROGRESS:
if (stateTracker.progressBarTimeDependent()) {
refresh();
}
}
}
}
 catch (IOException e) {
LOG.warning("String_Node_Str" + e);
}
}