Program: 47973
Project: 47973
Buggy source:
public QueryResult performQuery(Query query) throws IOException {
  List<IndexFieldDefinition> fieldDefs=definition.getFields();
  List<byte[]> fromKeyComponents=new ArrayList<byte[]>(fieldDefs.size());
  byte[] fromKey=null;
  byte[] toKey=null;
  Query.RangeCondition rangeCond=query.getRangeCondition();
  boolean rangeCondSet=false;
  int usedConditionsCount=0;
  int i=0;
  for (; i < fieldDefs.size(); i++) {
    IndexFieldDefinition fieldDef=fieldDefs.get(i);
    Query.EqualsCondition eqCond=query.getCondition(fieldDef.getName());
    if (eqCond != null) {
      checkQueryValueType(fieldDef,eqCond.getValue());
      byte[] bytes=fieldToBytes(fieldDef,eqCond.getValue(),true);
      fromKeyComponents.add(bytes);
      usedConditionsCount++;
    }
 else     if (rangeCond != null) {
      if (!rangeCond.getName().equals(fieldDef.getName())) {
        throw new MalformedQueryException("String_Node_Str" + rangeCond.getName() + "String_Node_Str"+ fieldDef.getName()+ "String_Node_Str");
      }
      List<byte[]> toKeyComponents=new ArrayList<byte[]>(fromKeyComponents.size() + 1);
      toKeyComponents.addAll(fromKeyComponents);
      Object fromValue=query.getRangeCondition().getFromValue();
      Object toValue=query.getRangeCondition().getToValue();
      if (fromValue == Query.MIN_VALUE) {
      }
 else {
        checkQueryValueType(fieldDef,fromValue);
        byte[] bytes=fieldToBytes(fieldDef,fromValue,false);
        fromKeyComponents.add(bytes);
      }
      if (toValue == Query.MAX_VALUE) {
      }
 else {
        checkQueryValueType(fieldDef,toValue);
        byte[] bytes=fieldToBytes(fieldDef,toValue,false);
        toKeyComponents.add(bytes);
      }
      fromKey=concat(fromKeyComponents);
      toKey=concat(toKeyComponents);
      rangeCondSet=true;
      usedConditionsCount++;
      break;
    }
 else {
      break;
    }
  }
  if (i < fieldDefs.size() && usedConditionsCount < query.getEqConditions().size() + (rangeCond != null ? 1 : 0)) {
    StringBuilder message=new StringBuilder();
    message.append("String_Node_Str");
    message.append("String_Node_Str");
    for (; i < fieldDefs.size(); i++) {
      IndexFieldDefinition fieldDef=fieldDefs.get(i);
      if (query.getCondition(fieldDef.getName()) != null) {
        message.append(fieldDef.getName());
      }
 else       if (rangeCond != null && rangeCond.getName().equals(fieldDef.getName())) {
        message.append(fieldDef.getName());
      }
      message.append("String_Node_Str");
    }
    throw new MalformedQueryException(message.toString());
  }
  if (!rangeCondSet) {
    fromKey=concat(fromKeyComponents);
    toKey=fromKey;
  }
  Scan scan=new Scan(fromKey);
  boolean upperBoundInclusive=rangeCond != null && rangeCond.isUpperBoundInclusive() && rangeCond.getToValue() != Query.MAX_VALUE;
  CompareOp op=rangeCondSet && !upperBoundInclusive ? CompareOp.LESS : CompareOp.LESS_OR_EQUAL;
  Filter toFilter=new RowFilter(op,new BinaryPrefixComparator(toKey));
  if (rangeCondSet && !rangeCond.isLowerBoundInclusive()) {
    FilterList filters=new FilterList(FilterList.Operator.MUST_PASS_ALL);
    filters.addFilter(new RowFilter(CompareOp.GREATER,new BinaryPrefixComparator(fromKey)));
    filters.addFilter(toFilter);
    scan.setFilter(filters);
  }
 else {
    scan.setFilter(toFilter);
  }
  return new ScannerQueryResult(htable.getScanner(scan),definition.getIdentifierOrder() == Order.DESCENDING);
}

