Change this to this:
      scanner = new LimitingResultIterator(scanner, limit);