Program: 171946
Project: 171946
Buggy source:
public void processMessages(Integer requestKey,List<Messages.LogItem> logItems){
  ArrayList<AVIMMessage> messageList=new ArrayList<AVIMMessage>();
  long lastDeliveredAt=-1;
  long lastReadAt=-1;
  for (  Messages.LogItem item : logItems) {
    long ackAt=item.hasAckAt() ? -1 : item.getAckAt();
    long readAt=item.hasReadAt() ? -1 : item.getReadAt();
    if (lastDeliveredAt < ackAt) {
      lastDeliveredAt=ackAt;
    }
    if (lastReadAt < readAt) {
      lastReadAt=readAt;
    }
    String from=item.getFrom();
    Object data=item.getData();
    long timestamp=item.getTimestamp();
    String msgId=item.getMsgId();
    boolean mentionAll=item.hasMentionAll() ? item.getMentionAll() : false;
    List<String> mentionList=item.getMentionPidsList();
    boolean isBinaryMsg=item.hasBin() && item.getBin();
    AVIMMessage message=null;
    if (isBinaryMsg && null != data) {
      message=new AVIMBinaryMessage(this.conversationId,from,timestamp,ackAt,readAt);
      ((AVIMBinaryMessage)message).setBytes(AVUtils.Base64Decode(data.toString()));
    }
 else     if (data instanceof String || data instanceof JSON) {
      message=new AVIMMessage(this.conversationId,from,timestamp,ackAt,readAt);
      message.setContent(data.toString());
    }
 else {
      continue;
    }
    message.setMessageId(msgId);
    message.setMentionAll(mentionAll);
    message.setMentionList(mentionList);
    message=AVIMMessageManagerHelper.parseTypedMessage(message);
    messageList.add(message);
  }
  onHistoryMessageQuery(messageList,requestKey,lastDeliveredAt,lastReadAt);
}

Fixed version (ground truth):
public void processMessages(Integer requestKey,List<Messages.LogItem> logItems){
  ArrayList<AVIMMessage> messageList=new ArrayList<AVIMMessage>();
  long lastDeliveredAt=-1;
  long lastReadAt=-1;
  for (  Messages.LogItem item : logItems) {
    long ackAt=item.hasAckAt() ? -1 : item.getAckAt();
    long readAt=item.hasReadAt() ? -1 : item.getReadAt();
    if (lastDeliveredAt < ackAt) {
      lastDeliveredAt=ackAt;
    }
    if (lastReadAt < readAt) {
      lastReadAt=readAt;
    }
    String from=item.getFrom();
    Object data=item.getData();
    long timestamp=item.getTimestamp();
    String msgId=item.getMsgId();
    boolean mentionAll=item.hasMentionAll() ? item.getMentionAll() : false;
    List<String> mentionList=item.getMentionPidsList();
    boolean isBinaryMsg=item.hasBin() && item.getBin();
    AVIMMessage message=null;
    if (isBinaryMsg && null != data) {
      message=new AVIMBinaryMessage(this.conversationId,from,timestamp,ackAt,readAt);
      ((AVIMBinaryMessage)message).setBytes(AVUtils.base64Decode(data.toString()));
    }
 else     if (data instanceof String || data instanceof JSON) {
      message=new AVIMMessage(this.conversationId,from,timestamp,ackAt,readAt);
      message.setContent(data.toString());
    }
 else {
      continue;
    }
    message.setMessageId(msgId);
    message.setMentionAll(mentionAll);
    message.setMentionList(mentionList);
    message=AVIMMessageManagerHelper.parseTypedMessage(message);
    messageList.add(message);
  }
  onHistoryMessageQuery(messageList,requestKey,lastDeliveredAt,lastReadAt);
}