Program: 89234
Project: 89234
Buggy source:
public Object doWork() throws Exception {
  Set<NodeRef> rmRoots=filePlanService.getFilePlans();
  logger.info("String_Node_Str" + rmRoots.size() + "String_Node_Str");
  for (  NodeRef rmRoot : rmRoots) {
    if (permissionService.getInheritParentPermissions(rmRoot)) {
      logger.info("String_Node_Str" + rmRoot);
      permissionService.setInheritParentPermissions(rmRoot,false);
    }
    String allRoleShortName=RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId();
    String allRoleGroupName=authorityService.getName(AuthorityType.GROUP,allRoleShortName);
    if (!authorityService.authorityExists(allRoleGroupName)) {
      logger.info("String_Node_Str" + rmRoot.toString());
      String allRoles=authorityService.createAuthority(AuthorityType.GROUP,allRoleShortName,RMAuthority.ALL_ROLES_DISPLAY_NAME,new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
      Set<Role> roles=filePlanRoleService.getRoles(rmRoot);
      for (      Role role : roles) {
        logger.info("String_Node_Str" + role.getRoleGroupName() + "String_Node_Str");
        authorityService.addAuthority(allRoles,role.getRoleGroupName());
      }
      permissionService.setPermission(rmRoot,allRoles,RMPermissionModel.READ_RECORDS,true);
    }
  }
  ResultSet rs=searchService.query(SPACES_STORE,SearchService.LANGUAGE_LUCENE,"String_Node_Str");
  try {
    logger.info("String_Node_Str" + rs.length() + "String_Node_Str");
    for (    NodeRef container : rs.getNodeRefs()) {
      String containerName=(String)nodeService.getProperty(container,ContentModel.PROP_NAME);
      if (permissionService.getInheritParentPermissions(container)) {
        logger.info("String_Node_Str" + containerName);
        permissionService.setInheritParentPermissions(container,false);
      }
    }
  }
  finally {
    rs.close();
  }
  rs=searchService.query(SPACES_STORE,SearchService.LANGUAGE_LUCENE,"String_Node_Str");
  try {
    logger.info("String_Node_Str" + rs.length() + "String_Node_Str");
    for (    NodeRef recordFolder : rs.getNodeRefs()) {
      String folderName=(String)nodeService.getProperty(recordFolder,ContentModel.PROP_NAME);
      if (permissionService.getInheritParentPermissions(recordFolder)) {
        logger.info("String_Node_Str" + folderName);
        permissionService.setInheritParentPermissions(recordFolder,false);
      }
      if (!nodeService.hasAspect(recordFolder,ASPECT_DISPOSITION_LIFECYCLE)) {
        DispositionSchedule ds=dispositionService.getDispositionSchedule(recordFolder);
        if (ds != null) {
          logger.info("String_Node_Str" + folderName);
          recordFolderService.setupRecordFolder(recordFolder);
        }
      }
      logger.info("String_Node_Str" + folderName);
      recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
    }
  }
  finally {
    rs.close();
  }
  return null;
}

Fixed version (ground truth):
public Object doWork(){
  Set<NodeRef> rmRoots=filePlanService.getFilePlans();
  logger.info("String_Node_Str" + rmRoots.size() + "String_Node_Str");
  for (  NodeRef rmRoot : rmRoots) {
    if (permissionService.getInheritParentPermissions(rmRoot)) {
      logger.info("String_Node_Str" + rmRoot);
      permissionService.setInheritParentPermissions(rmRoot,false);
    }
    String allRoleShortName=RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId();
    String allRoleGroupName=authorityService.getName(AuthorityType.GROUP,allRoleShortName);
    if (!authorityService.authorityExists(allRoleGroupName)) {
      logger.info("String_Node_Str" + rmRoot.toString());
      String allRoles=authorityService.createAuthority(AuthorityType.GROUP,allRoleShortName,RMAuthority.ALL_ROLES_DISPLAY_NAME,new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
      Set<Role> roles=filePlanRoleService.getRoles(rmRoot);
      for (      Role role : roles) {
        logger.info("String_Node_Str" + role.getRoleGroupName() + "String_Node_Str");
        authorityService.addAuthority(allRoles,role.getRoleGroupName());
      }
      permissionService.setPermission(rmRoot,allRoles,RMPermissionModel.READ_RECORDS,true);
    }
  }
  ResultSet rs=searchService.query(SPACES_STORE,SearchService.LANGUAGE_LUCENE,"String_Node_Str");
  try {
    logger.info("String_Node_Str" + rs.length() + "String_Node_Str");
    for (    NodeRef container : rs.getNodeRefs()) {
      String containerName=(String)nodeService.getProperty(container,ContentModel.PROP_NAME);
      if (permissionService.getInheritParentPermissions(container)) {
        logger.info("String_Node_Str" + containerName);
        permissionService.setInheritParentPermissions(container,false);
      }
    }
  }
  finally {
    rs.close();
  }
  rs=searchService.query(SPACES_STORE,SearchService.LANGUAGE_LUCENE,"String_Node_Str");
  try {
    logger.info("String_Node_Str" + rs.length() + "String_Node_Str");
    for (    NodeRef recordFolder : rs.getNodeRefs()) {
      String folderName=(String)nodeService.getProperty(recordFolder,ContentModel.PROP_NAME);
      if (permissionService.getInheritParentPermissions(recordFolder)) {
        logger.info("String_Node_Str" + folderName);
        permissionService.setInheritParentPermissions(recordFolder,false);
      }
      if (!nodeService.hasAspect(recordFolder,ASPECT_DISPOSITION_LIFECYCLE)) {
        DispositionSchedule ds=dispositionService.getDispositionSchedule(recordFolder);
        if (ds != null) {
          logger.info("String_Node_Str" + folderName);
          recordFolderService.setupRecordFolder(recordFolder);
        }
      }
      logger.info("String_Node_Str" + folderName);
      recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
    }
  }
  finally {
    rs.close();
  }
  return null;
}