Program: 91740
Project: 91740
Buggy source:
public void getTaskData(Set<String> taskIds,TaskRepository taskRepository,TaskDataCollector collector,IOperationMonitor monitor) throws OSIORestException {
  OSIORestConfiguration config;
  try {
    config=connector.getRepositoryConfiguration(taskRepository);
  }
 catch (  CoreException e1) {
    throw new OSIORestException(e1);
  }
  for (  String taskId : taskIds) {
    if (taskId.isEmpty()) {
      continue;
    }
    String user=userName;
    String[] tokens=taskId.split("String_Node_Str");
    String spaceName=tokens[0];
    String[] spaceTokens=spaceName.split("String_Node_Str");
    if (spaceTokens.length > 1) {
      spaceName=spaceTokens[1];
      user=spaceTokens[0];
    }
    String wiNumber=tokens[1];
    try {
      user=URLQueryEncoder.transform(user);
      String query="String_Node_Str" + user + "String_Node_Str"+ spaceName+ "String_Node_Str"+ wiNumber;
      String wid="String_Node_Str";
      try {
        wid=new OSIORestGetWID(client,query,taskRepository).run(monitor);
      }
 catch (      OSIORestResourceMovedPermanentlyException e) {
        Header h=e.getHeader();
        HeaderElement[] elements=h.getElements();
        for (        HeaderElement element : elements) {
          if ("String_Node_Str".equals(element.getName())) {
            int index=element.getValue().indexOf("String_Node_Str");
            wid=element.getValue().substring(index + 9);
          }
        }
      }
      String workitemquery="String_Node_Str" + wid;
      TaskData taskData=new OSIORestGetSingleTaskData(client,connector,workitemquery,taskRepository).run(monitor);
      Map<String,Space> spaces=getCachedSpaces(monitor);
      Space space=spaces.get(spaceName);
      if (space == null) {
        Map<String,Space> externalSpaces=config.getExternalSpaces();
        space=externalSpaces.get(spaceName);
      }
      new OSIORestGetTaskComments(getClient(),space,taskData).run(monitor);
      new OSIORestGetTaskCreator(getClient(),taskData).run(monitor);
      new OSIORestGetTaskLabels(getClient(),space,taskData).run(monitor);
      new OSIORestGetTaskLinks(getClient(),this,space,taskData,config).run(monitor);
      setTaskAssignees(taskData);
      config.updateSpaceOptions(taskData);
      config.addValidOperations(taskData);
      collector.accept(taskData);
    }
 catch (    RuntimeException|CoreException e) {
      e.printStackTrace();
      Throwable cause=e.getCause();
      if (cause instanceof CoreException) {
        throw new OSIORestException(cause);
      }
    }
  }
}

Fixed version (ground truth):
public void getTaskData(Set<String> taskIds,TaskRepository taskRepository,TaskDataCollector collector,IOperationMonitor monitor) throws OSIORestException {
  OSIORestConfiguration config;
  try {
    config=connector.getRepositoryConfiguration(taskRepository);
  }
 catch (  CoreException e1) {
    throw new OSIORestException(e1);
  }
  for (  String taskId : taskIds) {
    if (taskId.isEmpty()) {
      continue;
    }
    String user=userName;
    String[] tokens=taskId.split("String_Node_Str");
    String spaceName=tokens[0];
    String[] spaceTokens=spaceName.split("String_Node_Str");
    if (spaceTokens.length > 1) {
      spaceName=spaceTokens[1];
      user=spaceTokens[0];
    }
    String wiNumber=tokens[1];
    try {
      user=URLQueryEncoder.transform(user);
      String query="String_Node_Str" + user + "String_Node_Str"+ spaceName+ "String_Node_Str"+ wiNumber;
      String wid="String_Node_Str";
      try {
        wid=new OSIORestGetWID(client,query,taskRepository).run(monitor);
      }
 catch (      OSIORestResourceMovedPermanentlyException e) {
        Header h=e.getHeader();
        HeaderElement[] elements=h.getElements();
        for (        HeaderElement element : elements) {
          if ("String_Node_Str".equals(element.getName())) {
            int index=element.getValue().indexOf("String_Node_Str");
            wid=element.getValue().substring(index + 9);
          }
        }
      }
      String workitemquery="String_Node_Str" + wid;
      TaskData taskData=new OSIORestGetSingleTaskData(client,connector,workitemquery,taskRepository).run(monitor);
      Map<String,Space> spaces=config.getSpaces();
      Space space=null;
      String spaceId=taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey()).getValue();
      space=getSpaceById(spaceId,taskRepository);
      new OSIORestGetTaskComments(getClient(),space,taskData).run(monitor);
      new OSIORestGetTaskCreator(getClient(),taskData).run(monitor);
      new OSIORestGetTaskLabels(getClient(),space,taskData).run(monitor);
      new OSIORestGetTaskLinks(getClient(),this,space,taskData,config).run(monitor);
      setTaskAssignees(taskData);
      config.updateSpaceOptions(taskData);
      config.addValidOperations(taskData);
      collector.accept(taskData);
    }
 catch (    RuntimeException|CoreException e) {
      e.printStackTrace();
      Throwable cause=e.getCause();
      if (cause instanceof CoreException) {
        throw new OSIORestException(cause);
      }
    }
  }
}