Program: 78463
Project: 78463
Buggy source:
/** 
 * @param sortSpec
 * @return Comparator based on specified sortSpec, null indicates there isno need to do sorting
 */
private Comparator getComparator(SortSpec sortSpec){
  if (sortSpec == null)   return null;
  final int[] sortKeyIndexes=sortSpec.sortKeyIndexes;
  if (sortKeyIndexes == null || sortKeyIndexes.length == 0)   return null;
  final boolean[] sortAscending=sortSpec.sortAscending;
  Comparator comparator=new Comparator(){
    /** 
 * compares two row indexes, actually compares two rows pointed by the two row indexes
 */
    public int compare(    Object obj1,    Object obj2){
      IResultObject row1=(IResultObject)obj1;
      IResultObject row2=(IResultObject)obj2;
      for (int i=0; i < sortKeyIndexes.length; i++) {
        int colIndex=sortKeyIndexes[i];
        try {
          Object colObj1=row1.getFieldValue(colIndex);
          Object colObj2=row2.getFieldValue(colIndex);
          int result=doCompare(colObj1,colObj2);
          if (result != 0) {
            return sortAscending[i] ? result : -result;
          }
        }
 catch (        DataException e) {
        }
      }
      return 0;
    }
    /** 
 * Compare two objects
 * @param colObj1
 * @param colObj2
 * @return true colObj1 equals colObj2
 */
    private int doCompare(    Object colObj1,    Object colObj2){
      int result=0;
      if (colObj1 == colObj2) {
        return result;
      }
      if (colObj1 == null || colObj2 == null) {
        if (colObj1 == null) {
          result=-1;
        }
 else {
          result=1;
        }
        return result;
      }
      if (colObj1.equals(colObj2)) {
        return result;
      }
 else       if (colObj1 instanceof Comparable && colObj2 instanceof Comparable) {
        Comparable comp1=(Comparable)colObj1;
        Comparable comp2=(Comparable)colObj2;
        result=comp1.compareTo(comp2);
      }
 else       if (colObj1 instanceof Boolean && colObj2 instanceof Boolean) {
        Boolean bool=(Boolean)colObj1;
        if (bool.equals(Boolean.TRUE))         result=1;
 else         result=-1;
      }
 else {
      }
      return result;
    }
  }
;
  return comparator;
}

Fixed version (ground truth):
/** 
 * @param sortSpec
 * @return Comparator based on specified sortSpec, null indicates there isno need to do sorting
 */
private Comparator getComparator(SortSpec sortSpec){
  if (sortSpec == null)   return null;
  final int[] sortKeyIndexes=sortSpec.sortKeyIndexes;
  if (sortKeyIndexes == null || sortKeyIndexes.length == 0)   return null;
  final boolean[] sortAscending=sortSpec.sortAscending;
  Comparator comparator=new Comparator(){
    /** 
 * compares two row indexes, actually compares two rows pointed by the two row indexes
 */
    public int compare(    Object obj1,    Object obj2){
      IResultObject row1=(IResultObject)obj1;
      IResultObject row2=(IResultObject)obj2;
      for (int i=0; i < sortKeyIndexes.length; i++) {
        int colIndex=sortKeyIndexes[i];
        try {
          Object colObj1=row1.getFieldValue(colIndex);
          Object colObj2=row2.getFieldValue(colIndex);
          int result=doCompare(colObj1,colObj2);
          if (result != 0) {
            return sortAscending[i] ? result : -result;
          }
        }
 catch (        DataException e) {
        }
      }
      return 0;
    }
    /** 
 * Compare two objects
 * @param colObj1
 * @param colObj2
 * @return true colObj1 equals colObj2
 */
    private int doCompare(    Object colObj1,    Object colObj2){
      int result=0;
      if (colObj1 == colObj2) {
        return result;
      }
      if (colObj1 == null || colObj2 == null) {
        if (colObj1 == null) {
          result=-1;
        }
 else {
          result=1;
        }
        return result;
      }
      if (colObj1.equals(colObj2)) {
        return result;
      }
 else       if (colObj1 instanceof Comparable && colObj2 instanceof Comparable) {
        Comparable comp1=(Comparable)colObj1;
        Comparable comp2=(Comparable)colObj2;
        if (colObj1.getClass() != colObj2.getClass() && colObj1 instanceof Number && colObj2 instanceof Number) {
          try {
            comp1=(Comparable)DataTypeUtil.toDouble(colObj1);
            comp2=(Comparable)DataTypeUtil.toDouble(colObj2);
          }
 catch (          BirtException ex) {
          }
        }
        result=comp1.compareTo(comp2);
      }
 else       if (colObj1 instanceof Boolean && colObj2 instanceof Boolean) {
        Boolean bool=(Boolean)colObj1;
        if (bool.equals(Boolean.TRUE))         result=1;
 else         result=-1;
      }
 else {
      }
      return result;
    }
  }
;
  return comparator;
}