Program: 175695
Project: 175695
Buggy source:
@Override public BrokerMessage.SendMessageResponse sendMessage(BrokerMessage.SendMessageRequest request){
  BrokerMessage.SendMessageResponse.Builder responseBuilder=BrokerMessage.SendMessageResponse.newBuilder();
  BrokerMessage.BaseResponse.Builder baseResBuilder=BrokerMessage.BaseResponse.newBuilder();
  baseResBuilder.setResCode(BrokerMessage.ResCode.RES_CODE_FAIL);
  boolean topicExist=metadataManager.checkTopicExist(request.getTopic());
  if (!topicExist) {
    Map<Integer,Integer> queueMap=metadataManager.readTopicInfo(request.getTopic());
    if (queueMap.size() > 0) {
      topicExist=true;
    }
    metadataManager.updateTopicMap(request.getTopic(),queueMap);
  }
  boolean shardingValid=false;
  GlobalConf conf=GlobalConf.getInstance();
  Integer shardingId=metadataManager.getQueueSharding(request.getTopic(),request.getQueue());
  if (shardingId != null && shardingId.equals(conf.getShardingId())) {
    shardingValid=true;
  }
  if (!topicExist || !shardingValid) {
    String message="String_Node_Str";
    baseResBuilder.setResMsg(message);
    responseBuilder.setBaseRes(baseResBuilder.build());
    LOG.info("String_Node_Str",request.getTopic(),request.getQueue(),responseBuilder.getBaseRes().getResCode(),responseBuilder.getBaseRes().getResMsg());
    return responseBuilder.build();
  }
  if (raftNode.getLeaderId() <= 0) {
    baseResBuilder.setResMsg("String_Node_Str");
    responseBuilder.setBaseRes(baseResBuilder);
  }
 else   if (raftNode.getLeaderId() != raftNode.getLocalServer().getServerId()) {
    RPCClient rpcClient=raftNode.getPeerMap().get(raftNode.getLeaderId()).getRpcClient();
    BrokerAPI brokerAPI=RPCProxy.getProxy(rpcClient,BrokerAPI.class);
    BrokerMessage.SendMessageResponse responseFromLeader=brokerAPI.sendMessage(request);
    if (responseFromLeader == null) {
      baseResBuilder.setResMsg("String_Node_Str");
      responseBuilder.setBaseRes(baseResBuilder);
    }
 else {
      responseBuilder.mergeFrom(responseFromLeader);
    }
  }
 else {
    byte[] data=request.toByteArray();
    boolean success=raftNode.replicate(data,RaftMessage.EntryType.ENTRY_TYPE_DATA);
    baseResBuilder.setResCode(success ? BrokerMessage.ResCode.RES_CODE_SUCCESS : BrokerMessage.ResCode.RES_CODE_FAIL);
    responseBuilder.setBaseRes(baseResBuilder);
  }
  BrokerMessage.SendMessageResponse response=responseBuilder.build();
  LOG.info("String_Node_Str",request.getTopic(),request.getQueue(),responseBuilder.getBaseRes().getResCode(),responseBuilder.getBaseRes().getResMsg());
  return response;
}

Fixed version (ground truth):
@Override public BrokerMessage.SendMessageResponse sendMessage(BrokerMessage.SendMessageRequest request){
  BrokerMessage.SendMessageResponse.Builder responseBuilder=BrokerMessage.SendMessageResponse.newBuilder();
  BrokerMessage.BaseResponse.Builder baseResBuilder=BrokerMessage.BaseResponse.newBuilder();
  baseResBuilder.setResCode(BrokerMessage.ResCode.RES_CODE_FAIL);
  boolean topicExist=metadataManager.checkTopicExist(request.getTopic());
  if (!topicExist) {
    Map<Integer,Integer> queueMap=metadataManager.readTopicInfo(request.getTopic());
    if (queueMap.size() > 0) {
      topicExist=true;
    }
    metadataManager.updateTopicMap(request.getTopic(),queueMap);
  }
  if (raftNode.getLeaderId() <= 0) {
    baseResBuilder.setResMsg("String_Node_Str");
    responseBuilder.setBaseRes(baseResBuilder);
  }
 else   if (raftNode.getLeaderId() != raftNode.getLocalServer().getServerId()) {
    RPCClient rpcClient=raftNode.getPeerMap().get(raftNode.getLeaderId()).getRpcClient();
    BrokerAPI brokerAPI=RPCProxy.getProxy(rpcClient,BrokerAPI.class);
    BrokerMessage.SendMessageResponse responseFromLeader=brokerAPI.sendMessage(request);
    if (responseFromLeader == null) {
      baseResBuilder.setResMsg("String_Node_Str");
      responseBuilder.setBaseRes(baseResBuilder);
    }
 else {
      responseBuilder.mergeFrom(responseFromLeader);
    }
  }
 else {
    byte[] data=request.toByteArray();
    boolean success=raftNode.replicate(data,RaftMessage.EntryType.ENTRY_TYPE_DATA);
    baseResBuilder.setResCode(success ? BrokerMessage.ResCode.RES_CODE_SUCCESS : BrokerMessage.ResCode.RES_CODE_FAIL);
    responseBuilder.setBaseRes(baseResBuilder);
  }
  BrokerMessage.SendMessageResponse response=responseBuilder.build();
  LOG.info("String_Node_Str",request.getTopic(),request.getQueue(),responseBuilder.getBaseRes().getResCode(),responseBuilder.getBaseRes().getResMsg());
  return response;
}