Program: 178974
Project: 178974
Buggy source:
/** 
 * Selects rows matching the specified qualifier.
 */
@Override public void selectAttributes(NSArray<EOAttribute> attributesToFetch,EOFetchSpecification fetchSpecification,boolean shouldLock,EOEntity entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (attributesToFetch == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ERXSolrFetchSpecification solrFetchSpecification=null;
  if (fetchSpecification instanceof ERXSolrFetchSpecification) {
    solrFetchSpecification=(ERXSolrFetchSpecification)fetchSpecification;
  }
  setAttributesToFetch(attributesToFetch);
  try {
    _fetchIndex=0;
    _fetchedRows=new NSMutableArray<NSMutableDictionary<String,Object>>();
    NSDictionary connectionDictionary=adaptorContext().adaptor().connectionDictionary();
    String solrUrl=(String)connectionDictionary.objectForKey("String_Node_Str");
    String solrCore=entity.externalName();
    if (ERXStringUtilities.stringIsNullOrEmpty(solrUrl)) {
      throw new IllegalArgumentException("String_Node_Str" + connectionDictionary);
    }
    ERXMutableURL url=new ERXMutableURL(solrUrl);
    if (solrCore != null && !solrCore.equalsIgnoreCase("String_Node_Str")) {
      url.setPath(url.path() + solrCore);
    }
    EOQualifier qualifier=fetchSpecification.qualifier();
    ERSolrExpression solrExpression=ERSolrExpression.newERSolrExpression(entity);
    String solrQueryString=solrExpression.solrStringForQualifier(qualifier);
    SolrQuery solrQuery=new SolrQuery();
    solrQuery.setQuery(solrQueryString);
    solrQuery.setRows(Integer.MAX_VALUE);
    if (solrFetchSpecification != null) {
      if (solrFetchSpecification.maxTime() != null) {
        solrQuery.setTimeAllowed(solrFetchSpecification.maxTime());
      }
      if (solrFetchSpecification.isBatching()) {
        Integer numberOfRowsPerBatch=solrFetchSpecification.batchSize() != null ? solrFetchSpecification.batchSize() : Integer.MAX_VALUE;
        Integer rowOffset=(solrFetchSpecification.batchNumber().intValue() * numberOfRowsPerBatch.intValue()) - numberOfRowsPerBatch;
        solrQuery.setStart(rowOffset);
        solrQuery.setRows(numberOfRowsPerBatch);
      }
      if (solrFetchSpecification.facets() != null && solrFetchSpecification.facets().count() > 0) {
        solrQuery.setFacet(true);
        if (solrFetchSpecification.defaultMinFacetSize() != null) {
          solrQuery.setFacetMinCount(solrFetchSpecification.defaultMinFacetSize());
        }
        if (solrFetchSpecification.defaultFacetLimit() != null) {
          solrQuery.setFacetLimit(solrFetchSpecification.defaultFacetLimit());
        }
        for (Enumeration e=solrFetchSpecification.facets().objectEnumerator(); e.hasMoreElements(); ) {
          SolrFacet facet=(SolrFacet)e.nextElement();
          if (facet.sort() != null && facet.sort().solrValue() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_SORT),facet.sort().solrValue());
          }
          if (facet.minCount() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_MINCOUNT),String.valueOf(facet.minCount()));
          }
          if (facet.limit() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_LIMIT),String.valueOf(facet.limit()));
          }
          boolean isExcludingFromCounts=true;
          boolean isMultiValue=false;
          EOAttribute attribute=entity.attributeNamed(facet.key());
          if (attribute == null) {
            throw new IllegalStateException("String_Node_Str" + entity.name() + "String_Node_Str"+ facet.key());
          }
          isMultiValue=NSValueUtilities.booleanValueWithDefault((attribute.userInfo() == null ? null : attribute.userInfo().valueForKey("String_Node_Str")),false);
          if (isMultiValue && SolrFacet.Operator.AND.equals(facet.operator())) {
            isExcludingFromCounts=false;
          }
          if (facet.isQuery()) {
            String qualifierKeyPrefix=facet.key() + "String_Node_Str";
            for (Enumeration qualifierKeyEnumeration=facet.qualifierKeys().objectEnumerator(); qualifierKeyEnumeration.hasMoreElements(); ) {
              String qualifierKey=(String)qualifierKeyEnumeration.nextElement();
              String prefixedQualifierKey=qualifierKeyPrefix + qualifierKey;
              NSMutableDictionary<String,String> parameters=new NSMutableDictionary<String,String>();
              parameters.takeValueForKey(prefixedQualifierKey,ERSolrExpression.PARAMETER_KEY);
              if (isExcludingFromCounts) {
                parameters.takeValueForKey(prefixedQualifierKey,ERSolrExpression.PARAMETER_EXCLUSION);
              }
              StringBuilder sb=new StringBuilder();
              ERSolrExpression.appendLocalParams(sb,parameters);
              EOQualifier facetQualifier=facet.qualifierForKey(qualifierKey);
              sb.append(solrExpression.solrStringForQualifier(facetQualifier));
              solrQuery.addFacetQuery(sb.toString());
            }
          }
 else {
            StringBuilder sb=new StringBuilder();
            if (isExcludingFromCounts) {
              ERSolrExpression.appendLocalParams(sb,new NSDictionary<String,String>(facet.key(),ERSolrExpression.PARAMETER_EXCLUSION));
            }
            sb.append(facet.key());
            solrQuery.addFacetField(sb.toString());
          }
          if (facet.selectedItems() != null && facet.selectedItems().count() > 0) {
            StringBuilder filterQuery=new StringBuilder();
            if (isExcludingFromCounts) {
              ERSolrExpression.appendLocalParams(filterQuery,new NSDictionary<String,String>(facet.key(),ERSolrExpression.PARAMETER_TAG));
            }
            filterQuery.append("String_Node_Str");
            for (Enumeration facetItemEnumeration=facet.selectedItems().objectEnumerator(); facetItemEnumeration.hasMoreElements(); ) {
              FacetItem selectedFacetItem=(FacetItem)facetItemEnumeration.nextElement();
              String operator=null;
              if (SolrFacet.Operator.NOT.equals(facet.operator())) {
                filterQuery.append(SolrFacet.Operator.NOT.toString()).append("String_Node_Str");
                operator=SolrFacet.Operator.AND.toString();
              }
 else {
                operator=facet.operator().toString();
              }
              if (selectedFacetItem.qualifier() != null) {
                filterQuery.append(solrExpression.solrStringForQualifier(selectedFacetItem.qualifier()));
              }
 else {
                filterQuery.append(facet.key()).append("String_Node_Str");
                ERSolrExpression.escapeAndAppend(selectedFacetItem.key(),filterQuery);
              }
              if (facetItemEnumeration.hasMoreElements()) {
                filterQuery.append("String_Node_Str").append(operator).append("String_Node_Str");
              }
            }
            filterQuery.append("String_Node_Str");
            solrQuery.addFilterQuery(filterQuery.toString());
          }
        }
      }
    }
    System.out.println("String_Node_Str" + qualifier);
    System.out.println("String_Node_Str" + ERXStringUtilities.urlDecode(solrQuery.toString()));
    CommonsHttpSolrServer solrServer=new CommonsHttpSolrServer(url.toURL());
    QueryResponse queryResponse=solrServer.query(solrQuery);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + ERXStringUtilities.urlDecode(solrQuery.toString()));
      log.debug("String_Node_Str" + queryResponse.getElapsedTime() + "String_Node_Str");
    }
    if (solrFetchSpecification != null) {
      ERXSolrFetchSpecification.Result result=ERXSolrFetchSpecification.Result.newResult(queryResponse,solrFetchSpecification);
      solrFetchSpecification.setResult(result);
    }
    for (    SolrDocument solrDoc : queryResponse.getResults()) {
      NSMutableDictionary<String,Object> row=new NSMutableDictionary<String,Object>();
      for (      EOAttribute attribute : attributesToFetch) {
        if (solrDoc.containsKey(attribute.name())) {
          Object value=solrDoc.getFieldValue(attribute.name());
          if (value == null) {
            value=NSKeyValueCoding.NullValue;
          }
          if (value instanceof List) {
            value=value.toString();
          }
          row.takeValueForKey(value,attribute.name());
        }
      }
      _fetchedRows.addObject(row);
    }
  }
 catch (  EOGeneralAdaptorException e) {
    throw e;
  }
