Program: 176039
Project: 176039
Buggy source:
List onExecuteQuery(RedisQueryInterpreter queryParameter,Class entityClazz){
  Object connection=null;
  List<Object> results=new ArrayList<Object>();
  try {
    connection=getConnection();
    Set<String> rowKeys=new HashSet<String>();
    EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(kunderaMetadata,entityClazz);
    if (queryParameter.getClause() != null && !queryParameter.isByRange()) {
      String destStore=entityClazz.getSimpleName() + System.currentTimeMillis();
      Map<String,Object> fieldSets=queryParameter.getFields();
      Set<String> keySets=new HashSet<String>(fieldSets.size());
      for (      String column : fieldSets.keySet()) {
        String valueAsStr=PropertyAccessorHelper.getString(fieldSets.get(column));
        String key=getHashKey(entityMetadata.getTableName(),getHashKey(column,valueAsStr));
        keySets.add(key);
      }
      if (queryParameter.getClause().equals(Clause.INTERSECT)) {
        if (resource != null && resource.isActive()) {
          ((Transaction)connection).zinterstore(destStore,keySets.toArray(new String[]{}));
        }
 else {
          ((Jedis)connection).zinterstore(destStore,keySets.toArray(new String[]{}));
        }
      }
 else {
        if (resource != null && resource.isActive()) {
          ((Transaction)connection).zunionstore(destStore,keySets.toArray(new String[]{}));
        }
 else {
          ((Jedis)connection).zunionstore(destStore,keySets.toArray(new String[]{}));
        }
      }
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrange(destStore,0,-1);
        ((Transaction)connection).exec();
        rowKeys=(Set<String>)response.get();
      }
 else {
        rowKeys=((Jedis)connection).zrange(destStore,0,-1);
        ((Jedis)connection).del(destStore);
      }
    }
 else     if (queryParameter.isByRange()) {
      Map<String,Double> minimum=queryParameter.getMin();
      Map<String,Double> maximum=queryParameter.getMax();
      String column=minimum.keySet().iterator().next();
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),minimum.get(column),maximum.get(column));
        ((Transaction)connection).exec();
        rowKeys=(Set<String>)response.get();
      }
 else {
        rowKeys=((Jedis)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),minimum.get(column),maximum.get(column));
      }
    }
 else     if (queryParameter.isById()) {
      Map<String,Object> fieldSets=queryParameter.getFields();
      results=findAllColumns(entityClazz,(byte[][])(queryParameter.getColumns() != null ? queryParameter.getColumns().toArray() : null),fieldSets.values().toArray());
      return results;
    }
 else     if (queryParameter.getFields() != null) {
      Set<String> columns=queryParameter.getFields().keySet();
      for (      String column : columns) {
        Double value=getDouble(PropertyAccessorHelper.getString(queryParameter.getFields().get(column)));
        if (resource != null && resource.isActive()) {
          Response response=((Transaction)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),value,value);
          ((Transaction)connection).exec();
          rowKeys=(Set<String>)response.get();
        }
 else {
          rowKeys=((Jedis)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),value,value);
        }
      }
    }
 else {
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrange(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),0,-1);
        ((Transaction)connection).exec();
        rowKeys=new HashSet<String>((Collection<? extends String>)response.get());
      }
 else {
        rowKeys=new HashSet<String>(((Jedis)connection).zrange(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),0,-1));
      }
    }
    for (    String k : rowKeys) {
      Object record=fetch(entityClazz,k,connection,(queryParameter.getColumns() != null ? queryParameter.getColumns().toArray(new byte[][]{}) : null));
      if (record != null) {
        results.add(record);
      }
    }
  }
 catch (  InstantiationException e) {
    logger.error("String_Node_Str",e);
    throw new PersistenceException(e);
  }
catch (  IllegalAccessException e) {
    logger.error("String_Node_Str",e);
    throw new PersistenceException(e);
  }
 finally {
    onCleanup(connection);
  }
  return results;
}

