Program: 176267
Project: 176267
Buggy source:
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",getJPAQuery());
  }
  List<Object> result=new ArrayList<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  externalProperties=((CassandraClientBase)client).getExternalProperties();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  if (!appMetadata.isNative(getJPAQuery()) && ((CassandraClientBase)client).isCql3Enabled(m)) {
    result=((CassandraClientBase)client).executeQuery(onQueryOverCQL3(m,client,metaModel,null),m.getEntityClazz(),null);
  }
 else {
    if (appMetadata.isNative(getJPAQuery())) {
      result=((CassandraClientBase)client).executeQuery(appMetadata.getQuery(getJPAQuery()),m.getEntityClazz(),null);
    }
 else {
      if (MetadataUtils.useSecondryIndex(((ClientBase)client).getClientMetadata())) {
        boolean useInvertedIndex=CassandraIndexHelper.isInvertedIndexingApplicable(m,MetadataUtils.useSecondryIndex(((ClientBase)client).getClientMetadata()));
        Map<Boolean,List<IndexClause>> ixClause=prepareIndexClause(m,useInvertedIndex);
        if (useInvertedIndex && !getKunderaQuery().getFilterClauseQueue().isEmpty()) {
          result=(List)((CassandraEntityReader)getReader()).readFromIndexTable(m,client,ixClause);
        }
 else {
          boolean isRowKeyQuery=ixClause.keySet().iterator().next();
          if (!isRowKeyQuery) {
            result=((CassandraClientBase)client).find(ixClause.get(isRowKeyQuery),m,false,null,isSingleResult ? 1 : this.maxResult,getColumnList(m,getKunderaQuery().getResult(),null));
          }
 else {
            result=((CassandraEntityReader)getReader()).handleFindByRange(m,client,result,ixClause,isRowKeyQuery,getColumnList(m,getKunderaQuery().getResult(),null),isSingleResult ? 1 : this.maxResult);
          }
        }
      }
 else {
        result=populateUsingLucene(m,client,result,null);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
@Override protected List<Object> populateEntities(EntityMetadata m,Client client){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",getJPAQuery());
  }
  List<Object> result=new ArrayList<Object>();
  ApplicationMetadata appMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata();
  externalProperties=((CassandraClientBase)client).getExternalProperties();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  String query=appMetadata.getQuery(getJPAQuery());
  boolean isNative=kunderaQuery.isNative();
  if (!isNative && ((CassandraClientBase)client).isCql3Enabled(m)) {
    result=((CassandraClientBase)client).executeQuery(onQueryOverCQL3(m,client,metaModel,null),m.getEntityClazz(),null);
  }
 else {
    if (isNative) {
      result=((CassandraClientBase)client).executeQuery(query != null ? query : getJPAQuery(),m.getEntityClazz(),null);
    }
 else {
      if (MetadataUtils.useSecondryIndex(((ClientBase)client).getClientMetadata())) {
        boolean useInvertedIndex=CassandraIndexHelper.isInvertedIndexingApplicable(m,MetadataUtils.useSecondryIndex(((ClientBase)client).getClientMetadata()));
        Map<Boolean,List<IndexClause>> ixClause=prepareIndexClause(m,useInvertedIndex);
        if (useInvertedIndex && !getKunderaQuery().getFilterClauseQueue().isEmpty()) {
          result=(List)((CassandraEntityReader)getReader()).readFromIndexTable(m,client,ixClause);
        }
 else {
          boolean isRowKeyQuery=ixClause.keySet().iterator().next();
          if (!isRowKeyQuery) {
            result=((CassandraClientBase)client).find(ixClause.get(isRowKeyQuery),m,false,null,isSingleResult ? 1 : this.maxResult,getColumnList(m,getKunderaQuery().getResult(),null));
          }
 else {
            result=((CassandraEntityReader)getReader()).handleFindByRange(m,client,result,ixClause,isRowKeyQuery,getColumnList(m,getKunderaQuery().getResult(),null),isSingleResult ? 1 : this.maxResult);
          }
        }
      }
 else {
        result=populateUsingLucene(m,client,result,null);
      }
    }
  }
  return result;
}