Program: 90366
Project: 90366
Buggy source:
@SuppressWarnings("String_Node_Str") private <T>List<T> _findByQuery(IQuery<T> query,IDBResource dbResource,Class<T> clazz,boolean useCache,EnumDBMasterSlave masterSlave){
  List<T> result=Lists.newArrayList();
  Transaction tx=null;
  try {
    tx=txManager.getTransaction();
    if (tx != null) {
      tx.enlistResource((XAResource)dbResource);
    }
    Map<EntityPK,T> data=null;
    if (isSecondCacheAvailable(clazz,useCache)) {
      String sCacheKey=((DefaultQueryImpl<T>)query).getWhereSql().getSecondCacheKey();
      List<T> sCacheData=(List<T>)secondCache.get(sCacheKey,(ShardingDBResource)dbResource);
      if (sCacheData != null && !sCacheData.isEmpty()) {
        result.addAll(sCacheData);
      }
    }
    if (result == null || result.isEmpty()) {
      if (isCacheAvailable(clazz,useCache)) {
        EntityPK[] entityPks=selectPksByQuery((ShardingDBResource)dbResource,query,clazz);
        data=selectByPksWithCache(dbResource,clazz,entityPks,((DefaultQueryImpl<T>)query).getOrderList(),useCache);
        result.addAll(data.values());
      }
 else {
        result=selectByQuery((ShardingDBResource)dbResource,query,clazz);
      }
      if (isSecondCacheAvailable(clazz,useCache)) {
        String sCacheKey=((DefaultQueryImpl<T>)query).getWhereSql().getSecondCacheKey();
        secondCache.put(sCacheKey,(ShardingDBResource)dbResource,result);
      }
    }
    List<T> filteResult=new ArrayList<T>(data.size());
    if (((DefaultQueryImpl<T>)query).hasQueryFields()) {
      for (      T obj : result) {
        try {
          filteResult.add((T)BeansUtil.cloneWithGivenField(obj,((DefaultQueryImpl<T>)query).getFields()));
        }
 catch (        Exception e) {
          throw new DBOperationException(e);
        }
      }
      result=filteResult;
    }
    return result;
  }
 catch (  Exception e) {
    if (tx != null) {
      try {
        tx.rollback();
      }
 catch (      Exception e1) {
        throw new DBOperationException(e1);
      }
    }
    throw new DBOperationException(e);
  }
 finally {
    if (tx == null && dbResource != null) {
      dbResource.close();
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private <T>List<T> _findByQuery(IQuery<T> query,IDBResource dbResource,Class<T> clazz,boolean useCache,EnumDBMasterSlave masterSlave){
  List<T> result=Lists.newArrayList();
  Transaction tx=null;
  try {
    tx=txManager.getTransaction();
    if (tx != null) {
      tx.enlistResource((XAResource)dbResource);
    }
    Map<EntityPK,T> data=null;
    if (isSecondCacheAvailable(clazz,useCache)) {
      String sCacheKey=((DefaultQueryImpl<T>)query).getWhereSql().getSecondCacheKey();
      List<T> sCacheData=(List<T>)secondCache.get(sCacheKey,(ShardingDBResource)dbResource);
      if (sCacheData != null && !sCacheData.isEmpty()) {
        result.addAll(sCacheData);
      }
    }
    if (result == null || result.isEmpty()) {
      if (isCacheAvailable(clazz,useCache)) {
        EntityPK[] entityPks=selectPksByQuery((ShardingDBResource)dbResource,query,clazz);
        data=selectByPksWithCache(dbResource,clazz,entityPks,((DefaultQueryImpl<T>)query).getOrderList(),useCache);
        result.addAll(data.values());
      }
 else {
        result=selectByQuery((ShardingDBResource)dbResource,query,clazz);
      }
      if (isSecondCacheAvailable(clazz,useCache)) {
        String sCacheKey=((DefaultQueryImpl<T>)query).getWhereSql().getSecondCacheKey();
        secondCache.put(sCacheKey,(ShardingDBResource)dbResource,result);
      }
    }
    List<T> filteResult=new ArrayList<T>(result.size());
    if (((DefaultQueryImpl<T>)query).hasQueryFields()) {
      for (      T obj : result) {
        try {
          filteResult.add((T)BeansUtil.cloneWithGivenField(obj,((DefaultQueryImpl<T>)query).getFields()));
        }
 catch (        Exception e) {
          throw new DBOperationException(e);
        }
      }
      result=filteResult;
    }
    return result;
  }
 catch (  Exception e) {
    if (tx != null) {
      try {
        tx.rollback();
      }
 catch (      Exception e1) {
        throw new DBOperationException(e1);
      }
    }
    throw new DBOperationException(e);
  }
 finally {
    if (tx == null && dbResource != null) {
      dbResource.close();
    }
  }
}