Program: 175714
Project: 175714
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);
  ZKData zkData=ZKData.getInstance();
  GlobalConf conf=GlobalConf.getInstance();
  zkData.getTopicLock().lock();
  Map<String,Map<Integer,Integer>> topicMap=zkData.getTopicMap();
  Map<Integer,Integer> queueMap=topicMap.get(request.getTopic());
  if (queueMap == null || !queueMap.containsKey(request.getQueue()) || queueMap.get(request.getQueue()) != conf.getShardingId()) {
    queueMap=zkClient.readTopicInfo(request.getTopic());
    zkData.getTopicLock().lock();
    try {
      zkData.getTopicMap().put(request.getTopic(),queueMap);
    }
  finally {
      zkData.getTopicLock().unlock();
    }
    if (queueMap == null || !queueMap.containsKey(request.getQueue()) || queueMap.get(request.getQueue()) != conf.getShardingId()) {
      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);
    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);
  ZKData zkData=ZKData.getInstance();
  GlobalConf conf=GlobalConf.getInstance();
  Map<String,Map<Integer,Integer>> topicMap=zkData.getTopicMap();
  Map<Integer,Integer> queueMap=topicMap.get(request.getTopic());
  if (queueMap == null || !queueMap.containsKey(request.getQueue()) || queueMap.get(request.getQueue()) != conf.getShardingId()) {
    queueMap=zkClient.readTopicInfo(request.getTopic());
    zkData.getTopicLock().lock();
    try {
      zkData.getTopicMap().put(request.getTopic(),queueMap);
    }
  finally {
      zkData.getTopicLock().unlock();
    }
    if (queueMap == null || !queueMap.containsKey(request.getQueue()) || queueMap.get(request.getQueue()) != conf.getShardingId()) {
      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;
}