nus-yam/ex-repair huggingface dataset:
Program: 34430
Project: 34430
Buggy source:
protected void finishWithError(final FileStorageSetupActivity setupAct,Exception error){
  Log.e("String_Node_Str","String_Node_Str" + error.toString());
  error.printStackTrace();
  final Activity activity=(Activity)setupAct;
  int resultCode=Activity.RESULT_CANCELED;
  if (activity.getIntent().getBooleanExtra(EXTRA_ALWAYS_RETURN_SUCCESS,false)) {
    Log.d(TAG,"String_Node_Str");
    finishActivityWithSuccess(setupAct);
    return;
  }
  Intent retData=new Intent();
  retData.putExtra(EXTRA_ERROR_MESSAGE,error.getMessage());
  activity.setResult(resultCode,retData);
  activity.finish();
}

Fixed version (ground truth):
protected void finishWithError(final FileStorageSetupActivity setupAct,Exception error){
  logDebug("String_Node_Str" + error.toString());
  error.printStackTrace();
  final Activity activity=(Activity)setupAct;
  int resultCode=Activity.RESULT_CANCELED;
  if (activity.getIntent().getBooleanExtra(EXTRA_ALWAYS_RETURN_SUCCESS,false)) {
    logDebug("String_Node_Str");
    finishActivityWithSuccess(setupAct);
    return;
  }
  Intent retData=new Intent();
  retData.putExtra(EXTRA_ERROR_MESSAGE,error.getMessage());
  activity.setResult(resultCode,retData);
  activity.finish();
}
Program: 34432
Project: 34432
Buggy source:
public static String toEnviromentVariableString(List<ValueRange> portRanges,Map<String,Ports> portsDefinitions){
  StringBuilder portsString=new StringBuilder();
  if (portsDefinitions != null && !portsDefinitions.isEmpty()) {
    Iterator iter=portsDefinitions.entrySet().iterator();
    int basePort=0;
    while (iter.hasNext()) {
      Map.Entry entry=(Map.Entry)iter.next();
      String key=(String)entry.getKey();
      Ports ports=(Ports)entry.getValue();
      if (ports.getStart() > 0) {
        portsString.append(key + "String_Node_Str" + ports.getStart());
        for (int i=2; i <= ports.getCount(); i++) {
          portsString.append("String_Node_Str" + (ports.getStart() + i - 1));
        }
        portsString.append("String_Node_Str");
      }
 else {
        List<ValueRange> assignPorts=ValueRangeUtils.getSubRange(portRanges,ports.getCount(),basePort);
        basePort=assignPorts.get(assignPorts.size() - 1).getEnd() + 1;
        portsString.append(key + "String_Node_Str" + assignPorts.get(0).toDetailString("String_Node_Str"));
        for (int i=1; i < assignPorts.size(); i++) {
          portsString.append("String_Node_Str" + assignPorts.get(i).toDetailString("String_Node_Str"));
        }
        portsString.append("String_Node_Str");
      }
    }
  }
  return portsString.toString();
}