Fixed version (ground truth):
public QueryResult performQuery(Query query) throws IOException {
  List<IndexFieldDefinition> fieldDefs=definition.getFields();
  List<byte[]> fromKeyComponents=new ArrayList<byte[]>(fieldDefs.size());
  byte[] fromKey=null;
  byte[] toKey=null;
  Query.RangeCondition rangeCond=query.getRangeCondition();
  boolean rangeCondSet=false;
  int usedConditionsCount=0;
  int i=0;
  for (; i < fieldDefs.size(); i++) {
    IndexFieldDefinition fieldDef=fieldDefs.get(i);
    Query.EqualsCondition eqCond=query.getCondition(fieldDef.getName());
    if (eqCond != null) {
      checkQueryValueType(fieldDef,eqCond.getValue());
      byte[] bytes=fieldToBytes(fieldDef,eqCond.getValue(),true);
      fromKeyComponents.add(bytes);
      usedConditionsCount++;
    }
 else     if (rangeCond != null) {
      if (!rangeCond.getName().equals(fieldDef.getName())) {
        throw new MalformedQueryException("String_Node_Str" + rangeCond.getName() + "String_Node_Str"+ fieldDef.getName()+ "String_Node_Str");
      }
      List<byte[]> toKeyComponents=new ArrayList<byte[]>(fromKeyComponents.size() + 1);
      toKeyComponents.addAll(fromKeyComponents);
      Object fromValue=query.getRangeCondition().getFromValue();
      Object toValue=query.getRangeCondition().getToValue();
      if (fromValue == Query.MIN_VALUE) {
      }
 else {
        checkQueryValueType(fieldDef,fromValue);
        byte[] bytes=fieldToBytes(fieldDef,fromValue,false);
        fromKeyComponents.add(bytes);
      }
      if (toValue == Query.MAX_VALUE) {
      }
 else {
        checkQueryValueType(fieldDef,toValue);
        byte[] bytes=fieldToBytes(fieldDef,toValue,false);
        toKeyComponents.add(bytes);
      }
      fromKey=concat(fromKeyComponents);
      toKey=concat(toKeyComponents);
      rangeCondSet=true;
      usedConditionsCount++;
      break;
    }
 else {
      break;
    }
  }
  if (i < fieldDefs.size() && usedConditionsCount < query.getEqConditions().size() + (rangeCond != null ? 1 : 0)) {
    StringBuilder message=new StringBuilder();
    message.append("String_Node_Str");
    message.append("String_Node_Str");
    for (; i < fieldDefs.size(); i++) {
      IndexFieldDefinition fieldDef=fieldDefs.get(i);
      if (query.getCondition(fieldDef.getName()) != null) {
        message.append(fieldDef.getName());
      }
 else       if (rangeCond != null && rangeCond.getName().equals(fieldDef.getName())) {
        message.append(fieldDef.getName());
      }
      message.append("String_Node_Str");
    }
    throw new MalformedQueryException(message.toString());
  }
  if (!rangeCondSet) {
    fromKey=concat(fromKeyComponents);
    toKey=fromKey;
  }
  Scan scan=new Scan(fromKey);
  boolean upperBoundInclusive=rangeCond != null && (rangeCond.isUpperBoundInclusive() || rangeCond.getToValue() == Query.MAX_VALUE);
  CompareOp op=rangeCondSet && !upperBoundInclusive ? CompareOp.LESS : CompareOp.LESS_OR_EQUAL;
  Filter toFilter=new RowFilter(op,new BinaryPrefixComparator(toKey));
  if (rangeCondSet && !rangeCond.isLowerBoundInclusive()) {
    FilterList filters=new FilterList(FilterList.Operator.MUST_PASS_ALL);
    filters.addFilter(new RowFilter(CompareOp.GREATER,new BinaryPrefixComparator(fromKey)));
    filters.addFilter(toFilter);
    scan.setFilter(filters);
  }
 else {
    scan.setFilter(toFilter);
  }
  return new ScannerQueryResult(htable.getScanner(scan),definition.getIdentifierOrder() == Order.DESCENDING);
}