nus-yam/ex-repair huggingface dataset:
Program: 51479
Project: 51479
Buggy source:
public void testNegativeCases() throws Exception {
  ParserData data=new ParserData();
  Parser p=new TestParser(data);
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testNegativeCases() throws Exception {
  Parser p=new TestParser();
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
  checkFails(p,"String_Node_Str","String_Node_Str");
}
Program: 51480
Project: 51480
Buggy source:
public void testPooledConnectionWithProperties() throws SQLException {
  final String connectString=MondrianProperties.instance().TestConnectString.get();
  System.out.println(connectString);
  Util.PropertyList properties=Util.parseConnectString(connectString);
  properties.put("String_Node_Str","String_Node_Str");
  DataSource dataSource=RolapConnection.createDataSource(properties);
  Connection connection=null;
  try {
    connection=dataSource.getConnection();
    connection.close();
    fail("String_Node_Str");
  }
 catch (  SQLException e) {
    if (e.getClass().getName().equals("String_Node_Str")) {
    }
 else     if (e.getClass() == SQLException.class && e.getCause() == null && e.getMessage() != null && e.getMessage().equals("String_Node_Str")) {
    }
 else {
      fail("String_Node_Str" + e);
    }
  }
 finally {
    RolapConnectionPool.instance().clearPool();
  }
}

Fixed version (ground truth):
public void testPooledConnectionWithProperties() throws SQLException {
  final String connectString=MondrianProperties.instance().TestConnectString.get();
  Util.PropertyList properties=Util.parseConnectString(connectString);
  final String jdbc=properties.get("String_Node_Str");
  if (jdbc != null && !jdbc.startsWith("String_Node_Str")) {
    return;
  }
  properties.put("String_Node_Str","String_Node_Str");
  DataSource dataSource=RolapConnection.createDataSource(properties);
  Connection connection=null;
  try {
    connection=dataSource.getConnection();
    connection.close();
    fail("String_Node_Str");
  }
 catch (  SQLException e) {
    if (e.getClass().getName().equals("String_Node_Str")) {
    }
 else     if (e.getClass() == SQLException.class && e.getCause() == null && e.getMessage() != null && e.getMessage().equals("String_Node_Str")) {
    }
 else {
      fail("String_Node_Str" + e);
    }
  }
 finally {
    RolapConnectionPool.instance().clearPool();
  }
}
Program: 51481
Project: 51481
Buggy source:
public void testNonPooledConnectionWithProperties(){
  final String connectString=MondrianProperties.instance().TestConnectString.get();
  Util.PropertyList properties=Util.parseConnectString(connectString);
  properties.put("String_Node_Str","String_Node_Str");
  properties.put(RolapConnectionProperties.PoolNeeded,"String_Node_Str");
  DataSource dataSource=RolapConnection.createDataSource(properties);
  Connection connection=null;
  try {
    connection=dataSource.getConnection();
    connection.close();
    fail("String_Node_Str");
  }
 catch (  SQLException se) {
  }
}

Fixed version (ground truth):
public void testNonPooledConnectionWithProperties(){
  final String connectString=MondrianProperties.instance().TestConnectString.get();
  Util.PropertyList properties=Util.parseConnectString(connectString);
  final String jdbc=properties.get("String_Node_Str");
  if (jdbc != null && !jdbc.startsWith("String_Node_Str")) {
    return;
  }
  properties.put("String_Node_Str","String_Node_Str");
  properties.put(RolapConnectionProperties.PoolNeeded,"String_Node_Str");
  DataSource dataSource=RolapConnection.createDataSource(properties);
  Connection connection=null;
  try {
    connection=dataSource.getConnection();
    connection.close();
    fail("String_Node_Str");
  }
 catch (  SQLException se) {
  }
}
Program: 51484
Project: 51484
Buggy source:
private static void descendantsLeavesByDepth(Member member,List result,final SchemaReader schemaReader,final int depthLimit){
  if (!schemaReader.isDrillable(member)) {
    if (depthLimit >= 0) {
      result.add(member);
    }
    return;
  }
  Member[] children={member};
  for (int depth=0; depth <= depthLimit; ++depth) {
    children=schemaReader.getMemberChildren(children);
    if (children.length == 0) {
      throw Util.newInternal("String_Node_Str");
    }
    List nextChildren=new ArrayList();
    for (int i=0; i < children.length; i++) {
      Member child=children[i];
      if (schemaReader.isDrillable(child)) {
        nextChildren.add(child);
      }
 else {
        result.add(child);
      }
    }
    if (nextChildren.isEmpty()) {
      break;
    }
    children=(Member[])nextChildren.toArray(new Member[nextChildren.size()]);
  }
}

Fixed version (ground truth):
/** 
 * Populates 'result' with the descendants at the leaf level at depth 'depthLimit' or less. If 'depthLimit' is -1, does not apply a depth constraint.
 */
private static void descendantsLeavesByDepth(final Member member,final List result,final SchemaReader schemaReader,final int depthLimit){
  if (!schemaReader.isDrillable(member)) {
    if (depthLimit >= 0) {
      result.add(member);
    }
    return;
  }
  Member[] children={member};
  for (int depth=0; depthLimit == -1 || depth <= depthLimit; ++depth) {
    children=schemaReader.getMemberChildren(children);
    if (children.length == 0) {
      throw Util.newInternal("String_Node_Str");
    }
    List nextChildren=new ArrayList();
    for (int i=0; i < children.length; i++) {
      Member child=children[i];
      if (schemaReader.isDrillable(child)) {
        nextChildren.add(child);
      }
 else {
        result.add(child);
      }
    }
    if (nextChildren.isEmpty()) {
      return;
    }
    children=(Member[])nextChildren.toArray(new Member[nextChildren.size()]);
  }
}
Program: 51486
Project: 51486
Buggy source:
/** 
 * Returns the hierarchies in an expression.
 */
private Hierarchy[] collectHierarchies(Exp queryPart){
  Type type=queryPart.getType();
  if (type instanceof SetType) {
    type=((SetType)type).getElementType();
  }
  if (type instanceof TupleType) {
    final Type[] types=((TupleType)type).elementTypes;
    ArrayList hierarchyList=new ArrayList();
    for (int i=0; i < types.length; i++) {
      final Hierarchy hierarchy=types[i].getHierarchy();
      hierarchyList.add(hierarchy);
    }
    return (Hierarchy[])hierarchyList.toArray(new Hierarchy[hierarchyList.size()]);
  }
  return new Hierarchy[]{type.getHierarchy()};
}

Fixed version (ground truth):
/** 
 * Returns the hierarchies in an expression. <p>If the expression's type is a dimension with several hierarchies, assumes that the expression yields a member of the first (default) hierarchy of the dimension. <p>For example, the expression <blockquote><code>Crossjoin( Hierarchize( Union( {[Time].LastSibling}, [Time].LastSibling.Children)), {[Measures].[Unit Sales], [Measures].[Store Cost]})</code> </blockquote> has type <code>{[Time.Monthly], [Measures]}</code> even though <code>[Time].LastSibling</code> might return a member of either [Time.Monthly] or [Time.Weekly].
 */
private Hierarchy[] collectHierarchies(Exp queryPart){
  Type exprType=queryPart.getType();
  if (exprType instanceof SetType) {
    exprType=((SetType)exprType).getElementType();
  }
  if (exprType instanceof TupleType) {
    final Type[] types=((TupleType)exprType).elementTypes;
    ArrayList hierarchyList=new ArrayList();
    for (int i=0; i < types.length; i++) {
      hierarchyList.add(getTypeHierarchy(types[i]));
    }
    return (Hierarchy[])hierarchyList.toArray(new Hierarchy[hierarchyList.size()]);
  }
  return new Hierarchy[]{getTypeHierarchy(exprType)};
}
Program: 51487
Project: 51487
Buggy source:
/** 
 * Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension. <p>Typical application: <code>Aggregate({Set}, {Value Expression})</code> depends upon everything {Value Expression} depends upon, except the dimensions of {Set}.
 */
public static boolean anyDependsButFirst(Calc[] calcs,Dimension dimension){
  if (calcs.length == 0) {
    return false;
  }
  if (calcs[0].dependsOn(dimension)) {
    return true;
  }
  if (calcs[0].getType().usesDimension(dimension,true)) {
    return false;
  }
  for (int i=1; i < calcs.length; i++) {
    Calc calc=calcs[i];
    if (calc.dependsOn(dimension)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension. <p>Typical application: <code>Aggregate({Set}, {Value Expression})</code> depends upon everything {Value Expression} depends upon, except the dimensions of {Set}.
 */
public static boolean anyDependsButFirst(Calc[] calcs,Dimension dimension){
  if (calcs.length == 0) {
    return false;
  }
  if (calcs[0].dependsOn(dimension)) {
    return true;
  }
  if (calcs[0].getType().usesDimension(dimension,true)) {
    return false;
  }
  for (int i=1; i < calcs.length; i++) {
    Calc calc=calcs[i];
    if (calc != null && calc.dependsOn(dimension)) {
      return true;
    }
  }
  return false;
}
Program: 51488
Project: 51488
Buggy source:
MondrianJolapConnectionSpec(){
  propertyList.put("String_Node_Str","String_Node_Str");
  propertyList.put("String_Node_Str","String_Node_Str");
  if (System.getProperty(FOODMART_CATALOG_URL) != null)   propertyList.put("String_Node_Str",System.getProperty(FOODMART_CATALOG_URL));
 else   propertyList.put("String_Node_Str","String_Node_Str");
  propertyList.put("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
MondrianJolapConnectionSpec(){
  MondrianJolapConnectionFactory.setDefaultProperties(propertyList);
}
Program: 51489
Project: 51489
Buggy source:
public Connection getConnection(ConnectionSpec properties) throws OLAPException {
  Util.PropertyList propertyList=new Util.PropertyList();
  MondrianJolapConnectionSpec cs=(MondrianJolapConnectionSpec)properties;
  propertyList.put("String_Node_Str","String_Node_Str");
  propertyList.put("String_Node_Str",cs.getName());
  propertyList.put("String_Node_Str",cs.getPassword());
  propertyList.put("String_Node_Str","String_Node_Str");
  if (System.getProperty(FOODMART_CATALOG_URL) != null)   propertyList.put("String_Node_Str",System.getProperty(FOODMART_CATALOG_URL));
 else   propertyList.put("String_Node_Str","String_Node_Str");
  propertyList.put("String_Node_Str","String_Node_Str");
  final boolean fresh=false;
  mondrian.olap.Connection mondrianConnection=DriverManager.getConnection(propertyList,null,fresh);
  return new MondrianJolapConnection(mondrianConnection);
}

Fixed version (ground truth):
public Connection getConnection(ConnectionSpec properties) throws OLAPException {
  Util.PropertyList propertyList=new Util.PropertyList();
  MondrianJolapConnectionSpec cs=(MondrianJolapConnectionSpec)properties;
  setDefaultProperties(propertyList);
  propertyList.put("String_Node_Str",cs.getName());
  propertyList.put("String_Node_Str",cs.getPassword());
  final boolean fresh=false;
  mondrian.olap.Connection mondrianConnection=DriverManager.getConnection(propertyList,null,fresh);
  return new MondrianJolapConnection(mondrianConnection);
}
Program: 51490
Project: 51490
Buggy source:
public NativeEvaluator getNativeSetEvaluator(FunDef fun,Evaluator evaluator,Exp[] args){
  return schemaReader.getNativeSetEvaluator(fun,evaluator,args);
}

Fixed version (ground truth):
public NativeEvaluator getNativeSetEvaluator(FunDef fun,Exp[] args,Evaluator evaluator,Calc calc){
  return schemaReader.getNativeSetEvaluator(fun,args,evaluator,calc);
}
Program: 51491
Project: 51491
Buggy source:
/** 
 * returns the instance that can perform native crossjoin
 * @param args
 * @param evaluator
 * @param fun
 */
NativeEvaluator getNativeSetEvaluator(FunDef fun,Evaluator evaluator,Exp[] args);

Fixed version (ground truth):
/** 
 * Returns an object which can evaluate an expression in native SQL, or null if this is not possible.
 * @param fun Function
 * @param args Arguments to the function
 * @param evaluator Evaluator, provides context
 * @param calc
 */
NativeEvaluator getNativeSetEvaluator(FunDef fun,Exp[] args,Evaluator evaluator,Calc calc);
Program: 51492
Project: 51492
Buggy source:
public boolean usesDimension(Dimension dimension,boolean maybe){
  final Dimension hierarchyDimension=hierarchy.getDimension();
  return hierarchyDimension == dimension || (maybe && hierarchyDimension == null);
}

Fixed version (ground truth):
public boolean usesDimension(Dimension dimension,boolean maybe){
  return this.dimension == dimension || (maybe && this.dimension == null);
}
Program: 51493
Project: 51493
Buggy source:
public NativeEvaluator getNativeSetEvaluator(FunDef fun,Evaluator evaluator,Exp[] args){
  RolapEvaluator revaluator=(RolapEvaluator)evaluator;
  return schema.getNativeRegistry().createEvaluator(revaluator,fun,args);
}

Fixed version (ground truth):
public NativeEvaluator getNativeSetEvaluator(FunDef fun,Exp[] args,Evaluator evaluator,Calc calc){
  RolapEvaluator revaluator=(RolapEvaluator)AbstractCalc.simplifyEvaluator(calc,evaluator);
  return schema.getNativeRegistry().createEvaluator(revaluator,fun,args);
}
Program: 51494
Project: 51494
Buggy source:
/** 
 * Reads the children of <code>member</code> into cache, and also into <code>result</code>.
 * @param result Children are written here, in order
 * @param members Members whose children to read
 * @param constraint restricts the returned members if possible (optionaloptimization)
 */
private void readMemberChildren(List members,List result,MemberChildrenConstraint constraint){
  if (false) {
    Util.assertPrecondition(isSorted(members),"String_Node_Str");
  }
  List children=new ArrayList();
  source.getMemberChildren(members,children,constraint);
  Map tempMap=new HashMap();
  for (int i=0, n=members.size(); i < n; i++) {
    tempMap.put(members.get(i),new ArrayList());
  }
  for (int i=0, childrenCount=children.size(); i < childrenCount; i++) {
    RolapMember child=(RolapMember)children.get(i);
    List list=(ArrayList)tempMap.get(child.getParentMember());
    list.add(child);
    result.add(child);
  }
synchronized (this) {
    for (Iterator keys=tempMap.keySet().iterator(); keys.hasNext(); ) {
      RolapMember member=(RolapMember)keys.next();
      List list=(ArrayList)tempMap.get(member);
      if (getChildrenFromCache(member,constraint) == null) {
        putChildren(member,constraint,list);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Reads the children of <code>member</code> into cache, and also into <code>result</code>.
 * @param result Children are written here, in order
 * @param members Members whose children to read
 * @param constraint restricts the returned members if possible (optionaloptimization)
 */
private void readMemberChildren(List members,List result,MemberChildrenConstraint constraint){
}
Program: 51495
Project: 51495
Buggy source:
/** 
 * Handles TopSum, TopPercent, BottomSum, BottomPercent by evaluating members, sorting appropriately, and returning a truncated list of members
 */
static List topOrBottom(Evaluator evaluator,List members,Calc exp,boolean isTop,boolean isPercent,double target){
  Map mapMemberToValue=evaluateMembers(evaluator,exp,members,false);
  Comparator comparator=new BreakMemberComparator(mapMemberToValue,isTop);
  Collections.sort(members,comparator);
  if (isPercent) {
    toPercent(members,mapMemberToValue);
  }
  double runningTotal=0;
  int numMembers=members.size();
  int nullCount=0;
  for (int i=0; i < numMembers; i++) {
    if (runningTotal >= target) {
      members=members.subList(0,i);
      break;
    }
    Object o=mapMemberToValue.get(members.get(i));
    if (o == Util.nullValue) {
      nullCount++;
    }
 else     if (o instanceof Number) {
      runningTotal+=((Number)o).doubleValue();
    }
 else     if (o instanceof Exception) {
    }
 else {
      throw Util.newInternal("String_Node_Str" + o + "String_Node_Str");
    }
  }
  if ((numMembers > 0) && isPercent && (nullCount == numMembers)) {
    return (isTop) ? members.subList(0,1) : members.subList(numMembers - 1,numMembers);
  }
  return members;
}

Fixed version (ground truth):
/** 
 * Handles TopSum, TopPercent, BottomSum, BottomPercent by evaluating members, sorting appropriately, and returning a truncated list of members
 */
static List topOrBottom(Evaluator evaluator,List members,Calc exp,boolean isTop,boolean isPercent,double target){
  Map mapMemberToValue=evaluateMembers(evaluator,exp,members,false);
  sort(evaluator,members,exp,isTop,true);
  if (isPercent) {
    toPercent(members,mapMemberToValue);
  }
  double runningTotal=0;
  int numMembers=members.size();
  int nullCount=0;
  for (int i=0; i < numMembers; i++) {
    if (runningTotal >= target) {
      members=members.subList(0,i);
      break;
    }
    Object o=mapMemberToValue.get(members.get(i));
    if (o == Util.nullValue) {
      nullCount++;
    }
 else     if (o instanceof Number) {
      runningTotal+=((Number)o).doubleValue();
    }
 else     if (o instanceof Exception) {
    }
 else {
      throw Util.newInternal("String_Node_Str" + o + "String_Node_Str");
    }
  }
  if ((numMembers > 0) && isPercent && (nullCount == numMembers)) {
    return (isTop) ? members.subList(0,1) : members.subList(numMembers - 1,numMembers);
  }
  return members;
}
Program: 51497
Project: 51497
Buggy source:
/** 
 * For every restricting member in the current context, generates a WHERE condition and a join to the fact table.
 * @param sqlQuery the query to modify
 * @param strict defines the behavior if the current context contains calculated members. If true, an exception is thrown, otherwise calculated members are silently ignored.
 */
public static void addContextConstraint(SqlQuery sqlQuery,Evaluator e,boolean strict){
}

Fixed version (ground truth):
/** 
 * For every restricting member in the current context, generates a WHERE condition and a join to the fact table.
 * @param sqlQuery the query to modify
 * @param strict defines the behavior if the current context containscalculated members. If true, an exception is thrown, otherwise calculated members are silently ignored.
 */
public static void addContextConstraint(SqlQuery sqlQuery,Evaluator e,boolean strict){
}
Program: 51498
Project: 51498
Buggy source:
/** 
 * ensures that the table of <code>level</code> is joined to the fact table
 */
public static void joinLevelTableToFactTable(SqlQuery sqlQuery,RolapCube cube,RolapLevel level){
  RolapStar star=cube.getStar();
  Map mapLevelToColumnMap=star.getMapLevelToColumn(cube);
  RolapStar.Column starColumn=(RolapStar.Column)mapLevelToColumnMap.get(level);
  RolapStar.Table table=starColumn.getTable();
  table.addToFrom(sqlQuery,false,true);
}

Fixed version (ground truth):
/** 
 * Ensures that the table of <code>level</code> is joined to the fact table
 */
public static void joinLevelTableToFactTable(SqlQuery sqlQuery,RolapCube cube,RolapLevel level){
  RolapStar star=cube.getStar();
  Map mapLevelToColumnMap=star.getMapLevelToColumn(cube);
  RolapStar.Column starColumn=(RolapStar.Column)mapLevelToColumnMap.get(level);
  RolapStar.Table table=starColumn.getTable();
  table.addToFrom(sqlQuery,false,true);
}
Program: 51499
Project: 51499
Buggy source:
private static boolean containsCalculatedMember(Member[] members){
  for (int i=0; i < members.length; i++)   if (members[i].isCalculated())   return true;
  return false;
}

Fixed version (ground truth):
private static boolean containsCalculatedMember(Member[] members){
  for (int i=0; i < members.length; i++) {
    if (members[i].isCalculated()) {
      return true;
    }
  }
  return false;
}
Program: 51500
Project: 51500
Buggy source:
private static Member[] removeCalculatedMembers(Member[] members){
  List result=new ArrayList();
  for (int i=0; i < members.length; i++)   if (!members[i].isCalculated())   result.add(members[i]);
  return (Member[])result.toArray(new Member[result.size()]);
}

Fixed version (ground truth):
private static Member[] removeCalculatedMembers(Member[] members){
  List result=new ArrayList();
  for (int i=0; i < members.length; i++) {
    if (!members[i].isCalculated()) {
      result.add(members[i]);
    }
  }
  return (Member[])result.toArray(new Member[result.size()]);
}
Program: 51501
Project: 51501
Buggy source:
/** 
 * Creates a "WHERE exp IN (...)" condition containing the values of all parents. All parents must belong to the same level.
 * @param sqlQuery the query to modify
 * @param parents the list of parent members
 * @param strict defines the behavior if <code>parents</code> contains calculated members.  If true, an exception is thrown, otherwise calculated members are silently ignored.
 */
public static void addMemberConstraint(SqlQuery sqlQuery,List parents,boolean strict){
  if (parents.size() == 0)   return;
  for (Collection c=parents; !c.isEmpty(); c=getUniqueParentMembers(c)) {
    RolapMember m=(RolapMember)c.iterator().next();
    if (m.isAll())     continue;
    if (m.isCalculated()) {
      if (strict)       throw Util.newInternal("String_Node_Str");
      continue;
    }
    RolapLevel level=m.getRolapLevel();
    RolapHierarchy hierarchy=(RolapHierarchy)level.getHierarchy();
    hierarchy.addToFrom(sqlQuery,level.getKeyExp());
    String q=level.getKeyExp().getExpression(sqlQuery);
    ColumnConstraint[] cc=getColumnConstraints(c);
    String cond=RolapStar.Column.createInExpr(q,cc,level.isNumeric());
    sqlQuery.addWhere(cond);
    if (level.isUnique()) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates a "WHERE exp IN (...)" condition containing the values of all parents. All parents must belong to the same level.
 * @param sqlQuery the query to modify
 * @param parents the list of parent members
 * @param strict defines the behavior if <code>parents</code>contains calculated members. If true, an exception is thrown, otherwise calculated members are silently ignored.
 */
public static void addMemberConstraint(SqlQuery sqlQuery,List parents,boolean strict){
  if (parents.size() == 0)   return;
  for (Collection c=parents; !c.isEmpty(); c=getUniqueParentMembers(c)) {
    RolapMember m=(RolapMember)c.iterator().next();
    if (m.isAll())     continue;
    if (m.isCalculated()) {
      if (strict)       throw Util.newInternal("String_Node_Str");
      continue;
    }
    RolapLevel level=m.getRolapLevel();
    RolapHierarchy hierarchy=(RolapHierarchy)level.getHierarchy();
    hierarchy.addToFrom(sqlQuery,level.getKeyExp());
    String q=level.getKeyExp().getExpression(sqlQuery);
    ColumnConstraint[] cc=getColumnConstraints(c);
    String cond=RolapStar.Column.createInExpr(q,cc,level.isNumeric());
    sqlQuery.addWhere(cond);
    if (level.isUnique()) {
      break;
    }
  }
}
Program: 51502
Project: 51502
Buggy source:
public void testDimensionsNumeric(){
  assertExprDependsOn("String_Node_Str","String_Node_Str");
  assertMemberExprDependsOn("String_Node_Str",allDims());
  assertExprReturns("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testDimensionsNumeric(){
  assertExprDependsOn("String_Node_Str","String_Node_Str");
  assertMemberExprDependsOn("String_Node_Str",allDims());
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprThrows("String_Node_Str","String_Node_Str");
  assertExprThrows("String_Node_Str","String_Node_Str");
}
Program: 51503
Project: 51503
Buggy source:
public void testLevelsNumeric(){
  assertExprReturns("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testLevelsNumeric(){
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
  assertExprReturns("String_Node_Str","String_Node_Str");
}
Program: 51504
Project: 51504
Buggy source:
/** 
 * Creates a connection to a Mondrian OLAP Server.
 * @param properties Collection of properties which define the locationof the connection. See  {@link RolapConnection} for a list of allowed properties.
 * @param servletContext If not null, the <code>catalog</code> is readrelative to the WAR file of this servlet.
 * @param dataSource - if not null an external DataSource to be usedby Mondrian
 * @param fresh If <code>true</code>, a new connection is created;if <code>false</code>, the connection may come from a connection pool.
 * @return A {@link Connection}
 * @post return != null
 */
public static Connection getConnection(Util.PropertyList properties,ServletContext servletContext,DataSource dataSource,boolean fresh){
  String provider=properties.get("String_Node_Str");
  if (!provider.equalsIgnoreCase("String_Node_Str")) {
    throw Util.newError("String_Node_Str" + provider);
  }
  if (servletContext != null) {
    MondrianProperties.instance().populate(servletContext);
    fixup(properties,servletContext);
  }
  return new RolapConnection(properties,dataSource);
}

Fixed version (ground truth):
/** 
 * Creates a connection to a Mondrian OLAP Server.
 * @param properties Collection of properties which define the locationof the connection. See  {@link RolapConnection} for a list of allowed properties.
 * @param servletContext If not null, the <code>catalog</code> is readrelative to the WAR file of this servlet.
 * @param dataSource - if not null an external DataSource to be usedby Mondrian
 * @param fresh If <code>true</code>, a new connection is created;if <code>false</code>, the connection may come from a connection pool.
 * @return A {@link Connection}
 * @post return != null
 */
public static Connection getConnection(Util.PropertyList properties,ServletContext servletContext,DataSource dataSource,boolean fresh){
  String provider=properties.get("String_Node_Str");
  if (!provider.equalsIgnoreCase("String_Node_Str")) {
    throw Util.newError("String_Node_Str" + provider);
  }
  if (servletContext != null) {
    MondrianProperties.instance().populate();
    fixup(properties,servletContext);
  }
  return new RolapConnection(properties,dataSource);
}
Program: 51505
Project: 51505
Buggy source:
public Calc accept(ExpCompiler compiler){
  return compiler.compile(exp);
}

Fixed version (ground truth):
public Calc accept(ExpCompiler compiler){
  final Calc defaultCalc=defaultExp.accept(compiler);
  return new GenericCalc(new DummyExp(type)){
    public Calc[] getCalcs(){
      return new Calc[]{defaultCalc};
    }
    public Object evaluate(    Evaluator evaluator){
      if (value != null) {
        return value;
      }
 else {
        return defaultCalc.evaluate(evaluator);
      }
    }
  }
;
}
Program: 51506
Project: 51506
Buggy source:
/** 
 * Returns the value of this parameter.
 * @return one of String, Double, Member
 */
public Object getValue(){
switch (category) {
case Category.Numeric:
    if (exp instanceof FunCall) {
      FunCall f=(FunCall)exp;
      if (f.getFunName().equals("String_Node_Str")) {
        Literal lit=(Literal)f.getArg(0);
        Object o=lit.getValue();
        if (o instanceof Double) {
          return new Double(-((Double)o).doubleValue());
        }
 else         if (o instanceof Integer) {
          return new Integer(-((Integer)o).intValue());
        }
 else         if (o instanceof Integer) {
          return o;
        }
      }
 else {
        throw Util.newInternal("String_Node_Str" + f);
      }
    }
  return ((Literal)exp).getValue();
case Category.String:
return ((Literal)exp).getValue();
default :
return (Member)exp;
}
}

Fixed version (ground truth):
/** 
 * Returns the value of this parameter.
 * @return one of String, Double, Member
 */
public Object getValue(){
switch (category) {
case Category.Numeric:
    if (defaultExp instanceof FunCall) {
      FunCall f=(FunCall)defaultExp;
      if (f.getFunName().equals("String_Node_Str")) {
        Literal lit=(Literal)f.getArg(0);
        Object o=lit.getValue();
        if (o instanceof Double) {
          return new Double(-((Double)o).doubleValue());
        }
 else         if (o instanceof Integer) {
          return new Integer(-((Integer)o).intValue());
        }
 else         if (o instanceof Integer) {
          return o;
        }
      }
 else {
        throw Util.newInternal("String_Node_Str" + f);
      }
    }
  return ((Literal)defaultExp).getValue();
case Category.String:
return ((Literal)defaultExp).getValue();
default :
return (Member)defaultExp;
}
}
Program: 51507
Project: 51507
Buggy source:
/** 
 * Sets the value of this parameter.
 * @param value Value of the parameter; must be a {@link String}, a   {@link Double}, or a   {@link Member}
 */
public void setValue(Object value){
switch (category) {
case Category.Numeric:
    exp=Literal.create((Double)value);
  break;
case Category.String:
exp=Literal.createString((String)value);
break;
default :
exp=new MemberExpr((Member)value);
}
}

Fixed version (ground truth):
/** 
 * Sets the value of this parameter.
 * @param value Value of the parameter; must be a {@link String}, a   {@link Double}, or a   {@link Member}
 */
public void setValue(Object value){
  if (value instanceof MemberExpr) {
    this.value=((MemberExpr)value).getMember();
  }
 else   if (value instanceof Literal) {
    this.value=((Literal)value).getValue();
  }
 else {
    this.value=value;
  }
}
Program: 51508
Project: 51508
Buggy source:
/** 
 * Returns whether this parameter is equal to another, based upon name, type and value 
 */
public boolean equals(Object other){
  if (!(other instanceof Parameter)) {
    return false;
  }
  Parameter that=(Parameter)other;
  return that.getName().equals(this.getName()) && (that.getCategory() == this.getCategory()) && that.exp.equals(this.exp);
}

Fixed version (ground truth):
/** 
 * Returns whether this parameter is equal to another, based upon name, type and value
 */
public boolean equals(Object other){
  if (!(other instanceof Parameter)) {
    return false;
  }
  Parameter that=(Parameter)other;
  return that.getName().equals(this.getName()) && (that.getCategory() == this.getCategory()) && that.defaultExp.equals(this.defaultExp);
}
Program: 51509
Project: 51509
Buggy source:
public Object clone(){
  return new Parameter(name,category,exp,description,type);
}

Fixed version (ground truth):
public Object clone(){
  return new Parameter(name,category,defaultExp,description,type);
}
Program: 51510
Project: 51510
Buggy source:
Parameter(String name,int category,Exp exp,String description,Type type){
  this.name=name;
  this.category=category;
  this.exp=exp;
  this.defineCount=1;
  this.description=description;
  this.type=type;
}

Fixed version (ground truth):
Parameter(String name,int category,Exp defaultExp,String description,Type type){
  this.name=name;
  this.category=category;
  this.defaultExp=defaultExp;
  this.defineCount=1;
  this.description=description;
  this.type=type;
}
Program: 51511
Project: 51511
Buggy source:
public void unparse(PrintWriter pw){
  boolean firstPrinting=true;
  if (pw instanceof Query.QueryPrintWriter) {
    firstPrinting=((Query.QueryPrintWriter)pw).parameters.add(this);
  }
  if (firstPrinting) {
    pw.print("String_Node_Str" + Util.quoteForMdx(name) + "String_Node_Str");
switch (category) {
case Category.String:
case Category.Numeric:
      pw.print(getParameterType());
    break;
case Category.Member:
  pw.print(type.getHierarchy().getUniqueName());
break;
default :
throw Category.instance.badValue(category);
}
pw.print("String_Node_Str");
exp.unparse(pw);
if (description != null) {
pw.print("String_Node_Str" + Util.quoteForMdx(description));
}
pw.print("String_Node_Str");
}
 else {
pw.print("String_Node_Str" + Util.quoteForMdx(name) + "String_Node_Str");
}
}

Fixed version (ground truth):
public void unparse(PrintWriter pw){
  boolean firstPrinting=true;
  if (pw instanceof Query.QueryPrintWriter) {
    firstPrinting=((Query.QueryPrintWriter)pw).parameters.add(this);
  }
  if (firstPrinting) {
    pw.print("String_Node_Str" + Util.quoteForMdx(name) + "String_Node_Str");
switch (category) {
case Category.String:
case Category.Numeric:
      pw.print(getParameterType());
    break;
case Category.Member:
  String name=type.getLevel() != null ? type.getLevel().getUniqueName() : type.getHierarchy() != null ? type.getHierarchy().getUniqueName() : type.getDimension().getUniqueName();
pw.print(name);
break;
default :
throw Category.instance.badValue(category);
}
pw.print("String_Node_Str");
if (value == null) {
defaultExp.unparse(pw);
}
 else if (value instanceof String) {
String s=(String)value;
pw.print(Util.quoteForMdx(s));
}
 else {
pw.print(value);
}
if (description != null) {
pw.print("String_Node_Str" + Util.quoteForMdx(description));
}
pw.print("String_Node_Str");
}
 else {
pw.print("String_Node_Str" + Util.quoteForMdx(name) + "String_Node_Str");
}
}
Program: 51512
Project: 51512
Buggy source:
public void validate(Query q){
switch (defineCount) {
case 0:
    throw MondrianResource.instance().MdxParamNeverDef.ex(name);
case 1:
  break;
default :
throw MondrianResource.instance().MdxParamMultipleDef.ex(name,new Integer(defineCount));
}
if (exp == null) {
throw MondrianResource.instance().MdxParamValueNotFound.ex(name);
}
}

Fixed version (ground truth):
public void validate(Query q){
switch (defineCount) {
case 0:
    throw MondrianResource.instance().MdxParamNeverDef.ex(name);
case 1:
  break;
default :
throw MondrianResource.instance().MdxParamMultipleDef.ex(name,new Integer(defineCount));
}
if (defaultExp == null) {
throw MondrianResource.instance().MdxParamValueNotFound.ex(name);
}
}
Program: 51513
Project: 51513
Buggy source:
/** 
 * Creates a Query.
 */
public Query(Connection connection,Cube mdxCube,Formula[] formulas,QueryAxis[] axes,Exp slicer,QueryPart[] cellProps,Parameter[] parameters){
  this.connection=connection;
  this.cube=mdxCube;
  this.formulas=formulas;
  this.axes=axes;
  normalizeAxes();
  this.slicerAxis=slicer == null ? null : new QueryAxis(false,slicer,AxisOrdinal.Slicer,QueryAxis.SubtotalVisibility.Undefined);
  this.cellProps=cellProps;
  this.parameters=parameters;
  resolve();
}

Fixed version (ground truth):
/** 
 * Creates a Query.
 */
public Query(Connection connection,Cube mdxCube,Formula[] formulas,QueryAxis[] axes,Exp slicer,QueryPart[] cellProps,Parameter[] parameters){
  this.connection=connection;
  this.cube=mdxCube;
  this.formulas=formulas;
  this.axes=axes;
  normalizeAxes();
  if (slicer == null) {
    this.slicerAxis=null;
  }
 else {
    this.slicerAxis=new QueryAxis(false,slicer,AxisOrdinal.Slicer,QueryAxis.SubtotalVisibility.Undefined);
  }
  this.cellProps=cellProps;
  this.parameters=parameters;
  resolve();
}
Program: 51514
Project: 51514
Buggy source:
List getDefinedMembers(){
  List definedMembers=new ArrayList();
  for (int i=0; i < formulas.length; i++) {
    if (formulas[i].isMember() && formulas[i].getElement() != null && getConnection().getRole().canAccess(formulas[i].getElement())) {
      definedMembers.add(formulas[i].getElement());
    }
  }
  return definedMembers;
}

Fixed version (ground truth):
List getDefinedMembers(){
  List definedMembers=new ArrayList();
  for (int i=0; i < formulas.length; i++) {
    final Formula formula=formulas[i];
    if (formula.isMember() && formula.getElement() != null && getConnection().getRole().canAccess(formula.getElement())) {
      definedMembers.add(formula.getElement());
    }
  }
  return definedMembers;
}
Program: 51515
Project: 51515
Buggy source:
/** 
 * Assigns a value to the parameter with a given name.
 * @throws RuntimeException if there is not parameter with the given name
 */
public void setParameter(String parameterName,String value){
  Parameter param=lookupParam(parameterName);
  if (param == null) {
    throw MondrianResource.instance().MdxParamNotFound.ex(parameterName);
  }
  final Exp exp=param.quickParse(value,this);
  param.setValue(exp);
}

Fixed version (ground truth):
/** 
 * Assigns a value to the parameter with a given name.
 * @throws RuntimeException if there is not parameter with the given name
 */
public void setParameter(String parameterName,String value){
  Parameter param=lookupParam(parameterName);
  if (param == null) {
    throw MondrianResource.instance().MdxParamNotFound.ex(parameterName);
  }
  final Exp exp=quickParse(param.getCategory(),value,this);
  param.setValue(exp);
}
Program: 51516
Project: 51516
Buggy source:
/** 
 * Constructs an <code>InvalidObjectException</code> with the specified detail message.
 * @elementInError element in error.
 * @param msg the detail message.
 */
public InvalidObjectException(RefObject elementInError,String msg){
  super(elementInError,msg);
}

Fixed version (ground truth):
/** 
 * Constructs an <code>InvalidObjectException</code> with the specified detail message.
 * @param elementInError element in error.
 * @param msg the detail message.
 */
public InvalidObjectException(RefObject elementInError,String msg){
  super(elementInError,msg);
}
Program: 51517
Project: 51517
Buggy source:
/** 
 * Returns whether this expression depends upon a given dimension.<p/> If it does not depend on the dimension, then re-evaluating the expression with a different member of this context must produce the same answer.<p/> Some examples:<ul> <li>The expression <blockquote><code>[Measures].[Unit Sales]</code></blockquote> depends on all dimensions except <code>[Measures]</code>. <li>The boolean expression <blockquote><code>([Measures].[Unit Sales], [Time].[1997]) &gt; 1000</code></blockquote> depends on all dimensions except [Measures] and [Time]. <li>The list expression <blockquote><code>Filter([Store].[USA].Children, [Measures].[Unit Sales] &lt; 50)</code></pre></blockquote> depends upon all dimensions <em>except</em> [Store] and [Measures]. How so? Normally the scalar expression would depend upon all dimensions except [Measures], but the <code>Filter</code> function sets the [Store] context before evaluating the scalar expression, so it is not inherited from the surrounding context. </ul><p/>
 * @param dimension Dimension
 * @return Whether this expression's result depends upon the current memberof the dimension
 */
boolean dependsOn(Dimension dimension);

Fixed version (ground truth):
/** 
 * Returns whether this expression depends upon a given dimension. <p>If it does not depend on the dimension, then re-evaluating the expression with a different member of this context must produce the same answer.<p/> Some examples:<ul> <li>The expression <blockquote><code>[Measures].[Unit Sales]</code></blockquote> depends on all dimensions except <code>[Measures]</code>. <li>The boolean expression <blockquote><code>([Measures].[Unit Sales], [Time].[1997]) &gt; 1000</code></blockquote> depends on all dimensions except [Measures] and [Time]. <li>The list expression <blockquote><code>Filter([Store].[USA].Children, [Measures].[Unit Sales] &lt; 50)</code></pre></blockquote> depends upon all dimensions <em>except</em> [Store] and [Measures]. How so? Normally the scalar expression would depend upon all dimensions except [Measures], but the <code>Filter</code> function sets the [Store] context before evaluating the scalar expression, so it is not inherited from the surrounding context. </ul><p/>
 * @param dimension Dimension
 * @return Whether this expression's result depends upon the current memberof the dimension
 */
boolean dependsOn(Dimension dimension);
Program: 51518
Project: 51518
Buggy source:
/** 
 * Evaluates this expression to yield a dimension.<p/> Never returns null.
 * @param evaluator Evaluation context
 * @return a dimension
 */
Dimension evaluateDimension(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates this expression to yield a dimension. <p>Never returns null.
 * @param evaluator Evaluation context
 * @return a dimension
 */
Dimension evaluateDimension(Evaluator evaluator);
Program: 51519
Project: 51519
Buggy source:
/** 
 * Evaluates this expression to yield a hierarchy.<p/> Never returns null.
 * @param evaluator Evaluation context
 * @return a hierarchy
 */
Hierarchy evaluateHierarchy(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates this expression to yield a hierarchy. <p>Never returns null.
 * @param evaluator Evaluation context
 * @return a hierarchy
 */
Hierarchy evaluateHierarchy(Evaluator evaluator);
Program: 51520
Project: 51520
Buggy source:
/** 
 * Evaluates this expression to yield a level.<p/> Never returns null.
 * @param evaluator Evaluation context
 * @return a level
 */
Level evaluateLevel(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates this expression to yield a level. <p>Never returns null.
 * @param evaluator Evaluation context
 * @return a level
 */
Level evaluateLevel(Evaluator evaluator);
Program: 51521
Project: 51521
Buggy source:
/** 
 * Evaluates this expression to yield a member.<p/> May return the null member (see  {@link mondrian.olap.Hierarchy#getNullMember()}) but never null.
 * @param evaluator Evaluation context
 * @return a member
 */
Member evaluateMember(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates this expression to yield a member. <p>May return the null member (see  {@link mondrian.olap.Hierarchy#getNullMember()}) but never null.
 * @param evaluator Evaluation context
 * @return a member
 */
Member evaluateMember(Evaluator evaluator);
Program: 51522
Project: 51522
Buggy source:
/** 
 * Evaluates this expression to yield a tuple.<p/> A tuple cannot contain any null members. If any of the members is null, this method must return a null.
 * @post result == null || !tupleContainsNullMember(result)
 * @param evaluator Evaluation context
 * @return an array of members, or null to represent the null tuple
 */
Member[] evaluateTuple(Evaluator evaluator);

Fixed version (ground truth):
/** 
 * Evaluates this expression to yield a tuple. <p>A tuple cannot contain any null members. If any of the members is null, this method must return a null.
 * @post result == null || !tupleContainsNullMember(result)
 * @param evaluator Evaluation context
 * @return an array of members, or null to represent the null tuple
 */
Member[] evaluateTuple(Evaluator evaluator);
Program: 51523
Project: 51523
Buggy source:
/** 
 * Returns the name of this expression type, used when serializing an expression to a string.<p/> The default implementation tries to extract a name from a function call, if any, then prints the last part of the class name.
 */
protected String getName(){
  String name;
  if (exp instanceof ResolvedFunCall) {
    ResolvedFunCall funCall=(ResolvedFunCall)exp;
    name=funCall.getFunDef().getName();
  }
 else {
    name=getClass().getName();
    int dot=name.lastIndexOf('.');
    int dollar=name.lastIndexOf('$');
    int dotDollar=Math.max(dot,dollar);
    if (dotDollar >= 0) {
      name=name.substring(dotDollar + 1);
    }
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Returns the name of this expression type, used when serializing an expression to a string. <p>The default implementation tries to extract a name from a function call, if any, then prints the last part of the class name.
 */
protected String getName(){
  String name;
  if (exp instanceof ResolvedFunCall) {
    ResolvedFunCall funCall=(ResolvedFunCall)exp;
    name=funCall.getFunDef().getName();
  }
 else {
    name=getClass().getName();
    int dot=name.lastIndexOf('.');
    int dollar=name.lastIndexOf('$');
    int dotDollar=Math.max(dot,dollar);
    if (dotDollar >= 0) {
      name=name.substring(dotDollar + 1);
    }
  }
  return name;
}
Program: 51524
Project: 51524
Buggy source:
/** 
 * Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension.<p/> Typical application: <code>Aggregate({Set}, {Value Expression})</code> depends upon everything {Value Expression} depends upon, except the dimensions of {Set}.
 */
public static boolean anyDependsButFirst(Calc[] calcs,Dimension dimension){
  if (calcs.length == 0) {
    return false;
  }
  if (calcs[0].dependsOn(dimension)) {
    return true;
  }
  if (calcs[0].getType().usesDimension(dimension,true)) {
    return false;
  }
  for (int i=1; i < calcs.length; i++) {
    Calc calc=calcs[i];
    if (calc.dependsOn(dimension)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns true if calc[0] depends on dimension, else false if calc[0] returns dimension, else true if any of the other calcs depend on dimension. <p>Typical application: <code>Aggregate({Set}, {Value Expression})</code> depends upon everything {Value Expression} depends upon, except the dimensions of {Set}.
 */
public static boolean anyDependsButFirst(Calc[] calcs,Dimension dimension){
  if (calcs.length == 0) {
    return false;
  }
  if (calcs[0].dependsOn(dimension)) {
    return true;
  }
  if (calcs[0].getType().usesDimension(dimension,true)) {
    return false;
  }
  for (int i=1; i < calcs.length; i++) {
    Calc calc=calcs[i];
    if (calc.dependsOn(dimension)) {
      return true;
    }
  }
  return false;
}
Program: 51525
Project: 51525
Buggy source:
/** 
 * Returns the cell's raw value. This is useful for sending to further data processing, such as plotting a chart. <p> The value is never null. It may have various types:<ul> <li>if the cell is null, the value is an instance of  {@link Util.NullCellValue};</li> <li>if the cell contains an error, the value is an instance of  {@link Throwable};</li> <li>otherwise, the type of this value depends upon the type of measure: possible types include   {@link java.math.BigDecimal},  {@link Double},   {@link Integer} and {@link String}.</li> </ul>
 * @post return != null
 * @post (return instanceof Throwable) == isError()
 * @post (return instanceof Util.NullCellValue) == isNull()
 */
Object getValue();

Fixed version (ground truth):
/** 
 * Returns the cell's raw value. This is useful for sending to further data processing, such as plotting a chart. <p> The value is never null. It may have various types:<ul> <li>if the cell is null, the value is    {@link Util#nullValue};</li> <li>if the cell contains an error, the value is an instance of  {@link Throwable};</li> <li>otherwise, the type of this value depends upon the type of measure: possible types include   {@link java.math.BigDecimal},  {@link Double},   {@link Integer} and {@link String}.</li> </ul>
 * @post return != null
 * @post (return instanceof Throwable) == isError()
 * @post (return instanceof Util.NullCellValue) == isNull()
 */
Object getValue();
Program: 51526
Project: 51526
Buggy source:
/** 
 * Returns the <code>index</code><sup>th</sup> argument to this function call.
 * @param index
 * @return
 */
Exp getArg(int index);

Fixed version (ground truth):
/** 
 * Returns the <code>index</code><sup>th</sup> argument to this function call.
 * @param index Ordinal of the argument
 * @return <code>index</code><sup>th</sup> argument to this function call
 */
Exp getArg(int index);
Program: 51528
Project: 51528
Buggy source:
public void addConstraint(SqlQuery sqlQuery){
  if (orderByExpr != null) {
    Dialect dialect=sqlQuery.getDialect();
    if (dialect.isMySQL()) {
      String alias=sqlQuery.nextColumnAlias();
      alias=dialect.quoteIdentifier(alias);
      sqlQuery.addSelect(orderByExpr,alias);
      sqlQuery.addOrderBy(alias,ascending,true);
    }
 else {
      sqlQuery.addOrderBy(orderByExpr,ascending,true);
    }
  }
  super.addConstraint(sqlQuery);
}

Fixed version (ground truth):
public void addConstraint(SqlQuery sqlQuery){
  if (orderByExpr != null) {
    Dialect dialect=sqlQuery.getDialect();
    if (dialect.isMySQL() || dialect.isDB2()) {
      String alias=sqlQuery.nextColumnAlias();
      alias=dialect.quoteIdentifier(alias);
      sqlQuery.addSelect(orderByExpr,alias);
      sqlQuery.addOrderBy(alias,ascending,true);
    }
 else {
      sqlQuery.addOrderBy(orderByExpr,ascending,true);
    }
  }
  super.addConstraint(sqlQuery);
}