Fixed version (ground truth):
public static String toEnviromentVariableString(List<ValueRange> portRanges,Map<String,Ports> portsDefinitions){
  StringBuilder portsString=new StringBuilder();
  if (portsDefinitions != null && !portsDefinitions.isEmpty()) {
    Iterator iter=portsDefinitions.entrySet().iterator();
    int basePort=0;
    while (iter.hasNext()) {
      Map.Entry entry=(Map.Entry)iter.next();
      String key=(String)entry.getKey();
      Ports ports=(Ports)entry.getValue();
      if (ports.getStart() > 0) {
        portsString.append(key + "String_Node_Str" + ports.getStart());
        for (int i=2; i <= ports.getCount(); i++) {
          portsString.append("String_Node_Str" + (ports.getStart() + i - 1));
        }
        portsString.append("String_Node_Str");
      }
 else {
        List<ValueRange> assignPorts=ValueRangeUtils.getSubRangeSequence(portRanges,ports.getCount(),basePort);
        basePort=assignPorts.get(assignPorts.size() - 1).getEnd() + 1;
        portsString.append(key + "String_Node_Str" + assignPorts.get(0).toDetailString("String_Node_Str"));
        for (int i=1; i < assignPorts.size(); i++) {
          portsString.append("String_Node_Str" + assignPorts.get(i).toDetailString("String_Node_Str"));
        }
        portsString.append("String_Node_Str");
      }
    }
  }
  return portsString.toString();
}
Program: 34433
Project: 34433
Buggy source:
public static List<ValueRange> getSubRange(List<ValueRange> availableRange,int requestNumber,int baseValue){
  List<ValueRange> resultList=new ArrayList<ValueRange>();
  if (getValueNumber(availableRange) <= 0) {
    return resultList;
  }
  Random random=new Random();
  int maxValue=availableRange.get(availableRange.size() - 1).getEnd();
  int randomBase=random.nextInt(maxValue) + 1;
  while (randomBase > 0) {
    resultList.clear();
    int needNumber=requestNumber;
    randomBase=randomBase / 2;
    int newbaseValue=baseValue + randomBase;
    for (    ValueRange range : availableRange) {
      if (range.getEnd() < newbaseValue) {
        continue;
      }
      int start=Math.max(range.getBegin(),newbaseValue);
      if ((range.getEnd() - start + 1) >= needNumber) {
        resultList.add(ValueRange.newInstance(start,start + needNumber - 1));
        return resultList;
      }
 else {
        resultList.add(ValueRange.newInstance(start,range.getEnd()));
        needNumber-=(range.getEnd() - start + 1);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public static List<ValueRange> getSubRange(List<ValueRange> availableRange,int requestNumber,int baseValue){
  List<ValueRange> resultList=new ArrayList<ValueRange>();
  if (getValueNumber(availableRange) <= 0) {
    return resultList;
  }
  Random random=new Random();
  int maxValue=availableRange.get(availableRange.size() - 1).getEnd();
  int randomBase=random.nextInt(maxValue) + 1;
  while (randomBase > 0) {
    resultList.clear();
    int needNumber=requestNumber;
    randomBase=randomBase / 2;
    int newBaseValue=baseValue + randomBase;
    for (    ValueRange range : availableRange) {
      if (range.getEnd() < newBaseValue) {
        continue;
      }
      int start=Math.max(range.getBegin(),newBaseValue);
      if ((range.getEnd() - start + 1) >= needNumber) {
        resultList.add(ValueRange.newInstance(start,start + needNumber - 1));
        return resultList;
      }
 else {
        resultList.add(ValueRange.newInstance(start,range.getEnd()));
        needNumber-=(range.getEnd() - start + 1);
      }
    }
  }
  return resultList;
}
Program: 34437
Project: 34437
Buggy source:
public synchronized SelectionResult selectSingleNode(String taskRoleName) throws NotAvailableException {
  SelectionResult results=select(taskRoleName);
  ResourceDescriptor optimizedRequestResource=results.getOptimizedResource();
  String candidateNode=results.getNodeHosts().get(CommonUtils.getRandomNumber(0,results.getNodeHosts().size() - 1));
  optimizedRequestResource.setGpuAttribute(results.getGpuAttribute(candidateNode));
  SelectionResult result=new SelectionResult();
  result.addSelection(candidateNode,results.getGpuAttribute(candidateNode),results.getOverlapPorts());
  result.setOptimizedResource(optimizedRequestResource);
  return result;
}

Fixed version (ground truth):
public synchronized SelectionResult selectSingleNode(String taskRoleName) throws NotAvailableException {
  SelectionResult results=select(taskRoleName);
  if (results.getNodeHosts().size() > 1) {
    ResourceDescriptor optimizedRequestResource=results.getOptimizedResource();
    String candidateNode=results.getNodeHosts().get(CommonUtils.getRandomNumber(0,results.getNodeHosts().size() - 1));
    optimizedRequestResource.setGpuAttribute(results.getGpuAttribute(candidateNode));
    SelectionResult result=new SelectionResult();
    result.addSelection(candidateNode,results.getGpuAttribute(candidateNode),results.getOverlapPorts());
    result.setOptimizedResource(optimizedRequestResource);
    return result;
  }
  return results;
}
Program: 34438
Project: 34438
Buggy source:
public synchronized List<ValueRange> selectPorts(SelectionResult selectionResult,ResourceDescriptor optimizedRequestResource) throws NotAvailableException {
  if (ValueRangeUtils.getValueNumber(optimizedRequestResource.getPortRanges()) <= 0 && optimizedRequestResource.getPortNumber() > 0) {
    List<ValueRange> newCandidatePorts=ValueRangeUtils.getSubRange(selectionResult.getOverlapPorts(),optimizedRequestResource.getPortNumber(),conf.getAmContainerMinPort());
    if (ValueRangeUtils.getValueNumber(newCandidatePorts) >= optimizedRequestResource.getPortNumber()) {
      LOGGER.logDebug("String_Node_Str",optimizedRequestResource);
      return newCandidatePorts;
    }
 else {
      throw new NotAvailableException(String.format("String_Node_Str",optimizedRequestResource));
    }
  }
  return optimizedRequestResource.getPortRanges();
}

Fixed version (ground truth):
private synchronized List<ValueRange> selectPorts(SelectionResult selectionResult,ResourceDescriptor optimizedRequestResource) throws NotAvailableException {
  if (ValueRangeUtils.getValueNumber(optimizedRequestResource.getPortRanges()) <= 0 && optimizedRequestResource.getPortNumber() > 0) {
    List<ValueRange> newCandidatePorts=ValueRangeUtils.getSubRange(selectionResult.getOverlapPorts(),optimizedRequestResource.getPortNumber(),conf.getAmContainerMinPort());
    if (ValueRangeUtils.getValueNumber(newCandidatePorts) >= optimizedRequestResource.getPortNumber()) {
      LOGGER.logDebug("String_Node_Str",optimizedRequestResource);
      return newCandidatePorts;
    }
 else {
      throw new NotAvailableException(String.format("String_Node_Str",optimizedRequestResource));
    }
  }
  return optimizedRequestResource.getPortRanges();
}
Program: 34439
Project: 34439
Buggy source:
public static List<ValueRange> getSubRange(List<ValueRange> availableRange,int requestNumber,int baseValue){
  List<ValueRange> resultList=new ArrayList<ValueRange>();
  Random random=new Random();
  int maxValue=availableRange.get(availableRange.size() - 1).getEnd();
  int randomBase=random.nextInt(maxValue) + 1;
  while (randomBase > 0) {
    resultList.clear();
    int needNumber=requestNumber;
    randomBase=randomBase / 2;
    int newbaseValue=baseValue + randomBase;
    for (    ValueRange range : availableRange) {
      if (range.getEnd() < newbaseValue) {
        continue;
      }
      int start=Math.max(range.getBegin(),newbaseValue);
      if ((range.getEnd() - start + 1) >= needNumber) {
        resultList.add(ValueRange.newInstance(start,start + needNumber - 1));
        return resultList;
      }
 else {
        resultList.add(ValueRange.newInstance(start,range.getEnd()));
        needNumber-=(range.getEnd() - start + 1);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public static List<ValueRange> getSubRange(List<ValueRange> availableRange,int requestNumber,int baseValue){
  List<ValueRange> resultList=new ArrayList<ValueRange>();
  if (getValueNumber(availableRange) <= 0) {
    return resultList;
  }
  Random random=new Random();
  int maxValue=availableRange.get(availableRange.size() - 1).getEnd();
  int randomBase=random.nextInt(maxValue) + 1;
  while (randomBase > 0) {
    resultList.clear();
    int needNumber=requestNumber;
    randomBase=randomBase / 2;
    int newbaseValue=baseValue + randomBase;
    for (    ValueRange range : availableRange) {
      if (range.getEnd() < newbaseValue) {
        continue;
      }
      int start=Math.max(range.getBegin(),newbaseValue);
      if ((range.getEnd() - start + 1) >= needNumber) {
        resultList.add(ValueRange.newInstance(start,start + needNumber - 1));
        return resultList;
      }
 else {
        resultList.add(ValueRange.newInstance(start,range.getEnd()));
        needNumber-=(range.getEnd() - start + 1);
      }
    }
  }
  return null;
}
Program: 34440
Project: 34440
Buggy source:
/** 
 * REGION ReadInterface
 */
public synchronized Integer getStartStatesTaskCount(String taskRoleName){
  int unassociatedTastCount=0;
  List<TaskStatus> taskStatusList=taskStatuseses.get(taskRoleName).getTaskStatusArray();
  for (  TaskStatus taskStatus : taskStatusList) {
    if (!TaskStateDefinition.START_STATES.contains(taskStatus.getTaskState())) {
      unassociatedTastCount++;
    }
  }
  return unassociatedTastCount;
}

Fixed version (ground truth):
/** 
 * REGION ReadInterface
 */
public synchronized Integer getStartStatesTaskCount(String taskRoleName){
  int startStatesTaskCount=0;
  List<TaskStatus> taskStatusList=taskStatuseses.get(taskRoleName).getTaskStatusArray();
  for (  TaskStatus taskStatus : taskStatusList) {
    if (TaskStateDefinition.START_STATES.contains(taskStatus.getTaskState())) {
      startStatesTaskCount++;
    }
  }
  return startStatesTaskCount;
}
Program: 34441
Project: 34441
Buggy source:
private void removeContainerRequest(TaskStatus taskStatus){
  TaskStatusLocator taskLocator=new TaskStatusLocator(taskStatus.getTaskRoleName(),taskStatus.getTaskIndex());
  if (!statusManager.containsTask(taskLocator)) {
    return;
  }
  ContainerRequest request=statusManager.getContainerRequest(taskLocator);
  if (request == null) {
    return;
  }
  try {
    rmClient.removeContainerRequest(request);
  }
 catch (  Exception e) {
    LOGGER.logError(e,"String_Node_Str",taskLocator);
  }
  try {
    gpuAllocationManager.removeContainerRequest(request);
  }
 catch (  Exception e) {
    LOGGER.logError(e,"String_Node_Str",taskLocator);
  }
}

Fixed version (ground truth):
private void removeContainerRequest(TaskStatus taskStatus){
  TaskStatusLocator taskLocator=new TaskStatusLocator(taskStatus.getTaskRoleName(),taskStatus.getTaskIndex());
  if (!statusManager.containsTask(taskLocator)) {
    return;
  }
  ContainerRequest request=statusManager.getContainerRequest(taskLocator);
  if (request == null) {
    return;
  }
  try {
    rmClient.removeContainerRequest(request);
  }
 catch (  Exception e) {
    LOGGER.logError(e,"String_Node_Str",taskLocator);
  }
  try {
    selectionManager.removeContainerRequest(request);
  }
 catch (  Exception e) {
    LOGGER.logError(e,"String_Node_Str",taskLocator);
  }
}
Program: 34442
Project: 34442
Buggy source:
public void onNodesUpdated(List<NodeReport> nodeReports){
  if (nodeReports.size() <= 0) {
    return;
  }
  LOGGER.logDebug("String_Node_Str",nodeReports.size());
  transitionTaskStateQueue.queueSystemTask(() -> {
    updateNodeReport(nodeReports);
  }
);
}

Fixed version (ground truth):
public void onNodesUpdated(List<NodeReport> nodeReports){
  if (nodeReports.size() <= 0) {
    return;
  }
  LOGGER.logDebug("String_Node_Str",nodeReports.size());
  transitionTaskStateQueue.queueSystemTask(() -> {
    updateNodeReports(nodeReports);
  }
);
}
Program: 34443
Project: 34443
Buggy source:
private ContainerRequest setupContainerRequest(TaskStatus taskStatus) throws Exception {
  String taskRoleName=taskStatus.getTaskRoleName();
  Priority priority=statusManager.getNextContainerRequestPriority();
  String nodeLabel=requestManager.getTaskPlatParams().get(taskRoleName).getTaskNodeLabel();
  String nodeGpuType=requestManager.getTaskPlatParams().get(taskRoleName).getTaskNodeGpuType();
  ResourceDescriptor resource=YamlUtils.deepCopy(requestManager.getTaskResources().get(taskRoleName),ResourceDescriptor.class);
  ResourceDescriptor maxResource=conf.getMaxResource();
  if (resource.getMemoryMB() > maxResource.getMemoryMB() || resource.getCpuNumber() > maxResource.getCpuNumber() || resource.getGpuNumber() > maxResource.getGpuNumber()) {
    LOGGER.logWarning("String_Node_Str" + "String_Node_Str" + "String_Node_Str",resource,maxResource);
  }
  if (resource.getGpuNumber() > 0) {
    updateNodeReport(yarnClient.getNodeReports(NodeState.RUNNING));
    GpuAllocation gpuAllocation=gpuAllocationManager.selectCandidateRequestNode(resource,nodeLabel,nodeGpuType);
    if (gpuAllocation != null) {
      resource.setGpuAttribute(gpuAllocation.getGpuBitmap());
      return HadoopUtils.toContainerRequest(resource,priority,null,gpuAllocation.getNodeName());
    }
 else {
      LOGGER.logWarning("String_Node_Str");
    }
  }
  return HadoopUtils.toContainerRequest(resource,priority,nodeLabel,null);
}

Fixed version (ground truth):
private ContainerRequest setupContainerRequest(TaskStatus taskStatus) throws Exception {
  String taskRoleName=taskStatus.getTaskRoleName();
  Priority requestPriority=statusManager.getNextContainerRequestPriority();
  String requestNodeLabel=requestManager.getTaskPlatParams().get(taskRoleName).getTaskNodeLabel();
  String requestNodeGpuType=requestManager.getTaskPlatParams().get(taskRoleName).getTaskNodeGpuType();
  ResourceDescriptor requestResource=requestManager.getTaskResources().get(taskRoleName);
  ResourceDescriptor maxResource=conf.getMaxResource();
  if (requestResource.getMemoryMB() > maxResource.getMemoryMB() || requestResource.getCpuNumber() > maxResource.getCpuNumber() || requestResource.getGpuNumber() > maxResource.getGpuNumber()) {
    LOGGER.logWarning("String_Node_Str" + "String_Node_Str" + "String_Node_Str",requestResource,maxResource);
  }
  if (requestResource.getGpuNumber() > 0) {
    updateNodeReports(yarnClient.getNodeReports(NodeState.RUNNING));
    SelectionResult selectionResult=selectionManager.select(requestResource,requestNodeLabel,requestNodeGpuType);
    if (selectionResult != null) {
      ResourceDescriptor optimizedRequestResource=YamlUtils.deepCopy(requestResource,ResourceDescriptor.class);
      optimizedRequestResource.setGpuAttribute(selectionResult.getGpuAttribute());
      return HadoopUtils.toContainerRequest(optimizedRequestResource,requestPriority,null,selectionResult.getNodeHost());
    }
 else {
      LOGGER.logWarning("String_Node_Str");
    }
  }
  return HadoopUtils.toContainerRequest(requestResource,requestPriority,requestNodeLabel,null);
}
Program: 34444
Project: 34444
Buggy source:
@Override protected void initialize() throws Exception {
  super.initialize();
  transitionTaskStateQueue=new SystemTaskQueue(this::handleException);
  conf.initializeNoDependenceConfig();
  rmClient=AMRMClientAsync.createAMRMClientAsync(conf.getAmRmHeartbeatIntervalSec() * 1000,new RMClientCallbackHandler(this));
  rmClient.init(conf.getYarnConfig());
  rmClient.start();
  conf.initializeDependOnRMResponseConfig(registerToRM());
  nmClient=NMClientAsync.createNMClientAsync(new NMClientCallbackHandler(this));
  nmClient.init(conf.getYarnConfig());
  nmClient.start();
  yarnClient=YarnClient.createYarnClient();
  yarnClient.init(conf.getYarnConfig());
  yarnClient.start();
  conf.initializeDependOnYarnClientConfig(yarnClient);
  zkStore=new ZookeeperStore(conf.getZkConnectString(),conf.getZkRootDir());
  conf.initializeDependOnZKStoreConfig(zkStore);
  hdfsStore=new HdfsStore(conf.getLauncherConfig().getHdfsRootDir());
  hdfsStore.makeFrameworkRootDir(conf.getFrameworkName());
  hdfsStore.makeAMStoreRootDir(conf.getFrameworkName());
  launcherClient=new LauncherClientInternal(conf.getLauncherConfig().getWebServerAddress(),30,10,LaunchClientType.APPLICATION_MASTER);
  gpuAllocationManager=new GpuAllocationManager(this);
  rmResyncHandler=new RMResyncHandler(this,conf);
}

Fixed version (ground truth):
@Override protected void initialize() throws Exception {
  super.initialize();
  transitionTaskStateQueue=new SystemTaskQueue(this::handleException);
  conf.initializeNoDependenceConfig();
  rmClient=AMRMClientAsync.createAMRMClientAsync(conf.getAmRmHeartbeatIntervalSec() * 1000,new RMClientCallbackHandler(this));
  rmClient.init(conf.getYarnConfig());
  rmClient.start();
  conf.initializeDependOnRMResponseConfig(registerToRM());
  nmClient=NMClientAsync.createNMClientAsync(new NMClientCallbackHandler(this));
  nmClient.init(conf.getYarnConfig());
  nmClient.start();
  yarnClient=YarnClient.createYarnClient();
  yarnClient.init(conf.getYarnConfig());
  yarnClient.start();
  conf.initializeDependOnYarnClientConfig(yarnClient);
  zkStore=new ZookeeperStore(conf.getZkConnectString(),conf.getZkRootDir());
  conf.initializeDependOnZKStoreConfig(zkStore);
  hdfsStore=new HdfsStore(conf.getLauncherConfig().getHdfsRootDir());
  hdfsStore.makeFrameworkRootDir(conf.getFrameworkName());
  hdfsStore.makeAMStoreRootDir(conf.getFrameworkName());
  launcherClient=new LauncherClientInternal(conf.getLauncherConfig().getWebServerAddress(),30,10,LaunchClientType.APPLICATION_MASTER);
  selectionManager=new SelectionManager(this);
  rmResyncHandler=new RMResyncHandler(this,conf);
}
Program: 34445
Project: 34445
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + this.host + "String_Node_Str"+ CommonExtensions.toString(this.labels)+ "String_Node_Str"+ this.totalResource+ "String_Node_Str"+ this.usedResource+ "String_Node_Str"+ this.requestedResource+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + host + "String_Node_Str"+ CommonExtensions.toString(labels)+ "String_Node_Str"+ totalResource+ "String_Node_Str"+ usedResource+ "String_Node_Str"+ requestedResource+ "String_Node_Str";
}
Program: 34446
Project: 34446
Buggy source:
@VisibleForTesting public synchronized void removeCandidateNode(Node reportedNode){
  if (candidateNodes.containsKey(reportedNode.getHost())) {
    LOGGER.logInfo("String_Node_Str",reportedNode);
    candidateNodes.remove(reportedNode.getHost());
  }
}

Fixed version (ground truth):
@VisibleForTesting public synchronized void removeCandidateNode(Node reportedNode){
  if (candidateNodes.containsKey(reportedNode.getHost())) {
    LOGGER.logDebug("String_Node_Str",reportedNode);
    candidateNodes.remove(reportedNode.getHost());
  }
}
Program: 34448
Project: 34448
Buggy source:
public void addContainerRequest(ResourceDescriptor resource,List<String> nodeList) throws Exception {
  for (  String nodeName : nodeList) {
    if (!candidateRequestNodes.containsKey(nodeName)) {
      LOGGER.logWarning("String_Node_Str" + nodeName);
      continue;
    }
    candidateRequestNodes.get(nodeName).addContainerRequest(resource);
  }
  return;
}

Fixed version (ground truth):
public void addContainerRequest(ResourceDescriptor resource,List<String> nodeList){
  for (  String nodeName : nodeList) {
    if (!candidateRequestNodes.containsKey(nodeName)) {
      LOGGER.logWarning("String_Node_Str" + nodeName);
      continue;
    }
    candidateRequestNodes.get(nodeName).addContainerRequest(resource);
  }
}
Program: 34450
Project: 34450
Buggy source:
private static FileStatus getFileStatusInHdfsInternal(String hdfsPath) throws Exception {
  try {
    FileSystem fs=FileSystem.get(conf);
    LOGGER.logInfo("String_Node_Str",hdfsPath);
    FileStatus fileStatus=fs.getFileStatus(new Path(hdfsPath));
    return fileStatus;
  }
 catch (  PathNotFoundException e) {
    throw new NonTransientException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private static FileStatus getFileStatusInHdfsInternal(String hdfsPath) throws Exception {
  try {
    FileSystem fs=FileSystem.get(conf);
    LOGGER.logInfo("String_Node_Str",hdfsPath);
    FileStatus fileStatus=fs.getFileStatus(new Path(hdfsPath));
    return fileStatus;
  }
 catch (  PathNotFoundException|FileNotFoundException e) {
    throw new NonTransientException("String_Node_Str",e);
  }
}
Program: 34451
Project: 34451
Buggy source:
private void gcCompletedFrameworks(Map<String,FrameworkStatus> completedFrameworkStatuses) throws Exception {
  Long currentTimestamp=System.currentTimeMillis();
  for (  FrameworkStatus completedFrameworkStatus : completedFrameworkStatuses.values()) {
    String frameworkName=completedFrameworkStatus.getFrameworkName();
    Integer frameworkVersion=completedFrameworkStatus.getFrameworkVersion();
    Long frameworkCompletedTimestamp=completedFrameworkStatus.getFrameworkCompletedTimestamp();
    if (!aggFrameworkRequests.containsKey(frameworkName)) {
      continue;
    }
    FrameworkRequest frameworkRequest=aggFrameworkRequests.get(frameworkName).getFrameworkRequest();
    if (frameworkRequest.getFrameworkDescriptor().getVersion().equals(frameworkVersion)) {
      continue;
    }
    if (frameworkRequest.getLaunchClientType() == LaunchClientType.DATA_DEPLOYMENT) {
      continue;
    }
    if (currentTimestamp - frameworkCompletedTimestamp <= conf.getFrameworkCompletedRetainSec()) {
      continue;
    }
    LOGGER.logInfo("String_Node_Str" + "String_Node_Str",frameworkName,frameworkCompletedTimestamp,conf.getFrameworkCompletedRetainSec(),currentTimestamp);
    deleteFrameworkRequest(frameworkName);
  }
}

Fixed version (ground truth):
private void gcCompletedFrameworks(Map<String,FrameworkStatus> completedFrameworkStatuses) throws Exception {
  Long currentTimestamp=System.currentTimeMillis();
  for (  FrameworkStatus completedFrameworkStatus : completedFrameworkStatuses.values()) {
    String frameworkName=completedFrameworkStatus.getFrameworkName();
    Integer frameworkVersion=completedFrameworkStatus.getFrameworkVersion();
    Long frameworkCompletedTimestamp=completedFrameworkStatus.getFrameworkCompletedTimestamp();
    if (!aggFrameworkRequests.containsKey(frameworkName)) {
      continue;
    }
    FrameworkRequest frameworkRequest=aggFrameworkRequests.get(frameworkName).getFrameworkRequest();
    if (!frameworkRequest.getFrameworkDescriptor().getVersion().equals(frameworkVersion)) {
      continue;
    }
    if (frameworkRequest.getLaunchClientType() == LaunchClientType.DATA_DEPLOYMENT) {
      continue;
    }
    if (currentTimestamp - frameworkCompletedTimestamp <= conf.getFrameworkCompletedRetainSec() * 1000) {
      continue;
    }
    LOGGER.logInfo("String_Node_Str" + "String_Node_Str",frameworkName,frameworkCompletedTimestamp,conf.getFrameworkCompletedRetainSec(),currentTimestamp);
    deleteFrameworkRequest(frameworkName);
  }
}
Program: 34452
Project: 34452
Buggy source:
/** 
 * setEquals determines whether two string sets are identical.
 * @param a the first set.
 * @param b the second set.
 * @return whether a equals to b.
 */
public static boolean setEquals(List<String> a,List<String> b){
  if (a.size() != b.size()) {
    return false;
  }
  Collections.sort(a);
  Collections.sort(b);
  for (int i=0; i < a.size(); i++) {
    if (!a.get(i).equals(b.get(i))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * setEquals determines whether two string sets are identical.
 * @param a the first set.
 * @param b the second set.
 * @return whether a equals to b.
 */
public static boolean setEquals(List<String> a,List<String> b){
  if (a == null) {
    a=new ArrayList<>();
  }
  if (b == null) {
    b=new ArrayList<>();
  }
  if (a.size() != b.size()) {
    return false;
  }
  Collections.sort(a);
  Collections.sort(b);
  for (int i=0; i < a.size(); i++) {
    if (!a.get(i).equals(b.get(i))) {
      return false;
    }
  }
  return true;
}
Program: 34453
Project: 34453
Buggy source:
/** 
 * arrayEquals determines whether two string arrays are identical.
 * @param a the first array.
 * @param b the second array.
 * @return whether a equals to b.
 */
public static boolean arrayEquals(List<String> a,List<String> b){
  if (a.size() != b.size()) {
    return false;
  }
  for (int i=0; i < a.size(); i++) {
    if (!a.get(i).equals(b.get(i))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * arrayEquals determines whether two string arrays are identical.
 * @param a the first array.
 * @param b the second array.
 * @return whether a equals to b.
 */
public static boolean arrayEquals(List<String> a,List<String> b){
  if (a == null) {
    a=new ArrayList<>();
  }
  if (b == null) {
    b=new ArrayList<>();
  }
  if (a.size() != b.size()) {
    return false;
  }
  for (int i=0; i < a.size(); i++) {
    if (!a.get(i).equals(b.get(i))) {
      return false;
    }
  }
  return true;
}
Program: 34454
Project: 34454
Buggy source:
/** 
 * array2DEquals determines whether two 2-dimensional string arrays are identical.
 * @param a the first 2-dimensional array.
 * @param b the second 2-dimensional array.
 * @return whether a equals to b.
 */
public static boolean array2DEquals(List<List<String>> a,List<List<String>> b){
  if (a.size() != b.size()) {
    return false;
  }
  for (int i=0; i < a.size(); i++) {
    if (!arrayEquals(a.get(i),b.get(i))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * array2DEquals determines whether two 2-dimensional string arrays are identical.
 * @param a the first 2-dimensional array.
 * @param b the second 2-dimensional array.
 * @return whether a equals to b.
 */
public static boolean array2DEquals(List<List<String>> a,List<List<String>> b){
  if (a == null) {
    a=new ArrayList<>();
  }
  if (b == null) {
    b=new ArrayList<>();
  }
  if (a.size() != b.size()) {
    return false;
  }
  for (int i=0; i < a.size(); i++) {
    if (!arrayEquals(a.get(i),b.get(i))) {
      return false;
    }
  }
  return true;
}
Program: 34455
Project: 34455
Buggy source:
private Role createRole(String name){
  return allRoles.getOrDefault(name,new Role(name));
}

Fixed version (ground truth):
private Role createRole(String name){
  if (hasRole(name)) {
    return allRoles.get(name);
  }
 else {
    Role role=new Role(name);
    allRoles.put(name,role);
    return role;
  }
}
Program: 34456
Project: 34456
Buggy source:
public void testEnforce(Enforcer e,String sub,String obj,String act,boolean res){
  assertEquals(e.enforce(sub,obj,act),res);
}

Fixed version (ground truth):
public void testEnforce(Enforcer e,String sub,String obj,String act,boolean res){
  assertEquals(res,e.enforce(sub,obj,act));
}
Program: 34457
Project: 34457
Buggy source:
public void testEnforce(Enforcer e,String sub,String obj,String act,boolean res){
  assertEquals(e.enforce(sub,obj,act),res);
}

Fixed version (ground truth):
public void testEnforce(Enforcer e,String sub,String obj,String act,boolean res){
  assertEquals(res,e.enforce(sub,obj,act));
}
Program: 34458
Project: 34458
Buggy source:
public void testEnforceWithoutUsers(Enforcer e,String obj,String act,boolean res){
  assertEquals(e.enforce(obj,act),res);
}

Fixed version (ground truth):
public void testEnforceWithoutUsers(Enforcer e,String obj,String act,boolean res){
  assertEquals(res,e.enforce(obj,act));
}
Program: 34459
Project: 34459
Buggy source:
/** 
 * ipMatch determines whether IP address ip1 matches the pattern of IP address ip2, ip2 can be an IP address or a CIDR pattern. For example, "192.168.2.123" matches "192.168.2.0/24"
 */
public static boolean ipMatch(String ip1,String ip2){
  IPAddressString ipas1=new IPAddressString(ip1);
  try {
    ipas1.validateIPv4();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  IPAddressString ipas2=new IPAddressString(ip2);
  try {
    ipas2.validate();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  if (ipas1.equals(ipas2)) {
    return true;
  }
  IPAddress ipa1;
  IPAddress ipa2;
  try {
    ipa1=ipas1.toAddress();
    ipa2=ipas2.toAddress();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  Integer prefix=ipa2.getNetworkPrefixLength();
  IPAddress mask=ipa2.getNetwork().getNetworkMask(prefix,false);
  return ipa1.mask(mask).equals(ipa2);
}

Fixed version (ground truth):
/** 
 * ipMatch determines whether IP address ip1 matches the pattern of IP address ip2, ip2 can be an IP address or a CIDR pattern. For example, "192.168.2.123" matches "192.168.2.0/24"
 */
public static boolean ipMatch(String ip1,String ip2){
  IPAddressString ipas1=new IPAddressString(ip1);
  try {
    ipas1.validateIPv4();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  IPAddressString ipas2=new IPAddressString(ip2);
  try {
    ipas2.validate();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  if (ipas1.equals(ipas2)) {
    return true;
  }
  IPAddress ipa1;
  IPAddress ipa2;
  try {
    ipa1=ipas1.toAddress();
    ipa2=ipas2.toAddress();
  }
 catch (  AddressStringException e) {
    e.printStackTrace();
    throw new Error("String_Node_Str");
  }
  Integer prefix=ipa2.getNetworkPrefixLength();
  IPAddress mask=ipa2.getNetwork().getNetworkMask(prefix,false);
  return ipa1.mask(mask).equals(ipas2.getHostAddress());
}
Program: 34460
Project: 34460
Buggy source:
protected void deleteRole(Role role){
  for (  Role r : roles) {
    if (r.name.equals(role.name)) {
      roles.remove(r);
    }
  }
}

Fixed version (ground truth):
void deleteRole(Role role){
  for (  Role r : roles) {
    if (r.name.equals(role.name)) {
      roles.remove(r);
    }
  }
}
Program: 34461
Project: 34461
Buggy source:
protected boolean hasDirectRole(String name){
  for (  Role r : roles) {
    if (r.name.equals(name)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean hasDirectRole(String name){
  for (  Role r : roles) {
    if (r.name.equals(name)) {
      return true;
    }
  }
  return false;
}
Program: 34462
Project: 34462
Buggy source:
protected boolean hasRole(String name,int hierarchyLevel){
  if (name.equals(name)) {
    return true;
  }
  if (hierarchyLevel <= 0) {
    return false;
  }
  for (  Role role : roles) {
    if (role.hasRole(name,hierarchyLevel - 1)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean hasRole(String name,int hierarchyLevel){
  if (this.name.equals(name)) {
    return true;
  }
  if (hierarchyLevel <= 0) {
    return false;
  }
  for (  Role role : roles) {
    if (role.hasRole(name,hierarchyLevel - 1)) {
      return true;
    }
  }
  return false;
}
Program: 34463
Project: 34463
Buggy source:
protected void addRole(Role role){
  for (  Role r : roles) {
    if (r.name.equals(role.name)) {
      return;
    }
  }
  roles.add(role);
}

Fixed version (ground truth):
void addRole(Role role){
  for (  Role r : roles) {
    if (r.name.equals(role.name)) {
      return;
    }
  }
  roles.add(role);
}
Program: 34464
Project: 34464
Buggy source:
protected List<String> getRoles(){
  List<String> names=new ArrayList<>();
  for (  Role r : roles) {
    names.add(r.name);
  }
  return names;
}

Fixed version (ground truth):
List<String> getRoles(){
  List<String> names=new ArrayList<>();
  for (  Role r : roles) {
    names.add(r.name);
  }
  return names;
}
Program: 34465
Project: 34465
Buggy source:
/** 
 * escapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.
 */
public static String escapeAssertion(String s){
  s=s.replaceAll("String_Node_Str","String_Node_Str");
  s=s.replaceAll("String_Node_Str","String_Node_Str");
  return s;
}

Fixed version (ground truth):
/** 
 * escapeAssertion escapes the dots in the assertion, because the expression evaluation doesn't support such variable names.
 */
public static String escapeAssertion(String s){
  s=s.replace("String_Node_Str","String_Node_Str");
  s=s.replace("String_Node_Str","String_Node_Str");
  return s;
}
Program: 34466
Project: 34466
Buggy source:
public String get(String key){
  String section;
  String option;
  String[] keys=key.toLowerCase().split("String_Node_Str");
  if (keys.length >= 2) {
    section=keys[0];
    option=keys[1];
  }
 else {
    section=DEFAULT_SECTION;
    option=keys[0];
  }
  boolean ok=data.get(section).containsKey(option);
  if (ok) {
    return data.get(section).get(option);
  }
 else {
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
public String get(String key){
  String section;
  String option;
  String[] keys=key.toLowerCase().split("String_Node_Str");
  if (keys.length >= 2) {
    section=keys[0];
    option=keys[1];
  }
 else {
    section=DEFAULT_SECTION;
    option=keys[0];
  }
  boolean ok=data.containsKey(section) && data.get(section).containsKey(option);
  if (ok) {
    return data.get(section).get(option);
  }
 else {
    return "String_Node_Str";
  }
}
Program: 34467
Project: 34467
Buggy source:
/** 
 * setWatcher sets the current watcher.
 */
public void setWatcher(Watcher watcher){
  this.watcher=watcher;
  watcher.setUpdateCallback(loadPolicy());
}

Fixed version (ground truth):
/** 
 * setWatcher sets the current watcher.
 */
public void setWatcher(Watcher watcher){
  this.watcher=watcher;
  watcher.setUpdateCallback(this::loadPolicy);
}
Program: 34468
Project: 34468
Buggy source:
/** 
 * SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances. A classic callback is Enforcer.LoadPolicy().
 */
public void setUpdateCallback(Method callback);

Fixed version (ground truth):
/** 
 * SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances. A classic callback is Enforcer.LoadPolicy().
 */
void setUpdateCallback(Runnable runnable);
Program: 34469
Project: 34469
Buggy source:
/** 
 * Update calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.
 */
public void update();

Fixed version (ground truth):
/** 
 * Update calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.
 */
void update();
Program: 34470
Project: 34470
Buggy source:
/** 
 * DefaultRoleManager is the constructor for creating an instance of the default RoleManager implementation.
 */
public DefaultRoleManager(int maxHierarchyLevel){
  allRoles=new HashMap<>();
  maxHierarchyLevel=maxHierarchyLevel;
}

Fixed version (ground truth):
/** 
 * DefaultRoleManager is the constructor for creating an instance of the default RoleManager implementation.
 */
public DefaultRoleManager(int maxHierarchyLevel){
  allRoles=new HashMap<>();
  this.maxHierarchyLevel=maxHierarchyLevel;
}
Program: 34471
Project: 34471
Buggy source:
/** 
 * DefaultRoleManager is the constructor for creating an instance of the default RoleManager implementation.
 */
public DefaultRoleManager(int level){
  this.allRoles=new HashMap<>();
  this.level=level;
}

Fixed version (ground truth):
/** 
 * DefaultRoleManager is the constructor for creating an instance of the default RoleManager implementation.
 */
public DefaultRoleManager(int level){
  this.allRoles=new HashMap<String,Role>();
  this.level=level;
}
Program: 34473
Project: 34473
Buggy source:
private void handleProxyData(Channel channel,Object msg,boolean isHttp) throws Exception {
  if (cf == null) {
    if (isHttp && !(msg instanceof HttpRequest)) {
      return;
    }
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto requestProto=new RequestProto(host,port,isSsl);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,requestProto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(serverConfig.getLoopGroup()).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    requestList=new LinkedList();
    cf=bootstrap.connect(host,port);
    cf.addListener((ChannelFutureListener)future -> {
      if (future.isSuccess()) {
        future.channel().writeAndFlush(msg);
synchronized (requestList) {
          requestList.forEach((obj) -> future.channel().write(obj));
          isConnect=true;
        }
      }
 else {
        future.channel().close();
        channel.close();
      }
    }
);
  }
 else {
synchronized (requestList) {
      if (isConnect) {
        cf.channel().writeAndFlush(msg);
      }
 else {
        requestList.add(msg);
      }
    }
  }
}

Fixed version (ground truth):
private void handleProxyData(Channel channel,Object msg,boolean isHttp) throws Exception {
  if (cf == null) {
    if (isHttp && !(msg instanceof HttpRequest)) {
      return;
    }
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto requestProto=new RequestProto(host,port,isSsl);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,requestProto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(serverConfig.getLoopGroup()).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    requestList=new LinkedList();
    cf=bootstrap.connect(host,port);
    cf.addListener((ChannelFutureListener)future -> {
      if (future.isSuccess()) {
        future.channel().writeAndFlush(msg);
synchronized (requestList) {
          requestList.forEach((obj) -> future.channel().write(obj));
          requestList.clear();
          isConnect=true;
        }
      }
 else {
        future.channel().close();
        channel.close();
      }
    }
);
  }
 else {
synchronized (requestList) {
      if (isConnect) {
        cf.channel().writeAndFlush(msg);
      }
 else {
        requestList.add(msg);
      }
    }
  }
}
Program: 34474
Project: 34474
Buggy source:
public static RequestProto getRequestProto(HttpRequest httpRequest){
  RequestProto requestProto=new RequestProto();
  int port=-1;
  String hostStr=httpRequest.headers().get(HttpHeaderNames.HOST);
  if (hostStr == null) {
    return null;
  }
  String uriStr=httpRequest.uri();
  Pattern pattern=Pattern.compile("String_Node_Str");
  Matcher matcher=pattern.matcher(hostStr);
  String portTemp=null;
  if (matcher.find()) {
    requestProto.setHost(matcher.group("String_Node_Str"));
    portTemp=matcher.group("String_Node_Str");
    if (portTemp == null) {
      matcher=pattern.matcher(uriStr);
      if (matcher.find()) {
        portTemp=matcher.group("String_Node_Str");
      }
    }
  }
  if (portTemp != null) {
    port=Integer.parseInt(portTemp);
  }
  boolean isSsl=uriStr.indexOf("String_Node_Str") == 0 || hostStr.indexOf("String_Node_Str") == 0;
  if (port == -1) {
    if (isSsl) {
      port=443;
    }
 else {
      port=80;
    }
  }
  requestProto.setPort(port);
  requestProto.setSsl(isSsl);
  return requestProto;
}

Fixed version (ground truth):
public static RequestProto getRequestProto(HttpRequest httpRequest){
  RequestProto requestProto=new RequestProto();
  int port=-1;
  String hostStr=httpRequest.headers().get(HttpHeaderNames.HOST);
  if (hostStr == null) {
    Pattern pattern=Pattern.compile("String_Node_Str");
    Matcher matcher=pattern.matcher(httpRequest.uri());
    if (matcher.find()) {
      hostStr=matcher.group("String_Node_Str");
    }
 else {
      return null;
    }
  }
  String uriStr=httpRequest.uri();
  Pattern pattern=Pattern.compile("String_Node_Str");
  Matcher matcher=pattern.matcher(hostStr);
  String portTemp=null;
  if (matcher.find()) {
    requestProto.setHost(matcher.group("String_Node_Str"));
    portTemp=matcher.group("String_Node_Str");
    if (portTemp == null) {
      matcher=pattern.matcher(uriStr);
      if (matcher.find()) {
        portTemp=matcher.group("String_Node_Str");
      }
    }
  }
  if (portTemp != null) {
    port=Integer.parseInt(portTemp);
  }
  boolean isSsl=uriStr.indexOf("String_Node_Str") == 0 || hostStr.indexOf("String_Node_Str") == 0;
  if (port == -1) {
    if (isSsl) {
      port=443;
    }
 else {
      port=80;
    }
  }
  requestProto.setPort(port);
  requestProto.setSsl(isSsl);
  return requestProto;
}
Program: 34475
Project: 34475
Buggy source:
private void handleProxyData(final Channel channel,final Object msg,boolean isHttp) throws Exception {
  if (cf == null) {
    if (!(msg instanceof HttpRequest)) {
      return;
    }
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto proto=ProtoUtil.getRequestProto((HttpRequest)msg);
    proto.setSsl(isSSL);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,proto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(HttpProxyServer.proxyGroup).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    cf=bootstrap.connect(host,port).sync();
  }
  cf.channel().writeAndFlush(msg);
}

Fixed version (ground truth):
private void handleProxyData(Channel channel,Object msg,boolean isHttp) throws Exception {
  if (cf == null) {
    if (isHttp && !(msg instanceof HttpRequest)) {
      return;
    }
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto proto=new RequestProto(host,port,isSSL);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,proto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(HttpProxyServer.proxyGroup).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    cf=bootstrap.connect(host,port).sync();
  }
  cf.channel().writeAndFlush(msg);
}
Program: 34476
Project: 34476
Buggy source:
private void handleProxyData(final Channel channel,final Object msg,boolean isHttp) throws InterruptedException {
  if (cf == null) {
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto proto=ProtoUtil.getRequestProto((HttpRequest)msg);
    proto.setSsl(isSSL);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,proto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(HttpProxyServer.proxyGroup).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    cf=bootstrap.connect(host,port).sync();
  }
  cf.channel().writeAndFlush(msg);
}

Fixed version (ground truth):
private void handleProxyData(final Channel channel,final Object msg,boolean isHttp) throws InterruptedException {
  if (!channel.isOpen()) {
    return;
  }
  if (cf == null) {
    ProxyHandler proxyHandler=ProxyHandleFactory.build(proxyConfig);
    RequestProto proto=ProtoUtil.getRequestProto((HttpRequest)msg);
    proto.setSsl(isSSL);
    ChannelInitializer channelInitializer=isHttp ? new HttpProxyInitializer(channel,proto,proxyHandler) : new TunnelProxyInitializer(channel,proxyHandler);
    Bootstrap bootstrap=new Bootstrap();
    bootstrap.group(HttpProxyServer.proxyGroup).channel(NioSocketChannel.class).handler(channelInitializer);
    if (proxyConfig != null) {
      bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
    }
    cf=bootstrap.connect(host,port).sync();
  }
  cf.channel().writeAndFlush(msg);
}
Program: 34477
Project: 34477
Buggy source:
public static void main(String[] args) throws Exception {
  new HttpProxyServer().start(9999);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  new HttpProxyServer().proxyInterceptFactory(() -> new HttpProxyIntercept(){
    @Override public boolean beforeRequest(    Channel clientChannel,    HttpRequest httpRequest){
      httpRequest.headers().set(HttpHeaderNames.USER_AGENT,"String_Node_Str");
      return true;
    }
    @Override public boolean afterResponse(    Channel clientChannel,    Channel proxyChannel,    HttpResponse httpResponse){
      httpResponse.headers().add("String_Node_Str","String_Node_Str");
      return true;
    }
  }
).start(9999);
}