Program: 89233
Project: 89233
Buggy source:
/** 
 * Temp method to patch AMP'ed data
 */
private void patchLoadedData(){
  AuthenticationUtil.RunAsWork<Object> runAsWork=new AuthenticationUtil.RunAsWork<Object>(){
    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;
    }
  }
;
  AuthenticationUtil.runAs(runAsWork,AuthenticationUtil.getAdminUserName());
}

Fixed version (ground truth):
/** 
 * Temp method to patch AMP'ed data
 */
private void patchLoadedData(){
  AuthenticationUtil.RunAsWork<Object> runAsWork=new AuthenticationUtil.RunAsWork<Object>(){
    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;
    }
  }
;
  AuthenticationUtil.runAs(runAsWork,AuthenticationUtil.getAdminUserName());
}