Program: 66329
Project: 66329
Buggy source:
private SimpleLevelFilter createSimpleLevelFilter(IFilterDefinition filter,List bindings){
  if (!(filter instanceof CubeFilterDefinition))   return null;
  IBaseExpression expr=((CubeFilterDefinition)filter).getExpression();
  if (!(expr instanceof IConditionalExpression))   return null;
  IConditionalExpression condExpr=(IConditionalExpression)((CubeFilterDefinition)filter).getExpression();
  if (isVariableOperandInDimensionFilter(condExpr))   return null;
  Set refDimLevel;
  try {
    refDimLevel=OlapExpressionCompiler.getReferencedDimLevel(condExpr.getExpression(),bindings);
    if (refDimLevel.size() != 1)     return null;
    DimLevel dimlevel=(DimLevel)refDimLevel.iterator().next();
    if (dimlevel.getAttrName() != null)     return null;
    if (!(condExpr.getOperand1() instanceof IExpressionCollection)) {
      Object Op1=ScriptEvalUtil.evalExpr((IScriptExpression)condExpr.getOperand1(),session.getEngineContext().getScriptContext().newContext(scope),ScriptExpression.defaultID,0);
      if (Op1 == null)       return null;
      ISelection[] selction=new ISelection[1];
      if (condExpr.getOperator() == IConditionalExpression.OP_EQ || condExpr.getOperator() == IConditionalExpression.OP_IN) {
        selction[0]=SelectionFactory.createOneKeySelection(new Object[]{Op1});
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_GT) {
        selction[0]=SelectionFactory.createRangeSelection(new Object[]{Op1},null,false,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_GE) {
        selction[0]=SelectionFactory.createRangeSelection(new Object[]{Op1},null,true,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_LT) {
        selction[0]=SelectionFactory.createRangeSelection(null,new Object[]{Op1},false,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_LE) {
        selction[0]=SelectionFactory.createRangeSelection(null,new Object[]{Op1},false,true);
      }
 else       return null;
      return new SimpleLevelFilter(dimlevel,selction);
    }
 else     if (condExpr.getOperator() == IConditionalExpression.OP_IN) {
      IExpressionCollection combinedExpr=(IExpressionCollection)((IConditionalExpression)expr).getOperand1();
      Object[] exprs=combinedExpr.getExpressions().toArray();
      Object[] opValues=new Object[exprs.length];
      boolean existValue=false;
      for (int i=0; i < opValues.length; i++) {
        opValues[i]=ScriptEvalUtil.evalExpr((IBaseExpression)exprs[i],session.getEngineContext().getScriptContext().newContext(scope),ScriptExpression.defaultID,0);
        if (opValues[i] != null) {
          existValue=true;
        }
      }
      ISelection[] selction=new ISelection[1];
      Object[][] keyValues=null;
      if (opValues.length == 1 && opValues[0] instanceof Object[]) {
        Object[] mulValue=(Object[])opValues[0];
        keyValues=new Object[mulValue.length][1];
        for (int i=0; i < mulValue.length; i++) {
          keyValues[i][0]=mulValue[i];
        }
      }
 else {
        keyValues=new Object[opValues.length][1];
        for (int i=0; i < opValues.length; i++) {
          keyValues[i][0]=opValues[i];
        }
      }
      selction[0]=SelectionFactory.createMutiKeySelection(keyValues);
      return new SimpleLevelFilter(dimlevel,selction);
    }
    return null;
  }
 catch (  DataException e) {
    return null;
  }
}

Fixed version (ground truth):
private SimpleLevelFilter createSimpleLevelFilter(IFilterDefinition filter,List bindings){
  if (!(filter instanceof CubeFilterDefinition) || ((CubeFilterDefinition)filter).getAxisQualifierValues() != null)   return null;
  IBaseExpression expr=((CubeFilterDefinition)filter).getExpression();
  if (!(expr instanceof IConditionalExpression))   return null;
  IConditionalExpression condExpr=(IConditionalExpression)((CubeFilterDefinition)filter).getExpression();
  if (isVariableOperandInDimensionFilter(condExpr))   return null;
  Set refDimLevel;
  try {
    refDimLevel=OlapExpressionCompiler.getReferencedDimLevel(condExpr.getExpression(),bindings);
    if (refDimLevel.size() != 1)     return null;
    DimLevel dimlevel=(DimLevel)refDimLevel.iterator().next();
    if (dimlevel.getAttrName() != null)     return null;
    if (!(condExpr.getOperand1() instanceof IExpressionCollection)) {
      Object Op1=ScriptEvalUtil.evalExpr((IScriptExpression)condExpr.getOperand1(),session.getEngineContext().getScriptContext().newContext(scope),ScriptExpression.defaultID,0);
      if (Op1 == null)       return null;
      ISelection[] selction=new ISelection[1];
      if (condExpr.getOperator() == IConditionalExpression.OP_EQ || condExpr.getOperator() == IConditionalExpression.OP_IN) {
        selction[0]=SelectionFactory.createOneKeySelection(new Object[]{Op1});
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_GT) {
        selction[0]=SelectionFactory.createRangeSelection(new Object[]{Op1},null,false,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_GE) {
        selction[0]=SelectionFactory.createRangeSelection(new Object[]{Op1},null,true,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_LT) {
        selction[0]=SelectionFactory.createRangeSelection(null,new Object[]{Op1},false,false);
      }
 else       if (condExpr.getOperator() == IConditionalExpression.OP_LE) {
        selction[0]=SelectionFactory.createRangeSelection(null,new Object[]{Op1},false,true);
      }
 else       return null;
      return new SimpleLevelFilter(dimlevel,selction);
    }
 else     if (condExpr.getOperator() == IConditionalExpression.OP_IN) {
      IExpressionCollection combinedExpr=(IExpressionCollection)((IConditionalExpression)expr).getOperand1();
      Object[] exprs=combinedExpr.getExpressions().toArray();
      Object[] opValues=new Object[exprs.length];
      boolean existValue=false;
      for (int i=0; i < opValues.length; i++) {
        opValues[i]=ScriptEvalUtil.evalExpr((IBaseExpression)exprs[i],session.getEngineContext().getScriptContext().newContext(scope),ScriptExpression.defaultID,0);
        if (opValues[i] != null) {
          existValue=true;
        }
      }
      ISelection[] selction=new ISelection[1];
      Object[][] keyValues=null;
      if (opValues.length == 1 && opValues[0] instanceof Object[]) {
        Object[] mulValue=(Object[])opValues[0];
        keyValues=new Object[mulValue.length][1];
        for (int i=0; i < mulValue.length; i++) {
          keyValues[i][0]=mulValue[i];
        }
      }
 else {
        keyValues=new Object[opValues.length][1];
        for (int i=0; i < opValues.length; i++) {
          keyValues[i][0]=opValues[i];
        }
      }
      selction[0]=SelectionFactory.createMutiKeySelection(keyValues);
      return new SimpleLevelFilter(dimlevel,selction);
    }
    return null;
  }
 catch (  DataException e) {
    return null;
  }
}