Program: 189706
Project: 189706
Buggy source:
/** 
 * Checks that a function has parameters which are compatible with those declared by an annotation on that function
 * @param functionSignature The function signature to check for declared parameters
 * @param fnArgumentNames The Function arguments to check against the function signature
 * @throws RestAnnotationException If the function arguments are not compatible with the function signature
 */
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(getRequiredFunctionParameterCardinality())) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().isSubTypeOf(fnArgument.getType()))) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
  for (  final FunctionArgument fnArgument : fnArguments) {
    boolean found=false;
    for (    final String fnArgumentName : fnArgumentNames) {
      if (fnArgumentName.equals(fnArgument.getName())) {
        found=true;
        break;
      }
    }
    if (!found) {
      final Cardinality paramCardinality=fnArgument.getCardinality();
      if (paramCardinality != Cardinality.ZERO && paramCardinality != Cardinality.ZERO_OR_ONE && paramCardinality != Cardinality.ZERO_OR_MORE) {
        throw new RestAnnotationException(RestXqErrorCodes.RQST0008);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks that a function has parameters which are compatible with those declared by an annotation on that function
 * @param functionSignature The function signature to check for declared parameters
 * @param fnArgumentNames The Function arguments to check against the function signature
 * @throws RestAnnotationException If the function arguments are not compatible with the function signature
 */
protected void checkFnDeclaresParameters(final FunctionSignature functionSignature,final List<String> fnArgumentNames) throws RestAnnotationException {
  final FunctionArgument[] fnArguments=functionSignature.getArguments();
  for (  final String fnArgumentName : fnArgumentNames) {
    boolean found=false;
    for (    final FunctionArgument fnArgument : fnArguments) {
      if (fnArgument.getName().equals(fnArgumentName)) {
        if (!fnArgument.getCardinality().hasRequiredCardinality(getRequiredFunctionParameterCardinality())) {
          throw new RestAnnotationException(getInvalidFunctionParameterCardinalityErr());
        }
        if (!(fnArgument.getType().hasSubType(getRequiredFunctionParameterType()) | getRequiredFunctionParameterType().hasSubType(fnArgument.getType()))) {
          throw new RestAnnotationException(getInvalidFunctionParameterTypeErr());
        }
        found=true;
        break;
      }
    }
    if (!found) {
      throw new RestAnnotationException(RestXqErrorCodes.RQST0007);
    }
  }
  for (  final FunctionArgument fnArgument : fnArguments) {
    boolean found=false;
    for (    final String fnArgumentName : fnArgumentNames) {
      if (fnArgumentName.equals(fnArgument.getName())) {
        found=true;
        break;
      }
    }
    if (!found) {
      final Cardinality paramCardinality=fnArgument.getCardinality();
      if (paramCardinality != Cardinality.ZERO && paramCardinality != Cardinality.ZERO_OR_ONE && paramCardinality != Cardinality.ZERO_OR_MORE) {
        throw new RestAnnotationException(RestXqErrorCodes.RQST0008);
      }
    }
  }
}