Program: 5427
Project: 5427
Buggy source:
private SearchResults searchByCustomIndex(String namespaceId,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor,boolean showHidden){
  List<MetadataEntry> results=new ArrayList<>();
  String indexColumn=getIndexColumn(sortInfo.getSortBy(),sortInfo.getSortOrder());
  int fetchSize=offset + ((numCursors + 1) * limit);
  List<String> cursors=new ArrayList<>(numCursors);
  int count=0;
  for (  String searchTerm : getSearchTerms(namespaceId,"String_Node_Str")) {
    byte[] startKey=Bytes.toBytes(searchTerm.substring(0,searchTerm.lastIndexOf("String_Node_Str")));
    byte[] stopKey=Bytes.stopKeyForPrefix(startKey);
    if (!Strings.isNullOrEmpty(cursor)) {
      String namespaceInStartKey=searchTerm.substring(0,searchTerm.indexOf(KEYVALUE_SEPARATOR));
      startKey=Bytes.toBytes(namespaceInStartKey + KEYVALUE_SEPARATOR + cursor);
    }
    int mod=limit == 1 ? 0 : 1;
    try (Scanner scanner=indexedTable.scanByIndex(Bytes.toBytes(indexColumn),startKey,stopKey)){
      Row next;
      while ((next=scanner.next()) != null && count < fetchSize) {
        if (count < offset) {
          if (parseRow(next,indexColumn,types,showHidden).isPresent()) {
            count++;
          }
          continue;
        }
        Optional<MetadataEntry> metadataEntry=parseRow(next,indexColumn,types,showHidden);
        if (metadataEntry.isPresent()) {
          count++;
          results.add(metadataEntry.get());
        }
        if (results.size() % limit == mod && results.size() > limit) {
          String cursorWithNamespace=Bytes.toString(next.get(indexColumn));
          cursors.add(cursorWithNamespace.substring(cursorWithNamespace.indexOf(KEYVALUE_SEPARATOR) + 1));
        }
      }
    }
   }
  return new SearchResults(results,cursors);
}

Fixed version (ground truth):
private SearchResults searchByCustomIndex(String namespaceId,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor,boolean showHidden){
  List<MetadataEntry> returnedResults=new LinkedList<>();
  List<MetadataEntry> allResults=new LinkedList<>();
  String indexColumn=getIndexColumn(sortInfo.getSortBy(),sortInfo.getSortOrder());
  int fetchSize=offset + ((numCursors + 1) * limit);
  List<String> cursors=new ArrayList<>(numCursors);
  for (  String searchTerm : getSearchTerms(namespaceId,"String_Node_Str")) {
    byte[] startKey=Bytes.toBytes(searchTerm.substring(0,searchTerm.lastIndexOf("String_Node_Str")));
    byte[] stopKey=Bytes.stopKeyForPrefix(startKey);
    if (!Strings.isNullOrEmpty(cursor)) {
      String namespaceInStartKey=searchTerm.substring(0,searchTerm.indexOf(KEYVALUE_SEPARATOR));
      startKey=Bytes.toBytes(namespaceInStartKey + KEYVALUE_SEPARATOR + cursor);
    }
    int mod=(limit == 1) ? 0 : 1;
    try (Scanner scanner=indexedTable.scanByIndex(Bytes.toBytes(indexColumn),startKey,stopKey)){
      Row next;
      while ((next=scanner.next()) != null) {
        Optional<MetadataEntry> metadataEntry=parseRow(next,indexColumn,types,showHidden);
        if (!metadataEntry.isPresent()) {
          continue;
        }
        allResults.add(metadataEntry.get());
        if (allResults.size() <= offset || allResults.size() > fetchSize) {
          continue;
        }
        if (returnedResults.size() < limit) {
          returnedResults.add(metadataEntry.get());
        }
 else {
          if ((allResults.size() - offset) % limit == mod) {
            String cursorWithNamespace=Bytes.toString(next.get(indexColumn));
            cursors.add(cursorWithNamespace.substring(cursorWithNamespace.indexOf(KEYVALUE_SEPARATOR) + 1));
          }
        }
      }
    }
   }
  return new SearchResults(returnedResults,cursors,allResults);
}