Program: 172855
Project: 172855
Buggy source:
@Override public Object build(Object message,Object partialBuildObject){
  OutMessage sendMessage=(OutMessage)partialBuildObject;
  if (sendMessage.getChannelMessage().isComplete()) {
    sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
    return sendMessage;
  }
  if (sendMessage.getSerializationState() == null) {
    sendMessage.setSerializationState(new SerializeState());
  }
  while (sendBuffers.size() > 0 && sendMessage.serializedState() != OutMessage.SendState.SERIALIZED) {
    DataBuffer buffer=sendBuffers.poll();
    if (buffer == null) {
      break;
    }
    if (sendMessage.serializedState() == OutMessage.SendState.INIT || sendMessage.serializedState() == OutMessage.SendState.SENT_INTERNALLY) {
      buildHeader(buffer,sendMessage);
      sendMessage.setSendState(OutMessage.SendState.HEADER_BUILT);
    }
    if (sendMessage.serializedState() == OutMessage.SendState.HEADER_BUILT || sendMessage.serializedState() == OutMessage.SendState.BODY_BUILT || sendMessage.serializedState() == OutMessage.SendState.PARTIALLY_SERIALIZED) {
      if ((sendMessage.getFlags() & MessageFlags.EMPTY) == MessageFlags.EMPTY) {
        sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
        sendMessage.getSerializationState().setTotalBytes(0);
      }
 else {
        boolean complete=serializeBody(message,sendMessage,buffer);
        if (complete) {
          sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
        }
 else {
          sendMessage.setSendState(OutMessage.SendState.PARTIALLY_SERIALIZED);
        }
      }
    }
    sendMessage.getChannelMessage().addBuffer(buffer);
    if (sendMessage.serializedState() == OutMessage.SendState.SERIALIZED) {
      ChannelMessage channelMessage=sendMessage.getChannelMessage();
      SerializeState state=sendMessage.getSerializationState();
      if (!channelMessage.isHeaderSent()) {
        int totalBytes=state.getTotalBytes();
        channelMessage.getBuffers().get(0).getByteBuffer().putInt(HEADER_SIZE - Integer.BYTES,totalBytes);
        MessageHeader.Builder builder=MessageHeader.newBuilder(sendMessage.getSource(),sendMessage.getEdge(),totalBytes);
        builder.destination(sendMessage.getDestintationIdentifier());
        sendMessage.getChannelMessage().setHeader(builder.build());
        state.setTotalBytes(0);
        channelMessage.setHeaderSent(true);
      }
      channelMessage.setComplete(true);
    }
 else     if (sendMessage.serializedState() == OutMessage.SendState.PARTIALLY_SERIALIZED) {
      ChannelMessage channelMessage=sendMessage.getChannelMessage();
      SerializeState state=sendMessage.getSerializationState();
      if (!channelMessage.isHeaderSent()) {
        int totalBytes=state.getData().length;
        channelMessage.getBuffers().get(0).getByteBuffer().putInt(HEADER_SIZE - Integer.BYTES,totalBytes);
        MessageHeader.Builder builder=MessageHeader.newBuilder(sendMessage.getSource(),sendMessage.getEdge(),totalBytes);
        builder.destination(sendMessage.getDestintationIdentifier());
        sendMessage.getChannelMessage().setHeader(builder.build());
        channelMessage.setHeaderSent(true);
      }
      state.setTotalBytes(0);
      LOG.fine("String_Node_Str");
    }
 else {
      LOG.fine("String_Node_Str");
    }
  }
  return sendMessage;
}

Fixed version (ground truth):
@Override public Object build(Object message,Object partialBuildObject){
  OutMessage sendMessage=(OutMessage)partialBuildObject;
  if (sendMessage.getChannelMessage().isComplete()) {
    sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
    return sendMessage;
  }
  if (sendMessage.getSerializationState() == null) {
    sendMessage.setSerializationState(new SerializeState());
  }
  while (sendBuffers.size() > 0 && sendMessage.serializedState() != OutMessage.SendState.SERIALIZED) {
    DataBuffer buffer=sendBuffers.poll();
    if (buffer == null) {
      break;
    }
    if (sendMessage.serializedState() == OutMessage.SendState.INIT || sendMessage.serializedState() == OutMessage.SendState.SENT_INTERNALLY) {
      buildHeader(buffer,sendMessage);
      sendMessage.setSendState(OutMessage.SendState.HEADER_BUILT);
    }
    if (sendMessage.serializedState() == OutMessage.SendState.HEADER_BUILT || sendMessage.serializedState() == OutMessage.SendState.BODY_BUILT || sendMessage.serializedState() == OutMessage.SendState.PARTIALLY_SERIALIZED) {
      if ((sendMessage.getFlags() & MessageFlags.EMPTY) == MessageFlags.EMPTY) {
        sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
        sendMessage.getSerializationState().setTotalBytes(0);
      }
 else {
        boolean complete=serializeBody(message,sendMessage,buffer);
        if (complete) {
          sendMessage.setSendState(OutMessage.SendState.SERIALIZED);
        }
 else {
          sendMessage.setSendState(OutMessage.SendState.PARTIALLY_SERIALIZED);
        }
      }
    }
    sendMessage.getChannelMessage().addBuffer(buffer);
    if (sendMessage.serializedState() == OutMessage.SendState.SERIALIZED) {
      ChannelMessage channelMessage=sendMessage.getChannelMessage();
      SerializeState state=sendMessage.getSerializationState();
      if (!channelMessage.isHeaderSent()) {
        int totalBytes=state.getTotalBytes();
        channelMessage.getBuffers().get(0).getByteBuffer().putInt(HEADER_SIZE - Integer.BYTES,totalBytes);
        MessageHeader.Builder builder=MessageHeader.newBuilder(sendMessage.getSource(),sendMessage.getEdge(),totalBytes);
        builder.destination(sendMessage.getDestintationIdentifier());
        sendMessage.getChannelMessage().setHeader(builder.build());
        state.setTotalBytes(0);
        channelMessage.setHeaderSent(true);
      }
      channelMessage.setComplete(true);
    }
 else     if (sendMessage.serializedState() == OutMessage.SendState.PARTIALLY_SERIALIZED) {
      ChannelMessage channelMessage=sendMessage.getChannelMessage();
      SerializeState state=sendMessage.getSerializationState();
      if (!channelMessage.isHeaderSent()) {
        int totalBytes=state.getCurretHeaderLength();
        channelMessage.getBuffers().get(0).getByteBuffer().putInt(HEADER_SIZE - Integer.BYTES,totalBytes);
        MessageHeader.Builder builder=MessageHeader.newBuilder(sendMessage.getSource(),sendMessage.getEdge(),totalBytes);
        builder.destination(sendMessage.getDestintationIdentifier());
        sendMessage.getChannelMessage().setHeader(builder.build());
        channelMessage.setHeaderSent(true);
      }
      state.setTotalBytes(0);
      LOG.fine("String_Node_Str");
    }
 else {
      LOG.fine("String_Node_Str");
    }
  }
  return sendMessage;
}