Program: 5588
Project: 5588
Buggy source:
private SearchResults searchByCustomIndex(String namespaceId,Set<MetadataSearchTargetType> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor){
  List<MetadataEntry> results=new ArrayList<>();
  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;
      int count=0;
      while ((next=scanner.next()) != null && count < fetchSize) {
        if (count++ < offset) {
          continue;
        }
        processRow(results,next,indexColumn,types);
        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<MetadataSearchTargetType> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor){
  List<MetadataEntry> results=new ArrayList<>();
  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;
      int count=0;
      while ((next=scanner.next()) != null && count < fetchSize) {
        if (count < offset) {
          if (parseRow(next,indexColumn,types).isPresent()) {
            count++;
          }
          continue;
        }
        Optional<MetadataEntry> metadataEntry=parseRow(next,indexColumn,types);
        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);
}