catch (  Throwable e) {
    e.printStackTrace();
    throw new EOGeneralAdaptorException("String_Node_Str" + entity.name() + "String_Node_Str"+ fetchSpecification+ "String_Node_Str"+ e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Selects rows matching the specified qualifier.
 */
@Override public void selectAttributes(NSArray<EOAttribute> attributesToFetch,EOFetchSpecification fetchSpecification,boolean shouldLock,EOEntity entity){
  if (entity == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (attributesToFetch == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  ERXSolrFetchSpecification solrFetchSpecification=null;
  if (fetchSpecification instanceof ERXSolrFetchSpecification) {
    solrFetchSpecification=(ERXSolrFetchSpecification)fetchSpecification;
  }
  setAttributesToFetch(attributesToFetch);
  try {
    _fetchIndex=0;
    _fetchedRows=new NSMutableArray<NSMutableDictionary<String,Object>>();
    NSDictionary connectionDictionary=adaptorContext().adaptor().connectionDictionary();
    String solrUrl=(String)connectionDictionary.objectForKey("String_Node_Str");
    String solrCore=entity.externalName();
    if (ERXStringUtilities.stringIsNullOrEmpty(solrUrl)) {
      throw new IllegalArgumentException("String_Node_Str" + connectionDictionary);
    }
    ERXMutableURL url=new ERXMutableURL(solrUrl);
    if (solrCore != null && !solrCore.equalsIgnoreCase("String_Node_Str")) {
      url.setPath(url.path() + solrCore);
    }
    EOQualifier qualifier=fetchSpecification.qualifier();
    ERSolrExpression solrExpression=ERSolrExpression.newERSolrExpression(entity);
    String solrQueryString=solrExpression.solrStringForQualifier(qualifier);
    SolrQuery solrQuery=new SolrQuery();
    solrQuery.setQuery(solrQueryString);
    solrQuery.setRows(Integer.MAX_VALUE);
    if (solrFetchSpecification != null) {
      if (solrFetchSpecification.maxTime() != null) {
        solrQuery.setTimeAllowed(solrFetchSpecification.maxTime());
      }
      if (solrFetchSpecification.isBatching()) {
        Integer numberOfRowsPerBatch=solrFetchSpecification.batchSize() != null ? solrFetchSpecification.batchSize() : Integer.MAX_VALUE;
        Integer rowOffset=(solrFetchSpecification.batchNumber().intValue() * numberOfRowsPerBatch.intValue()) - numberOfRowsPerBatch;
        solrQuery.setStart(rowOffset);
        solrQuery.setRows(numberOfRowsPerBatch);
      }
      if (solrFetchSpecification.facets() != null && solrFetchSpecification.facets().count() > 0) {
        solrQuery.setFacet(true);
        if (solrFetchSpecification.defaultMinFacetSize() != null) {
          solrQuery.setFacetMinCount(solrFetchSpecification.defaultMinFacetSize());
        }
        if (solrFetchSpecification.defaultFacetLimit() != null) {
          solrQuery.setFacetLimit(solrFetchSpecification.defaultFacetLimit());
        }
        for (Enumeration e=solrFetchSpecification.facets().objectEnumerator(); e.hasMoreElements(); ) {
          SolrFacet facet=(SolrFacet)e.nextElement();
          if (facet.sort() != null && facet.sort().solrValue() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_SORT),facet.sort().solrValue());
          }
          if (facet.minCount() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_MINCOUNT),String.valueOf(facet.minCount()));
          }
          if (facet.limit() != null) {
            solrQuery.setParam("String_Node_Str" + facet.key() + "String_Node_Str"+ (FacetParams.FACET_LIMIT),String.valueOf(facet.limit()));
          }
          boolean isExcludingFromCounts=true;
          boolean isMultiValue=false;
          EOAttribute attribute=entity.attributeNamed(facet.key());
          if (attribute == null) {
            throw new IllegalStateException("String_Node_Str" + entity.name() + "String_Node_Str"+ facet.key());
          }
          isMultiValue=NSValueUtilities.booleanValueWithDefault((attribute.userInfo() == null ? null : attribute.userInfo().valueForKey("String_Node_Str")),false);
          if (isMultiValue && SolrFacet.Operator.AND.equals(facet.operator())) {
            isExcludingFromCounts=false;
          }
          if (facet.isQuery()) {
            String qualifierKeyPrefix=facet.key() + "String_Node_Str";
            for (Enumeration qualifierKeyEnumeration=facet.qualifierKeys().objectEnumerator(); qualifierKeyEnumeration.hasMoreElements(); ) {
              String qualifierKey=(String)qualifierKeyEnumeration.nextElement();
              String prefixedQualifierKey=qualifierKeyPrefix + qualifierKey;
              NSMutableDictionary<String,String> parameters=new NSMutableDictionary<String,String>();
              parameters.takeValueForKey(prefixedQualifierKey,ERSolrExpression.PARAMETER_KEY);
              if (isExcludingFromCounts) {
                parameters.takeValueForKey(facet.key(),ERSolrExpression.PARAMETER_EXCLUSION);
              }
              StringBuilder sb=new StringBuilder();
              ERSolrExpression.appendLocalParams(sb,parameters);
              EOQualifier facetQualifier=facet.qualifierForKey(qualifierKey);
              sb.append(solrExpression.solrStringForQualifier(facetQualifier));
              solrQuery.addFacetQuery(sb.toString());
            }
          }
 else {
            StringBuilder sb=new StringBuilder();
            if (isExcludingFromCounts) {
              ERSolrExpression.appendLocalParams(sb,new NSDictionary<String,String>(facet.key(),ERSolrExpression.PARAMETER_EXCLUSION));
            }
            sb.append(facet.key());
            solrQuery.addFacetField(sb.toString());
          }
          if (facet.selectedItems() != null && facet.selectedItems().count() > 0) {
            StringBuilder filterQuery=new StringBuilder();
            if (isExcludingFromCounts) {
              ERSolrExpression.appendLocalParams(filterQuery,new NSDictionary<String,String>(facet.key(),ERSolrExpression.PARAMETER_TAG));
            }
            filterQuery.append("String_Node_Str");
            for (Enumeration facetItemEnumeration=facet.selectedItems().objectEnumerator(); facetItemEnumeration.hasMoreElements(); ) {
              FacetItem selectedFacetItem=(FacetItem)facetItemEnumeration.nextElement();
              String operator=null;
              if (SolrFacet.Operator.NOT.equals(facet.operator())) {
                filterQuery.append(SolrFacet.Operator.NOT.toString()).append("String_Node_Str");
                operator=SolrFacet.Operator.AND.toString();
              }
 else {
                operator=facet.operator().toString();
              }
              if (selectedFacetItem.qualifier() != null) {
                filterQuery.append(solrExpression.solrStringForQualifier(selectedFacetItem.qualifier()));
              }
 else {
                filterQuery.append(facet.key()).append("String_Node_Str");
                ERSolrExpression.escapeAndAppend(selectedFacetItem.key(),filterQuery);
              }
              if (facetItemEnumeration.hasMoreElements()) {
                filterQuery.append("String_Node_Str").append(operator).append("String_Node_Str");
              }
            }
            filterQuery.append("String_Node_Str");
            solrQuery.addFilterQuery(filterQuery.toString());
          }
        }
      }
    }
    System.out.println("String_Node_Str" + qualifier);
    System.out.println("String_Node_Str" + ERXStringUtilities.urlDecode(solrQuery.toString()));
    CommonsHttpSolrServer solrServer=new CommonsHttpSolrServer(url.toURL());
    QueryResponse queryResponse=solrServer.query(solrQuery);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + ERXStringUtilities.urlDecode(solrQuery.toString()));
      log.debug("String_Node_Str" + queryResponse.getElapsedTime() + "String_Node_Str");
    }
    if (solrFetchSpecification != null) {
      ERXSolrFetchSpecification.Result result=ERXSolrFetchSpecification.Result.newResult(queryResponse,solrFetchSpecification);
      solrFetchSpecification.setResult(result);
    }
    for (    SolrDocument solrDoc : queryResponse.getResults()) {
      NSMutableDictionary<String,Object> row=new NSMutableDictionary<String,Object>();
      for (      EOAttribute attribute : attributesToFetch) {
        if (solrDoc.containsKey(attribute.name())) {
          Object value=solrDoc.getFieldValue(attribute.name());
          if (value == null) {
            value=NSKeyValueCoding.NullValue;
          }
          if (value instanceof List) {
            value=value.toString();
          }
          row.takeValueForKey(value,attribute.name());
        }
      }
      _fetchedRows.addObject(row);
    }
  }
 catch (  EOGeneralAdaptorException e) {
    throw e;
  }
catch (  Throwable e) {
    e.printStackTrace();
    throw new EOGeneralAdaptorException("String_Node_Str" + entity.name() + "String_Node_Str"+ fetchSpecification+ "String_Node_Str"+ e.getMessage());
  }
}