Fixed version (ground truth):
List onExecuteQuery(RedisQueryInterpreter queryParameter,Class entityClazz){
  Object connection=null;
  List<Object> results=new ArrayList<Object>();
  try {
    connection=getConnection();
    Set<String> rowKeys=new HashSet<String>();
    EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(kunderaMetadata,entityClazz);
    if (queryParameter.getClause() != null && !queryParameter.isByRange()) {
      String destStore=entityClazz.getSimpleName() + System.currentTimeMillis();
      Map<String,Object> fieldSets=queryParameter.getFields();
      Set<String> keySets=new HashSet<String>(fieldSets.size());
      for (      String column : fieldSets.keySet()) {
        String valueAsStr=PropertyAccessorHelper.getString(fieldSets.get(column));
        String key=getHashKey(entityMetadata.getTableName(),getHashKey(column,valueAsStr));
        keySets.add(key);
      }
      if (queryParameter.getClause().equals(Clause.INTERSECT)) {
        if (resource != null && resource.isActive()) {
          ((Transaction)connection).zinterstore(destStore,keySets.toArray(new String[]{}));
        }
 else {
          ((Jedis)connection).zinterstore(destStore,keySets.toArray(new String[]{}));
        }
      }
 else {
        if (resource != null && resource.isActive()) {
          ((Transaction)connection).zunionstore(destStore,keySets.toArray(new String[]{}));
        }
 else {
          ((Jedis)connection).zunionstore(destStore,keySets.toArray(new String[]{}));
        }
      }
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrange(destStore,0,-1);
        ((RedisTransaction)resource).onExecute(((Transaction)connection));
        rowKeys=(Set<String>)response.get();
      }
 else {
        rowKeys=((Jedis)connection).zrange(destStore,0,-1);
        ((Jedis)connection).del(destStore);
      }
    }
 else     if (queryParameter.isByRange()) {
      Map<String,Double> minimum=queryParameter.getMin();
      Map<String,Double> maximum=queryParameter.getMax();
      String column=minimum.keySet().iterator().next();
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),minimum.get(column),maximum.get(column));
        ((RedisTransaction)resource).onExecute(((Transaction)connection));
        rowKeys=(Set<String>)response.get();
      }
 else {
        rowKeys=((Jedis)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),minimum.get(column),maximum.get(column));
      }
    }
 else     if (queryParameter.isById()) {
      Map<String,Object> fieldSets=queryParameter.getFields();
      results=findAllColumns(entityClazz,(byte[][])(queryParameter.getColumns() != null ? queryParameter.getColumns().toArray() : null),fieldSets.values().toArray());
      return results;
    }
 else     if (queryParameter.getFields() != null) {
      Set<String> columns=queryParameter.getFields().keySet();
      for (      String column : columns) {
        Double value=getDouble(PropertyAccessorHelper.getString(queryParameter.getFields().get(column)));
        if (resource != null && resource.isActive()) {
          Response response=((Transaction)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),value,value);
          ((RedisTransaction)resource).onExecute(((Transaction)connection));
          rowKeys=(Set<String>)response.get();
        }
 else {
          rowKeys=((Jedis)connection).zrangeByScore(getHashKey(entityMetadata.getTableName(),column),value,value);
        }
      }
    }
 else {
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).zrange(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),0,-1);
        ((RedisTransaction)resource).onExecute(((Transaction)connection));
        rowKeys=new HashSet<String>((Collection<? extends String>)response.get());
      }
 else {
        rowKeys=new HashSet<String>(((Jedis)connection).zrange(getHashKey(entityMetadata.getTableName(),((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName()),0,-1));
      }
    }
    for (    String k : rowKeys) {
      connection=reInitialize(connection,rowKeys);
      Object record=fetch(entityClazz,k,connection,(queryParameter.getColumns() != null ? queryParameter.getColumns().toArray(new byte[][]{}) : null));
      if (record != null) {
        results.add(record);
      }
    }
  }
 catch (  InstantiationException e) {
    logger.error("String_Node_Str",e);
    throw new PersistenceException(e);
  }
catch (  IllegalAccessException e) {
    logger.error("String_Node_Str",e);
    throw new PersistenceException(e);
  }
catch (  Exception e) {
    logger.error("String_Node_Str",e);
    throw new PersistenceException(e);
  }
 finally {
    onCleanup(connection);
  }
  return results;
}