Program: 8470
Project: 8470
Buggy source:
@Override public Object resolveArgument(MethodParameter parameter,ModelAndViewContainer mavContainer,NativeWebRequest webRequest,WebDataBinderFactory binderFactory) throws Exception {
  HttpServletRequest request=(HttpServletRequest)webRequest.getNativeRequest();
  PageRequest pr=null;
  for (  Annotation annotation : parameter.getParameterAnnotations()) {
    if (annotation instanceof PageableDefaults) {
      PageableDefaults defaults=(PageableDefaults)annotation;
      pr=new PageRequest(defaults.pageNumber(),defaults.value());
      break;
    }
  }
  if (null == pr) {
    int page=DEFAULT_PAGE;
    String sPage=request.getParameter(config.getPageParamName());
    if (StringUtils.hasText(sPage)) {
      try {
        page=Integer.parseInt(sPage);
      }
 catch (      NumberFormatException ignored) {
      }
    }
    int limit=config.getDefaultPageSize();
    String sLimit=request.getParameter(config.getLimitParamName());
    if (StringUtils.hasText(sLimit)) {
      try {
        limit=Math.min(Integer.parseInt(sLimit),config.getMaxPageSize());
      }
 catch (      NumberFormatException ignored) {
      }
    }
    Sort sort=null;
    List<Sort.Order> orders=new ArrayList<Sort.Order>();
    String[] orderValues=request.getParameterValues(config.getSortParamName());
    if (null != orderValues) {
      for (      String orderParam : orderValues) {
        String sortDir=request.getParameter(orderParam + "String_Node_Str");
        Sort.Direction dir=(null != sortDir ? Sort.Direction.valueOf(sortDir.toUpperCase()) : Sort.Direction.ASC);
        orders.add(new Sort.Order(dir,orderParam));
      }
      if (!orders.isEmpty()) {
        sort=new Sort(orders);
      }
    }
    if (null != sort) {
      pr=new PageRequest(page - 1,limit,sort);
    }
 else {
      pr=new PageRequest(page - 1,limit);
    }
  }
  return new PagingAndSorting(config,pr);
}

Fixed version (ground truth):
@Override public Object resolveArgument(MethodParameter parameter,ModelAndViewContainer mavContainer,NativeWebRequest webRequest,WebDataBinderFactory binderFactory) throws Exception {
  RepositoryInformation repoInfo=(RepositoryInformation)repoInfoResolver.resolveArgument(parameter,mavContainer,webRequest,binderFactory);
  ResourceMapping repoMapping=config.getResourceMappingForDomainType(repoInfo.getDomainType());
  HttpServletRequest request=(HttpServletRequest)webRequest.getNativeRequest();
  PageRequest pr=null;
  for (  Annotation annotation : parameter.getParameterAnnotations()) {
    if (annotation instanceof PageableDefaults) {
      PageableDefaults defaults=(PageableDefaults)annotation;
      pr=new PageRequest(defaults.pageNumber(),defaults.value());
      break;
    }
  }
  if (null == pr) {
    int page=DEFAULT_PAGE;
    String sPage=request.getParameter(config.getPageParamName());
    if (StringUtils.hasText(sPage)) {
      try {
        page=Integer.parseInt(sPage);
      }
 catch (      NumberFormatException ignored) {
      }
    }
    int limit=config.getDefaultPageSize();
    String sLimit=request.getParameter(config.getLimitParamName());
    if (StringUtils.hasText(sLimit)) {
      try {
        limit=Math.min(Integer.parseInt(sLimit),config.getMaxPageSize());
      }
 catch (      NumberFormatException ignored) {
      }
    }
    Sort sort=null;
    List<Sort.Order> orders=new ArrayList<Sort.Order>();
    String[] orderValues=request.getParameterValues(config.getSortParamName());
    if (null != orderValues) {
      for (      String orderParam : orderValues) {
        String name=repoMapping.getNameForPath(orderParam);
        String sortDir=request.getParameter(orderParam + "String_Node_Str");
        Sort.Direction dir=(null != sortDir ? Sort.Direction.valueOf(sortDir.toUpperCase()) : Sort.Direction.ASC);
        orders.add(new Sort.Order(dir,name));
      }
      if (!orders.isEmpty()) {
        sort=new Sort(orders);
      }
    }
    if (null != sort) {
      pr=new PageRequest(page - 1,limit,sort);
    }
 else {
      pr=new PageRequest(page - 1,limit);
    }
  }
  return new PagingAndSorting(config,pr);
}