Program: 37022
Project: 37022
Buggy source:
public SCIMResponse updateWithPATCH(String existingId,String scimObjectString,UserManager userManager,String attributes,String excludeAttributes){
  try {
    JSONDecoder decoder=getDecoder();
    JSONEncoder encoder=getEncoder();
    List<PatchOperation> opList=decoder.decodeRequest(scimObjectString);
    SCIMResourceTypeSchema schema=SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
    Group oldGroup=userManager.getGroup(existingId,ResourceManagerUtil.getAllAttributeURIs(schema));
    if (oldGroup == null) {
      throw new NotFoundException("String_Node_Str" + existingId + "String_Node_Str");
    }
    Group copyOfOldGroup=(Group)CopyUtil.deepCopy(oldGroup);
    Group originalGroup=(Group)CopyUtil.deepCopy(copyOfOldGroup);
    Group newGroup=null;
    for (    PatchOperation operation : opList) {
      if (operation.getOperation().equals(SCIMConstants.OperationalConstants.ADD)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchAdd(operation,getDecoder(),oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchAdd(operation,getDecoder(),newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else       if (operation.getOperation().equals(SCIMConstants.OperationalConstants.REMOVE)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchRemove(operation,oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchRemove(operation,newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else       if (operation.getOperation().equals(SCIMConstants.OperationalConstants.REPLACE)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchReplace(operation,getDecoder(),oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchReplace(operation,getDecoder(),newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else {
        throw new BadRequestException("String_Node_Str",ResponseCodeConstants.INVALID_SYNTAX);
      }
    }
    Map<String,Boolean> requiredAttributes=ResourceManagerUtil.getOnlyRequiredAttributesURIs((SCIMResourceTypeSchema)CopyUtil.deepCopy(schema),attributes,excludeAttributes);
    if (userManager != null) {
      if (oldGroup != null) {
        Group validatedGroup=(Group)ServerSideValidator.validateUpdatedSCIMObject(originalGroup,newGroup,schema);
        newGroup=userManager.updateGroup(originalGroup,validatedGroup,requiredAttributes);
      }
 else {
        String error="String_Node_Str" + existingId;
        throw new NotFoundException(error);
      }
    }
 else {
      String error="String_Node_Str";
      throw new InternalErrorException(error);
    }
    String encodedGroup;
    Map<String,String> httpHeaders=new HashMap<String,String>();
    if (newGroup != null) {
      Group copiedGroup=(Group)CopyUtil.deepCopy(newGroup);
      ServerSideValidator.validateReturnedAttributes(copiedGroup,attributes,excludeAttributes);
      encodedGroup=getEncoder().encodeSCIMObject(copiedGroup);
      httpHeaders.put(SCIMConstants.LOCATION_HEADER,getResourceEndpointURL(SCIMConstants.USER_ENDPOINT) + "String_Node_Str" + newGroup.getId());
      httpHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER,SCIMConstants.APPLICATION_JSON);
    }
 else {
      String error="String_Node_Str";
      throw new CharonException(error);
    }
    return new SCIMResponse(ResponseCodeConstants.CODE_OK,encodedGroup,httpHeaders);
  }
 catch (  NotFoundException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  BadRequestException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  NotImplementedException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  CharonException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  InternalErrorException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  Exception e) {
    CharonException e1=new CharonException("String_Node_Str",e);
    return AbstractResourceManager.encodeSCIMException(e1);
  }
}

Fixed version (ground truth):
public SCIMResponse updateWithPATCH(String existingId,String scimObjectString,UserManager userManager,String attributes,String excludeAttributes){
  try {
    if (userManager == null) {
      String error="String_Node_Str";
      throw new InternalErrorException(error);
    }
    JSONDecoder decoder=getDecoder();
    List<PatchOperation> opList=decoder.decodeRequest(scimObjectString);
    SCIMResourceTypeSchema schema=SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
    Group oldGroup=userManager.getGroup(existingId,ResourceManagerUtil.getAllAttributeURIs(schema));
    if (oldGroup == null) {
      throw new NotFoundException("String_Node_Str" + existingId + "String_Node_Str");
    }
    Group copyOfOldGroup=(Group)CopyUtil.deepCopy(oldGroup);
    Group originalGroup=(Group)CopyUtil.deepCopy(copyOfOldGroup);
    Group newGroup=null;
    for (    PatchOperation operation : opList) {
      if (operation.getOperation().equals(SCIMConstants.OperationalConstants.ADD)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchAdd(operation,getDecoder(),oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchAdd(operation,getDecoder(),newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else       if (operation.getOperation().equals(SCIMConstants.OperationalConstants.REMOVE)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchRemove(operation,oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchRemove(operation,newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else       if (operation.getOperation().equals(SCIMConstants.OperationalConstants.REPLACE)) {
        if (newGroup == null) {
          newGroup=(Group)PatchOperationUtil.doPatchReplace(operation,getDecoder(),oldGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
 else {
          newGroup=(Group)PatchOperationUtil.doPatchReplace(operation,getDecoder(),newGroup,copyOfOldGroup,schema);
          copyOfOldGroup=(Group)CopyUtil.deepCopy(newGroup);
        }
      }
 else {
        throw new BadRequestException("String_Node_Str",ResponseCodeConstants.INVALID_SYNTAX);
      }
    }
    Map<String,Boolean> requiredAttributes=ResourceManagerUtil.getOnlyRequiredAttributesURIs((SCIMResourceTypeSchema)CopyUtil.deepCopy(schema),attributes,excludeAttributes);
    Group validatedGroup=(Group)ServerSideValidator.validateUpdatedSCIMObject(originalGroup,newGroup,schema);
    newGroup=userManager.updateGroup(originalGroup,validatedGroup,requiredAttributes);
    String encodedGroup;
    Map<String,String> httpHeaders=new HashMap<String,String>();
    if (newGroup != null) {
      Group copiedGroup=(Group)CopyUtil.deepCopy(newGroup);
      ServerSideValidator.validateReturnedAttributes(copiedGroup,attributes,excludeAttributes);
      encodedGroup=getEncoder().encodeSCIMObject(copiedGroup);
      httpHeaders.put(SCIMConstants.LOCATION_HEADER,getResourceEndpointURL(SCIMConstants.USER_ENDPOINT) + "String_Node_Str" + newGroup.getId());
      httpHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER,SCIMConstants.APPLICATION_JSON);
    }
 else {
      String error="String_Node_Str";
      throw new CharonException(error);
    }
    return new SCIMResponse(ResponseCodeConstants.CODE_OK,encodedGroup,httpHeaders);
  }
 catch (  NotFoundException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  BadRequestException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  NotImplementedException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  CharonException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  InternalErrorException e) {
    return AbstractResourceManager.encodeSCIMException(e);
  }
catch (  RuntimeException e) {
    CharonException e1=new CharonException("String_Node_Str",e);
    return AbstractResourceManager.encodeSCIMException(e1);
  }
}