Program: 172010
Project: 172010
Buggy source:
public ResultSet executeQuery(final BasicSearchParameters searchParameters,String language){
  if (repositoryState.isBootstrapping()) {
    throw new AlfrescoRuntimeException("String_Node_Str");
  }
  try {
    StoreRef store=SolrClientUtil.extractStoreRef(searchParameters);
    SolrStoreMappingWrapper mapping=SolrClientUtil.extractMapping(store,mappingLookup,shardRegistry,useDynamicShardRegistration,beanFactory);
    Pair<HttpClient,String> httpClientAndBaseUrl=mapping.getHttpClientAndBaseUrl();
    HttpClient httpClient=httpClientAndBaseUrl.getFirst();
    URLCodec encoder=new URLCodec();
    StringBuilder url=new StringBuilder();
    url.append(httpClientAndBaseUrl.getSecond());
    String languageUrlFragment=SolrClientUtil.extractLanguageFragment(languageMappings,language);
    if (!url.toString().endsWith("String_Node_Str")) {
      url.append("String_Node_Str");
    }
    url.append(languageUrlFragment);
    url.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
    url.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
    final LimitBy limitBy;
    int maxResults=-1;
    SearchParameters searchParams=(SearchParameters)searchParameters;
    if (searchParams.getMaxItems() >= 0) {
      maxResults=searchParams.getMaxItems();
      limitBy=LimitBy.FINAL_SIZE;
    }
 else     if (searchParams.getLimitBy() == LimitBy.FINAL_SIZE && searchParams.getLimit() >= 0) {
      maxResults=searchParams.getLimit();
      limitBy=LimitBy.FINAL_SIZE;
    }
 else {
      maxResults=searchParams.getMaxPermissionChecks();
      if (maxResults < 0) {
        maxResults=maximumResultsFromUnlimitedQuery;
      }
      limitBy=LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS;
    }
    url.append("String_Node_Str").append(String.valueOf(maxResults));
    if ((searchParameters.getStores().size() > 1) || (mapping.isSharded())) {
      boolean requiresSeparator=false;
      url.append("String_Node_Str");
      for (      StoreRef storeRef : searchParameters.getStores()) {
        SolrStoreMappingWrapper storeMapping=SolrClientUtil.extractMapping(storeRef,mappingLookup,shardRegistry,requiresSeparator,beanFactory);
        if (requiresSeparator) {
          url.append(',');
        }
 else {
          requiresSeparator=true;
        }
        url.append(storeMapping.getShards());
      }
    }
    buildUrlParameters(searchParams,mapping.isSharded(),encoder,url);
    final String searchTerm=searchParams.getSearchTerm();
    String spellCheckQueryStr=null;
    if (searchTerm != null && searchParams.isSpellCheck()) {
      StringBuilder builder=new StringBuilder();
      builder.append("String_Node_Str").append(encoder.encode(searchTerm,"String_Node_Str"));
      builder.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
      spellCheckQueryStr=builder.toString();
      url.append(spellCheckQueryStr);
    }
    JSONObject body=new JSONObject();
    body.put("String_Node_Str",searchParameters.getQuery());
    Set<String> allAuthorisations=permissionService.getAuthorisations();
    boolean includeGroups=includeGroupsForRoleAdmin ? true : !allAuthorisations.contains(PermissionService.ADMINISTRATOR_AUTHORITY);
    JSONArray authorities=new JSONArray();
    for (    String authority : allAuthorisations) {
      if (includeGroups) {
        authorities.put(authority);
      }
 else {
        if (AuthorityType.getAuthorityType(authority) != AuthorityType.GROUP) {
          authorities.put(authority);
        }
      }
    }
    body.put("String_Node_Str",authorities);
    body.put("String_Node_Str",anyDenyDenies);
    JSONArray tenants=new JSONArray();
    tenants.put(tenantService.getCurrentUserDomain());
    body.put("String_Node_Str",tenants);
    JSONArray locales=new JSONArray();
    for (    Locale currentLocale : searchParameters.getLocales()) {
      locales.put(DefaultTypeConverter.INSTANCE.convert(String.class,currentLocale));
    }
    if (locales.length() == 0) {
      locales.put(I18NUtil.getLocale());
    }
    body.put("String_Node_Str",locales);
    JSONArray templates=new JSONArray();
    for (    String templateName : searchParams.getQueryTemplates().keySet()) {
      JSONObject template=new JSONObject();
      template.put("String_Node_Str",templateName);
      template.put("String_Node_Str",searchParams.getQueryTemplates().get(templateName));
      templates.put(template);
    }
    body.put("String_Node_Str",templates);
    JSONArray allAttributes=new JSONArray();
    for (    String attribute : searchParams.getAllAttributes()) {
      allAttributes.put(attribute);
    }
    body.put("String_Node_Str",allAttributes);
    body.put("String_Node_Str",searchParams.getDefaultFTSOperator());
    body.put("String_Node_Str",searchParams.getDefaultFTSFieldOperator());
    body.put("String_Node_Str",searchParams.getQueryConsistency());
    if (searchParams.getMlAnalaysisMode() != null) {
      body.put("String_Node_Str",searchParams.getMlAnalaysisMode().toString());
    }
    body.put("String_Node_Str",searchParams.getNamespace());
    JSONArray textAttributes=new JSONArray();
    for (    String attribute : searchParams.getTextAttributes()) {
      textAttributes.put(attribute);
    }
    body.put("String_Node_Str",textAttributes);
    final int maximumResults=maxResults;
    return (ResultSet)postSolrQuery(httpClient,url.toString(),body,json -> {
      return new SolrJSONResultSet(json,searchParams,nodeService,nodeDAO,limitBy,maximumResults);
    }
,spellCheckQueryStr);
  }
 catch (  UnsupportedEncodingException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  HttpException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  IOException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  JSONException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public ResultSet executeQuery(final SearchParameters searchParameters,String language){
  if (repositoryState.isBootstrapping()) {
    throw new AlfrescoRuntimeException("String_Node_Str");
  }
  try {
    StoreRef store=SolrClientUtil.extractStoreRef(searchParameters);
    SolrStoreMappingWrapper mapping=SolrClientUtil.extractMapping(store,mappingLookup,shardRegistry,useDynamicShardRegistration,beanFactory);
    Pair<HttpClient,String> httpClientAndBaseUrl=mapping.getHttpClientAndBaseUrl();
    HttpClient httpClient=httpClientAndBaseUrl.getFirst();
    URLCodec encoder=new URLCodec();
    StringBuilder url=new StringBuilder();
    url.append(httpClientAndBaseUrl.getSecond());
    String languageUrlFragment=SolrClientUtil.extractLanguageFragment(languageMappings,language);
    if (!url.toString().endsWith("String_Node_Str")) {
      url.append("String_Node_Str");
    }
    url.append(languageUrlFragment);
    url.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
    url.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
    final LimitBy limitBy;
    int maxResults=-1;
    if (searchParameters.getMaxItems() >= 0) {
      maxResults=searchParameters.getMaxItems();
      limitBy=LimitBy.FINAL_SIZE;
    }
 else     if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE && searchParameters.getLimit() >= 0) {
      maxResults=searchParameters.getLimit();
      limitBy=LimitBy.FINAL_SIZE;
    }
 else {
      maxResults=searchParameters.getMaxPermissionChecks();
      if (maxResults < 0) {
        maxResults=maximumResultsFromUnlimitedQuery;
      }
      limitBy=LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS;
    }
    url.append("String_Node_Str").append(String.valueOf(maxResults));
    if ((searchParameters.getStores().size() > 1) || (mapping.isSharded())) {
      boolean requiresSeparator=false;
      url.append("String_Node_Str");
      for (      StoreRef storeRef : searchParameters.getStores()) {
        SolrStoreMappingWrapper storeMapping=SolrClientUtil.extractMapping(storeRef,mappingLookup,shardRegistry,requiresSeparator,beanFactory);
        if (requiresSeparator) {
          url.append(',');
        }
 else {
          requiresSeparator=true;
        }
        url.append(storeMapping.getShards());
      }
    }
    buildUrlParameters(searchParameters,mapping.isSharded(),encoder,url);
    final String searchTerm=searchParameters.getSearchTerm();
    String spellCheckQueryStr=null;
    if (searchTerm != null && searchParameters.isSpellCheck()) {
      StringBuilder builder=new StringBuilder();
      builder.append("String_Node_Str").append(encoder.encode(searchTerm,"String_Node_Str"));
      builder.append("String_Node_Str").append(encoder.encode("String_Node_Str","String_Node_Str"));
      spellCheckQueryStr=builder.toString();
      url.append(spellCheckQueryStr);
    }
    JSONObject body=new JSONObject();
    body.put("String_Node_Str",searchParameters.getQuery());
    Set<String> allAuthorisations=permissionService.getAuthorisations();
    boolean includeGroups=includeGroupsForRoleAdmin ? true : !allAuthorisations.contains(PermissionService.ADMINISTRATOR_AUTHORITY);
    JSONArray authorities=new JSONArray();
    for (    String authority : allAuthorisations) {
      if (includeGroups) {
        authorities.put(authority);
      }
 else {
        if (AuthorityType.getAuthorityType(authority) != AuthorityType.GROUP) {
          authorities.put(authority);
        }
      }
    }
    body.put("String_Node_Str",authorities);
    body.put("String_Node_Str",anyDenyDenies);
    JSONArray tenants=new JSONArray();
    tenants.put(tenantService.getCurrentUserDomain());
    body.put("String_Node_Str",tenants);
    JSONArray locales=new JSONArray();
    for (    Locale currentLocale : searchParameters.getLocales()) {
      locales.put(DefaultTypeConverter.INSTANCE.convert(String.class,currentLocale));
    }
    if (locales.length() == 0) {
      locales.put(I18NUtil.getLocale());
    }
    body.put("String_Node_Str",locales);
    JSONArray templates=new JSONArray();
    for (    String templateName : searchParameters.getQueryTemplates().keySet()) {
      JSONObject template=new JSONObject();
      template.put("String_Node_Str",templateName);
      template.put("String_Node_Str",searchParameters.getQueryTemplates().get(templateName));
      templates.put(template);
    }
    body.put("String_Node_Str",templates);
    JSONArray allAttributes=new JSONArray();
    for (    String attribute : searchParameters.getAllAttributes()) {
      allAttributes.put(attribute);
    }
    body.put("String_Node_Str",allAttributes);
    body.put("String_Node_Str",searchParameters.getDefaultFTSOperator());
    body.put("String_Node_Str",searchParameters.getDefaultFTSFieldOperator());
    body.put("String_Node_Str",searchParameters.getQueryConsistency());
    if (searchParameters.getMlAnalaysisMode() != null) {
      body.put("String_Node_Str",searchParameters.getMlAnalaysisMode().toString());
    }
    body.put("String_Node_Str",searchParameters.getNamespace());
    JSONArray textAttributes=new JSONArray();
    for (    String attribute : searchParameters.getTextAttributes()) {
      textAttributes.put(attribute);
    }
    body.put("String_Node_Str",textAttributes);
    final int maximumResults=maxResults;
    return (ResultSet)postSolrQuery(httpClient,url.toString(),body,json -> {
      return new SolrJSONResultSet(json,searchParameters,nodeService,nodeDAO,limitBy,maximumResults);
    }
,spellCheckQueryStr);
  }
 catch (  UnsupportedEncodingException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  HttpException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  IOException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
catch (  JSONException e) {
    throw new LuceneQueryParserException("String_Node_Str",e);
  }
}