Program: 50948
Project: 50948
Buggy source:
/** 
 * Creates a member reader which enforces the access-control profile of <code>role</code>. <p>This method may not be efficient, so the caller should take care not to call it too often. A cache is a good idea.
 * @param role Role
 * @return Member reader that implements access control
 * @pre role != null
 * @post return != null
 */
MemberReader createMemberReader(Role role){
  final Access access=role.getAccess(this);
switch (access) {
case NONE:
    role.getAccess(this);
  throw Util.newInternal("String_Node_Str" + this);
case ALL:
return (isRagged()) ? new RestrictedMemberReader(getMemberReader(),role) : getMemberReader();
case CUSTOM:
final Role.HierarchyAccess hierarchyAccess=role.getAccessDetails(this);
final Role.RollupPolicy rollupPolicy=hierarchyAccess.getRollupPolicy();
final NumericType returnType=new NumericType();
switch (rollupPolicy) {
case FULL:
return new RestrictedMemberReader(getMemberReader(),role);
case PARTIAL:
Type memberType1=new mondrian.olap.type.MemberType(getDimension(),this,null,null);
SetType setType=new SetType(memberType1);
ListCalc listCalc=new AbstractListCalc(new DummyExp(setType),new Calc[0]){
public TupleList evaluateList(Evaluator evaluator){
return new UnaryTupleList(FunUtil.getNonEmptyMemberChildren(evaluator,((RolapEvaluator)evaluator).getExpanding()));
}
public boolean dependsOn(Hierarchy hierarchy){
return true;
}
}
;
final Calc partialCalc=new LimitedRollupAggregateCalc(returnType,listCalc);
final Exp partialExp=new ResolvedFunCall(new FunDefBase("String_Node_Str","String_Node_Str","String_Node_Str"){
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
return partialCalc;
}
public void unparse(Exp[] args,PrintWriter pw){
pw.print("String_Node_Str");
}
}
,new Exp[0],returnType);
return new LimitedRollupSubstitutingMemberReader(getMemberReader(),role,hierarchyAccess,partialExp);
case HIDDEN:
Exp hiddenExp=new ResolvedFunCall(new FunDefBase("String_Node_Str","String_Node_Str","String_Node_Str"){
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
return new ConstantCalc(returnType,null);
}
public void unparse(Exp[] args,PrintWriter pw){
pw.print("String_Node_Str");
}
}
,new Exp[0],returnType);
return new LimitedRollupSubstitutingMemberReader(getMemberReader(),role,hierarchyAccess,hiddenExp);
default :
throw Util.unexpected(rollupPolicy);
}
default :
throw Util.badValue(access);
}
}

Fixed version (ground truth):
/** 
 * Creates a member reader which enforces the access-control profile of <code>role</code>. <p>This method may not be efficient, so the caller should take care not to call it too often. A cache is a good idea.
 * @param role Role
 * @return Member reader that implements access control
 * @pre role != null
 * @post return != null
 */
MemberReader createMemberReader(Role role){
  final Access access=role.getAccess(this);
switch (access) {
case NONE:
    role.getAccess(this);
  throw Util.newInternal("String_Node_Str" + this);
case ALL:
return (isRagged()) ? new RestrictedMemberReader(getMemberReader(),role) : getMemberReader();
case CUSTOM:
final Role.HierarchyAccess hierarchyAccess=role.getAccessDetails(this);
final Role.RollupPolicy rollupPolicy=hierarchyAccess.getRollupPolicy();
final NumericType returnType=new NumericType();
switch (rollupPolicy) {
case FULL:
return new RestrictedMemberReader(getMemberReader(),role);
case PARTIAL:
Type memberType1=new mondrian.olap.type.MemberType(getDimension(),this,null,null);
SetType setType=new SetType(memberType1);
ListCalc listCalc=new AbstractListCalc(new DummyExp(setType),new Calc[0]){
public TupleList evaluateList(Evaluator evaluator){
return new UnaryTupleList(getLowestMembersForAccess(evaluator,hierarchyAccess,null));
}
public boolean dependsOn(Hierarchy hierarchy){
return true;
}
}
;
final Calc partialCalc=new LimitedRollupAggregateCalc(returnType,listCalc);
final Exp partialExp=new ResolvedFunCall(new FunDefBase("String_Node_Str","String_Node_Str","String_Node_Str"){
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
return partialCalc;
}
public void unparse(Exp[] args,PrintWriter pw){
pw.print("String_Node_Str");
}
}
,new Exp[0],returnType);
return new LimitedRollupSubstitutingMemberReader(getMemberReader(),role,hierarchyAccess,partialExp);
case HIDDEN:
Exp hiddenExp=new ResolvedFunCall(new FunDefBase("String_Node_Str","String_Node_Str","String_Node_Str"){
public Calc compileCall(ResolvedFunCall call,ExpCompiler compiler){
return new ConstantCalc(returnType,null);
}
public void unparse(Exp[] args,PrintWriter pw){
pw.print("String_Node_Str");
}
}
,new Exp[0],returnType);
return new LimitedRollupSubstitutingMemberReader(getMemberReader(),role,hierarchyAccess,hiddenExp);
default :
throw Util.unexpected(rollupPolicy);
}
default :
throw Util.badValue(access);
}
}