Program: 37019
Project: 37019
Buggy source:
/** 
 * Method to list the groups at the /Groups endpoint
 * @param userManager
 * @param filter
 * @param startIndex
 * @param count
 * @param sortBy
 * @param sortOrder
 * @param attributes
 * @param excludeAttributes
 * @return
 */
@Override public SCIMResponse listWithGET(UserManager userManager,String filter,int startIndex,int count,String sortBy,String sortOrder,String attributes,String excludeAttributes){
  FilterTreeManager filterTreeManager=null;
  Node rootNode=null;
  JSONEncoder encoder=null;
  try {
    if (startIndex < 1) {
      startIndex=1;
    }
    if (count == 0) {
      count=CharonConfiguration.getInstance().getCountValueForPagination();
    }
    if (sortOrder != null) {
      if (!(sortOrder.equalsIgnoreCase(SCIMConstants.OperationalConstants.ASCENDING) || sortOrder.equalsIgnoreCase(SCIMConstants.OperationalConstants.DESCENDING))) {
        String error="String_Node_Str";
        throw new BadRequestException(error,ResponseCodeConstants.INVALID_VALUE);
      }
    }
    if (sortOrder == null && sortBy != null) {
      sortOrder=SCIMConstants.OperationalConstants.ASCENDING;
    }
    SCIMResourceTypeSchema schema=SCIMResourceSchemaManager.getInstance().getUserResourceSchema();
    if (filter != null) {
      filterTreeManager=new FilterTreeManager(filter,schema);
      rootNode=filterTreeManager.buildTree();
    }
    encoder=getEncoder();
    Map<String,Boolean> requiredAttributes=ResourceManagerUtil.getOnlyRequiredAttributesURIs((SCIMResourceTypeSchema)CopyUtil.deepCopy(schema),attributes,excludeAttributes);
    List<Object> returnedGroups;
    int totalResults=0;
    if (userManager != null) {
      List<Object> tempList=userManager.listGroupsWithGET(rootNode,startIndex,count,sortBy,sortOrder,requiredAttributes);
      totalResults=(int)tempList.get(0);
      tempList.remove(0);
      returnedGroups=tempList;
      if (returnedGroups.isEmpty()) {
        String error="String_Node_Str";
        throw new NotFoundException(error);
      }
      for (      Object group : returnedGroups) {
        ServerSideValidator.validateRetrievedSCIMObjectInList((Group)group,SCIMSchemaDefinitions.SCIM_GROUP_SCHEMA,attributes,excludeAttributes);
      }
      ListedResource listedResource=createListedResource(returnedGroups,startIndex,totalResults);
      String encodedListedResource=encoder.encodeSCIMObject(listedResource);
      Map<String,String> responseHeaders=new HashMap<String,String>();
      responseHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER,SCIMConstants.APPLICATION_JSON);
      return new SCIMResponse(ResponseCodeConstants.CODE_OK,encodedListedResource,responseHeaders);
    }
 else {
      String error="String_Node_Str";
      throw new InternalErrorException(error);
    }
  }
 catch (  CharonException e) {
    return encodeSCIMException(e);
  }
catch (  NotFoundException e) {
    return encodeSCIMException(e);
  }
catch (  InternalErrorException e) {
    return encodeSCIMException(e);
  }
catch (  BadRequestException e) {
    return encodeSCIMException(e);
  }
catch (  NotImplementedException e) {
    return encodeSCIMException(e);
  }
catch (  IOException e) {
    String error="String_Node_Str";
    CharonException charonException=new CharonException(error);
    return AbstractResourceManager.encodeSCIMException(charonException);
  }
}

Fixed version (ground truth):
/** 
 * Method to list the groups at the /Groups endpoint
 * @param userManager
 * @param filter
 * @param startIndex
 * @param count
 * @param sortBy
 * @param sortOrder
 * @param attributes
 * @param excludeAttributes
 * @return
 */
@Override public SCIMResponse listWithGET(UserManager userManager,String filter,int startIndex,int count,String sortBy,String sortOrder,String attributes,String excludeAttributes){
  FilterTreeManager filterTreeManager=null;
  Node rootNode=null;
  JSONEncoder encoder=null;
  try {
    if (startIndex < 1) {
      startIndex=1;
    }
    if (count == 0) {
      count=CharonConfiguration.getInstance().getCountValueForPagination();
    }
    if (sortOrder != null) {
      if (!(sortOrder.equalsIgnoreCase(SCIMConstants.OperationalConstants.ASCENDING) || sortOrder.equalsIgnoreCase(SCIMConstants.OperationalConstants.DESCENDING))) {
        String error="String_Node_Str";
        throw new BadRequestException(error,ResponseCodeConstants.INVALID_VALUE);
      }
    }
    if (sortOrder == null && sortBy != null) {
      sortOrder=SCIMConstants.OperationalConstants.ASCENDING;
    }
    SCIMResourceTypeSchema schema=SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
    if (filter != null) {
      filterTreeManager=new FilterTreeManager(filter,schema);
      rootNode=filterTreeManager.buildTree();
    }
    encoder=getEncoder();
    Map<String,Boolean> requiredAttributes=ResourceManagerUtil.getOnlyRequiredAttributesURIs((SCIMResourceTypeSchema)CopyUtil.deepCopy(schema),attributes,excludeAttributes);
    List<Object> returnedGroups;
    int totalResults=0;
    if (userManager != null) {
      List<Object> tempList=userManager.listGroupsWithGET(rootNode,startIndex,count,sortBy,sortOrder,requiredAttributes);
      totalResults=(int)tempList.get(0);
      tempList.remove(0);
      returnedGroups=tempList;
      if (returnedGroups.isEmpty()) {
        String error="String_Node_Str";
        throw new NotFoundException(error);
      }
      for (      Object group : returnedGroups) {
        ServerSideValidator.validateRetrievedSCIMObjectInList((Group)group,SCIMSchemaDefinitions.SCIM_GROUP_SCHEMA,attributes,excludeAttributes);
      }
      ListedResource listedResource=createListedResource(returnedGroups,startIndex,totalResults);
      String encodedListedResource=encoder.encodeSCIMObject(listedResource);
      Map<String,String> responseHeaders=new HashMap<String,String>();
      responseHeaders.put(SCIMConstants.CONTENT_TYPE_HEADER,SCIMConstants.APPLICATION_JSON);
      return new SCIMResponse(ResponseCodeConstants.CODE_OK,encodedListedResource,responseHeaders);
    }
 else {
      String error="String_Node_Str";
      throw new InternalErrorException(error);
    }
  }
 catch (  CharonException e) {
    return encodeSCIMException(e);
  }
catch (  NotFoundException e) {
    return encodeSCIMException(e);
  }
catch (  InternalErrorException e) {
    return encodeSCIMException(e);
  }
catch (  BadRequestException e) {
    return encodeSCIMException(e);
  }
catch (  NotImplementedException e) {
    return encodeSCIMException(e);
  }
catch (  IOException e) {
    String error="String_Node_Str";
    CharonException charonException=new CharonException(error);
    return AbstractResourceManager.encodeSCIMException(charonException);
  }
}