Program: 57833
Project: 57833
Buggy source:
@Override public int compare(DatanodeDescriptor d1,DatanodeDescriptor d2){
  int ret=0;
switch (sortField) {
case FIELD_LAST_CONTACT:
    ret=(int)(d2.getLastUpdate() - d1.getLastUpdate());
  break;
case FIELD_CAPACITY:
long dlong=d1.getCapacity() - d2.getCapacity();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_USED:
dlong=d1.getDfsUsed() - d2.getDfsUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_NONDFS_USED:
dlong=d1.getNonDfsUsed() - d2.getNonDfsUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_REMAINING:
dlong=d1.getRemaining() - d2.getRemaining();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_PERCENT_USED:
double ddbl=((d1.getDfsUsedPercent()) - (d2.getDfsUsedPercent()));
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_PERCENT_REMAINING:
ddbl=((d1.getRemainingPercent()) - (d2.getRemainingPercent()));
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_BLOCKS:
ret=d1.numBlocks() - d2.numBlocks();
break;
case FIELD_ADMIN_STATE:
ret=d1.getAdminState().toString().compareTo(d2.getAdminState().toString());
break;
case FIELD_DECOMMISSIONED:
ret=DFSUtil.DECOM_COMPARATOR.compare(d1,d2);
break;
case FIELD_NAME:
ret=d1.getHostName().compareTo(d2.getHostName());
break;
case FIELD_BLOCKPOOL_USED:
dlong=d1.getBlockPoolUsed() - d2.getBlockPoolUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_PERBLOCKPOOL_USED:
ddbl=d1.getBlockPoolUsedPercent() - d2.getBlockPoolUsedPercent();
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_FAILED_VOLUMES:
int dint=d1.getVolumeFailures() - d2.getVolumeFailures();
ret=(dint < 0) ? -1 : ((dint > 0) ? 1 : 0);
break;
}
return (sortOrder == SORT_ORDER_DSC) ? -ret : ret;
}

Fixed version (ground truth):
@Override public int compare(DatanodeDescriptor d1,DatanodeDescriptor d2){
  int ret=0;
switch (sortField) {
case FIELD_LAST_CONTACT:
    ret=(int)(d2.getLastUpdate() - d1.getLastUpdate());
  break;
case FIELD_CAPACITY:
long dlong=d1.getCapacity() - d2.getCapacity();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_USED:
dlong=d1.getDfsUsed() - d2.getDfsUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_NONDFS_USED:
dlong=d1.getNonDfsUsed() - d2.getNonDfsUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_REMAINING:
dlong=d1.getRemaining() - d2.getRemaining();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_PERCENT_USED:
double ddbl=((d1.getDfsUsedPercent()) - (d2.getDfsUsedPercent()));
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_PERCENT_REMAINING:
ddbl=((d1.getRemainingPercent()) - (d2.getRemainingPercent()));
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_BLOCKS:
ret=d1.numBlocks() - d2.numBlocks();
break;
case FIELD_ADMIN_STATE:
ret=d1.getAdminState().toString().compareTo(d2.getAdminState().toString());
break;
case FIELD_DECOMMISSIONED:
ret=DFSUtil.DECOM_COMPARATOR.compare(d1,d2);
break;
case FIELD_NAME:
ret=d1.getHostName().compareTo(d2.getHostName());
break;
case FIELD_BLOCKPOOL_USED:
dlong=d1.getBlockPoolUsed() - d2.getBlockPoolUsed();
ret=(dlong < 0) ? -1 : ((dlong > 0) ? 1 : 0);
break;
case FIELD_PERBLOCKPOOL_USED:
ddbl=d1.getBlockPoolUsedPercent() - d2.getBlockPoolUsedPercent();
ret=(ddbl < 0) ? -1 : ((ddbl > 0) ? 1 : 0);
break;
case FIELD_FAILED_VOLUMES:
int dint=d1.getVolumeFailures() - d2.getVolumeFailures();
ret=(dint < 0) ? -1 : ((dint > 0) ? 1 : 0);
break;
default :
throw new IllegalArgumentException("String_Node_Str");
}
return (sortOrder == SORT_ORDER_DSC) ? -ret : ret;
}