Program: 120958
Project: 120958
Buggy source:
/** 
 * DOC chuang Comment method "createOutputSchema".
 * @param unusedFields
 */
public void createOutputSchema(){
  Map<String,IMetadataColumn> outputColumns=removeUnusedAndGeneratedColumns(component.getMetadataList(),unusedFields);
  IMetadataTable schema=component.getMetadataList().get(0);
  Map<String,IMetadataColumn> inputColumnsMap=new HashMap<String,IMetadataColumn>();
  List<IMetadataColumn> inputColumns=getInputColumns(component);
  for (  IMetadataColumn column : inputColumns) {
    inputColumnsMap.put(column.getLabel(),column);
    if (!unusedFields.contains(column.getLabel()) && outputColumns.get(column.getLabel()) == null) {
      schema.getListColumns().add(cloneColumn(column,column.getLabel()));
    }
  }
  if (type3Table != null) {
    for (    Type3Field type3 : type3Table) {
      if (outputColumns.get(type3.getPreviousValue()) != null || StringUtils.isEmpty(type3.getPreviousValue())) {
        continue;
      }
      IMetadataColumn column=inputColumnsMap.get(type3.getCurrentValue());
      IMetadataColumn previous=cloneColumn(column,type3.getPreviousValue());
      outputColumns.put(previous.getLabel(),previous);
      schema.getListColumns().add(previous);
    }
  }
  ECodeLanguage lang=LanguageManager.getCurrentLanguage();
  if (type2Table != null && !type2Table.isEmpty()) {
    createMetadataColumn(outputColumns,schema,versionData.getStartName(),Date.class,lang);
    IMetadataColumn endColumn=createMetadataColumn(outputColumns,schema,versionData.getEndName(),Date.class,lang);
    if (endColumn != null) {
      endColumn.setNullable(true);
    }
    if (versionData.isVersionChecked()) {
      createMetadataColumn(outputColumns,schema,versionData.getVersionName(),Integer.class,lang);
    }
    if (versionData.isActiveChecked()) {
      createMetadataColumn(outputColumns,schema,versionData.getActiveName(),Boolean.class,lang);
    }
  }
  fixKeyColumnsInOutputSchema(schema,inputColumnsMap,lang);
  Collections.sort(schema.getListColumns(),new Comparator<IMetadataColumn>(){
    public int compare(    IMetadataColumn o1,    IMetadataColumn o2){
      return o1.getLabel().compareTo(o2.getLabel());
    }
  }
);
}

Fixed version (ground truth):
/** 
 * DOC chuang Comment method "createOutputSchema".
 * @param unusedFields
 */
public void createOutputSchema(){
  Map<String,IMetadataColumn> outputColumns=removeUnusedAndGeneratedColumns(component.getMetadataList(),unusedFields);
  IMetadataTable schema=component.getMetadataList().get(0);
  Map<String,IMetadataColumn> inputColumnsMap=new HashMap<String,IMetadataColumn>();
  List<IMetadataColumn> inputColumns=getInputColumns(component);
  for (  IMetadataColumn column : inputColumns) {
    inputColumnsMap.put(column.getLabel(),column);
    if (!unusedFields.contains(column.getLabel()) && outputColumns.get(column.getLabel()) == null) {
      schema.getListColumns().add(cloneColumn(column,column.getLabel()));
    }
  }
  if (type3Table != null) {
    for (    Type3Field type3 : type3Table) {
      if (outputColumns.get(type3.getPreviousValue()) != null || StringUtils.isEmpty(type3.getPreviousValue())) {
        continue;
      }
      IMetadataColumn column=inputColumnsMap.get(type3.getCurrentValue());
      IMetadataColumn previous=cloneColumn(column,type3.getPreviousValue());
      outputColumns.put(previous.getLabel(),previous);
      schema.getListColumns().add(previous);
    }
  }
  ECodeLanguage lang=LanguageManager.getCurrentLanguage();
  if (type2Table != null && !type2Table.isEmpty()) {
    IMetadataColumn startColumn=createMetadataColumn(outputColumns,schema,versionData.getStartName(),Date.class,lang);
    if (startColumn != null) {
      startColumn.setCustomId(1);
      startColumn.setCustom(true);
    }
    IMetadataColumn endColumn=createMetadataColumn(outputColumns,schema,versionData.getEndName(),Date.class,lang);
    if (endColumn != null) {
      endColumn.setNullable(true);
      endColumn.setCustomId(2);
      endColumn.setCustom(true);
    }
    if (versionData.isVersionChecked()) {
      IMetadataColumn versionColumn=createMetadataColumn(outputColumns,schema,versionData.getVersionName(),Integer.class,lang);
      if (versionColumn != null) {
        versionColumn.setCustomId(3);
        versionColumn.setCustom(true);
      }
    }
    if (versionData.isActiveChecked()) {
      IMetadataColumn activeColumn=createMetadataColumn(outputColumns,schema,versionData.getActiveName(),Boolean.class,lang);
      if (activeColumn != null) {
        activeColumn.setCustomId(4);
        activeColumn.setCustom(true);
      }
    }
  }
  fixKeyColumnsInOutputSchema(schema,inputColumnsMap,lang);
  Collections.sort(schema.getListColumns(),new Comparator<IMetadataColumn>(){
    public int compare(    IMetadataColumn o1,    IMetadataColumn o2){
      return o1.getLabel().compareTo(o2.getLabel());
    }
  }
);
}