Program: 163436
Project: 163436
Buggy source:
/** 
 * Identifies which fields are associated with which columns in a row.
 * @param row A row with values for the given java bean.
 * @param headers The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexes The indexes of the headers or row that are actually being used. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @param columnsReordered Indicates the indexes provided were reordered and do not match the original sequence of headers.
 */
private void mapFieldIndexes(Object[] row,String[] headers,int[] indexes,boolean columnsReordered){
  this.fieldIndexesMapped=true;
  if (headers == null) {
    headers=ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  int biggestIndex=headers.length > row.length ? headers.length : row.length;
  for (  FieldMapping mapping : parsedFields) {
    int index=mapping.getIndex();
    if (biggestIndex < index) {
      biggestIndex=index;
    }
  }
  FieldMapping[] fieldOrder=new FieldMapping[biggestIndex];
  for (  FieldMapping mapping : parsedFields) {
    if (mapping.isMappedToField()) {
      int index=ArgumentUtils.indexOf(headers,mapping.getFieldName());
      if (index == -1) {
        throw new IllegalStateException("String_Node_Str" + mapping.getFieldName() + "String_Node_Str"+ Arrays.toString(headers));
      }
      fieldOrder[index]=mapping;
    }
 else {
      fieldOrder[mapping.getIndex()]=mapping;
    }
  }
  if (indexes != null) {
    for (int i=0; i < fieldOrder.length; i++) {
      boolean isIndexUsed=false;
      for (int j=0; j < indexes.length; j++) {
        if (indexes[j] == i) {
          isIndexUsed=true;
          break;
        }
      }
      if (!isIndexUsed) {
        fieldOrder[i]=null;
      }
    }
    if (columnsReordered) {
      FieldMapping[] newFieldOrder=new FieldMapping[indexes.length];
      for (int i=0; i < indexes.length; i++) {
        for (int j=0; j < fieldOrder.length; j++) {
          int index=indexes[i];
          FieldMapping field=fieldOrder[index];
          newFieldOrder[i]=field;
        }
      }
      fieldOrder=newFieldOrder;
    }
  }
  this.readOrder=fieldOrder;
}

Fixed version (ground truth):
/** 
 * Identifies which fields are associated with which columns in a row.
 * @param row A row with values for the given java bean.
 * @param headers The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexes The indexes of the headers or row that are actually being used. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @param columnsReordered Indicates the indexes provided were reordered and do not match the original sequence of headers.
 */
private void mapFieldIndexes(Object[] row,String[] headers,int[] indexes,boolean columnsReordered){
  if (headers == null) {
    headers=ArgumentUtils.EMPTY_STRING_ARRAY;
  }
  int biggestIndex=headers.length > row.length ? headers.length : row.length;
  for (  FieldMapping mapping : parsedFields) {
    int index=mapping.getIndex();
    if (biggestIndex < index) {
      biggestIndex=index;
    }
  }
  FieldMapping[] fieldOrder=new FieldMapping[biggestIndex];
  for (  FieldMapping mapping : parsedFields) {
    if (mapping.isMappedToField()) {
      int index=ArgumentUtils.indexOf(headers,mapping.getFieldName());
      if (index == -1) {
        throw new IllegalStateException("String_Node_Str" + mapping.getFieldName() + "String_Node_Str"+ Arrays.toString(headers));
      }
      fieldOrder[index]=mapping;
    }
 else {
      if (mapping.getIndex() < fieldOrder.length) {
        fieldOrder[mapping.getIndex()]=mapping;
      }
    }
  }
  if (indexes != null) {
    for (int i=0; i < fieldOrder.length; i++) {
      boolean isIndexUsed=false;
      for (int j=0; j < indexes.length; j++) {
        if (indexes[j] == i) {
          isIndexUsed=true;
          break;
        }
      }
      if (!isIndexUsed) {
        fieldOrder[i]=null;
      }
    }
    if (columnsReordered) {
      FieldMapping[] newFieldOrder=new FieldMapping[indexes.length];
      for (int i=0; i < indexes.length; i++) {
        for (int j=0; j < fieldOrder.length; j++) {
          int index=indexes[i];
          FieldMapping field=fieldOrder[index];
          newFieldOrder[i]=field;
        }
      }
      fieldOrder=newFieldOrder;
    }
  }
  this.readOrder=fieldOrder;
}