Program: 5322
Project: 5322
Buggy source:
/** 
 * Searches entities that match the specified search query in the specified namespace and   {@link NamespaceId#SYSTEM}for the specified   {@link EntityTypeSimpleName}.
 * @param namespaceId the namespace to search in
 * @param searchQuery the search query, which could be of two forms: [key]:[value] or just [value] and can have '*'at the end for a prefix search
 * @param types the {@link EntityTypeSimpleName} to restrict the search to, if empty all types are searched
 * @param sortInfo the {@link SortInfo} to sort the results by
 * @param offset index to start with in the search results. To return results from the beginning, pass {@code 0}. Only applies when #sortInfo is not   {@link SortInfo#DEFAULT}
 * @param limit number of results to return, starting from #offset. To return all, pass {@link Integer#MAX_VALUE}. Only applies when #sortInfo is not   {@link SortInfo#DEFAULT}
 * @param numCursors number of cursors to return in the response. A cursor identifies the first index of thenext page for pagination purposes. Only applies when #sortInfo is not  {@link SortInfo#DEFAULT}. Defaults to   {@code 0}
 * @param cursor the cursor that acts as the starting index for the requested page. This is only applicable when#sortInfo is not  {@link SortInfo#DEFAULT}. If offset is also specified, it is applied starting at the cursor. If   {@code null}, the first row is used as the cursor
 * @param showHidden boolean which specifies whether to display hidden entities (entity whose name start with "_")or not.
 * @param entityScope a set which specifies which scope of entities to display.
 * @return a {@link SearchResults} object containing a list of {@link MetadataEntry} containing each matching{@link NamespacedEntityId} with its associated metadata. It also optionally contains a list of cursorsfor subsequent queries to start with, if the specified #sortInfo is not  {@link SortInfo#DEFAULT}.
 */
public SearchResults search(String namespaceId,String searchQuery,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor,boolean showHidden,Set<EntityScope> entityScope){
  if (!SortInfo.DEFAULT.equals(sortInfo)) {
    if (!"String_Node_Str".equals(searchQuery)) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    return searchByCustomIndex(namespaceId,types,sortInfo,offset,limit,numCursors,cursor,showHidden,entityScope);
  }
  return searchByDefaultIndex(namespaceId,searchQuery,types,showHidden,entityScope);
}

Fixed version (ground truth):
/** 
 * Searches entities that match the specified search query in the specified namespace and   {@link NamespaceId#SYSTEM}for the specified   {@link EntityTypeSimpleName}.
 * @param namespaceId the namespace to search in
 * @param searchQuery the search query, which could be of two forms: [key]:[value] or just [value] and can have '*'at the end for a prefix search
 * @param types the {@link EntityTypeSimpleName} to restrict the search to, if empty all types are searched
 * @param sortInfo the {@link SortInfo} to sort the results by
 * @param offset index to start with in the search results. To return results from the beginning, pass {@code 0}. Only applies when #sortInfo is not   {@link SortInfo#DEFAULT}
 * @param limit number of results to return, starting from #offset. To return all, pass {@link Integer#MAX_VALUE}. Only applies when #sortInfo is not   {@link SortInfo#DEFAULT}
 * @param numCursors number of cursors to return in the response. A cursor identifies the first index of thenext page for pagination purposes. Only applies when #sortInfo is not  {@link SortInfo#DEFAULT}. Defaults to   {@code 0}
 * @param cursor the cursor that acts as the starting index for the requested page. This is only applicable when#sortInfo is not  {@link SortInfo#DEFAULT}. If offset is also specified, it is applied starting at the cursor. If   {@code null}, the first row is used as the cursor
 * @param showHidden boolean which specifies whether to display hidden entities (entity whose name start with "_")or not.
 * @param entityScope a set which specifies which scope of entities to display.
 * @return a {@link SearchResults} object containing a list of {@link MetadataEntry} containing each matching{@link NamespacedEntityId} with its associated metadata. It also optionally contains a list of cursorsfor subsequent queries to start with, if the specified #sortInfo is not  {@link SortInfo#DEFAULT}.
 */
public SearchResults search(String namespaceId,String searchQuery,Set<EntityTypeSimpleName> types,SortInfo sortInfo,int offset,int limit,int numCursors,@Nullable String cursor,boolean showHidden,Set<EntityScope> entityScope) throws BadRequestException {
  if (!SortInfo.DEFAULT.equals(sortInfo)) {
    if (!"String_Node_Str".equals(searchQuery)) {
      throw new BadRequestException("String_Node_Str");
    }
    return searchByCustomIndex(namespaceId,types,sortInfo,offset,limit,numCursors,cursor,showHidden,entityScope);
  }
  return searchByDefaultIndex(namespaceId,searchQuery,types,showHidden,entityScope);
}