Program: 66148
Project: 66148
Buggy source:
/** 
 * @param query
 * @param cubeHandle
 * @throws DataException
 * @throws AdapterException
 */
public static void validateTimeFunctionInCubeQuery(ICubeQueryDefinition query,CubeHandle cubeHandle) throws DataException, AdapterException {
  if (cubeHandle == null)   return;
  Map<String,IDimensionDefinition> dimensionMap=new HashMap<String,IDimensionDefinition>();
  IEdgeDefinition columnEdge=query.getEdge(ICubeQueryDefinition.COLUMN_EDGE);
  if (columnEdge != null) {
    List<IDimensionDefinition> dimensions=columnEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  IEdgeDefinition rowEdge=query.getEdge(ICubeQueryDefinition.ROW_EDGE);
  if (rowEdge != null) {
    List<IDimensionDefinition> dimensions=rowEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  IEdgeDefinition pageEdge=query.getEdge(ICubeQueryDefinition.PAGE_EDGE);
  if (pageEdge != null) {
    List<IDimensionDefinition> dimensions=pageEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  List bindingList=query.getBindings();
  for (int i=0; i < bindingList.size(); i++) {
    IBinding binding=(IBinding)bindingList.get(i);
    if (binding.getTimeFunction() != null) {
      String dimensionName=binding.getTimeFunction().getTimeDimension();
      QueryValidator.validateTimeFunction(cubeHandle,binding.getTimeFunction());
      if (dimensionMap.containsKey(dimensionName)) {
        QueryValidator.validateTimeFunction(dimensionMap.get(dimensionName),cubeHandle,binding.getTimeFunction());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param cubeHandle
 * @throws DataException
 * @throws AdapterException
 */
public static void validateTimeFunctionInCubeQuery(ICubeQueryDefinition query,CubeHandle cubeHandle) throws DataException, AdapterException {
  if (cubeHandle == null)   return;
  Map<String,IDimensionDefinition> dimensionMap=new HashMap<String,IDimensionDefinition>();
  IEdgeDefinition columnEdge=query.getEdge(ICubeQueryDefinition.COLUMN_EDGE);
  if (columnEdge != null) {
    List<IDimensionDefinition> dimensions=columnEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  IEdgeDefinition rowEdge=query.getEdge(ICubeQueryDefinition.ROW_EDGE);
  if (rowEdge != null) {
    List<IDimensionDefinition> dimensions=rowEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  IEdgeDefinition pageEdge=query.getEdge(ICubeQueryDefinition.PAGE_EDGE);
  if (pageEdge != null) {
    List<IDimensionDefinition> dimensions=pageEdge.getDimensions();
    for (int i=0; i < dimensions.size(); i++) {
      dimensionMap.put(dimensions.get(i).getName(),dimensions.get(i));
    }
  }
  List bindingList=query.getBindings();
  for (int i=0; i < bindingList.size(); i++) {
    IBinding binding=(IBinding)bindingList.get(i);
    if (binding.getTimeFunction() != null) {
      String dimensionName=binding.getTimeFunction().getTimeDimension();
      QueryValidator.validateTimeFunction(cubeHandle,binding.getTimeFunction());
      if (dimensionMap.containsKey(dimensionName) && binding.getTimeFunction().getReferenceDate() == null) {
        QueryValidator.validateTimeFunction(dimensionMap.get(dimensionName),cubeHandle,binding.getTimeFunction());
      }
    }
  }
}