Program: 120946
Project: 120946
Buggy source:
/** 
 * DOC chuang Comment method "fixKeyColumnsInOutputSchema".
 * @param schema
 * @param inputColumnsMap
 * @param lang
 */
private void fixKeyColumnsInOutputSchema(IMetadataTable schema,Map<String,IMetadataColumn> inputColumnsMap,ECodeLanguage lang){
  Map<String,IMetadataColumn> columnsMap=new HashMap<String,IMetadataColumn>();
  for (  IMetadataColumn column : schema.getListColumns()) {
    columnsMap.put(column.getLabel(),column);
  }
  if (sourceKeys != null && !sourceKeys.isEmpty()) {
    for (    String key : sourceKeys) {
      IMetadataColumn column=columnsMap.get(key);
      if (column != null && GENERATE_COLUMN.equals(column.getComment())) {
        column.setKey(false);
      }
    }
  }
  if (surrogateKeys != null && !surrogateKeys.isEmpty()) {
    for (    SurrogateKey key : surrogateKeys) {
      if (StringUtils.isEmpty(key.getColumn())) {
        continue;
      }
      IMetadataColumn column=columnsMap.get(key.getColumn());
      if (column == null) {
        if (key.getCreation() == SurrogateCreationType.INPUT_FIELD) {
          IMetadataColumn inputCol=inputColumnsMap.get(key.getComplement());
          if (inputCol != null) {
            column=inputCol.clone();
            column.setLabel(key.getColumn());
            column.setOriginalDbColumnName(key.getColumn());
            column.setComment(GENERATE_COLUMN);
            column.setKey(true);
            schema.getListColumns().add(column);
          }
        }
 else {
          column=createMetadataColumn(columnsMap,schema,key.getColumn(),Integer.class,lang);
          column.setKey(true);
          if (key.getCreation() == SurrogateCreationType.ROUTINE) {
            column.setTalendType(getType(String.class,lang));
          }
 else           if (key.getCreation() == SurrogateCreationType.DB_SEQUENCE) {
            column.setTalendType(getType(String.class,lang));
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC chuang Comment method "fixKeyColumnsInOutputSchema".
 * @param schema
 * @param inputColumnsMap
 * @param lang
 */
private void fixKeyColumnsInOutputSchema(IMetadataTable schema,Map<String,IMetadataColumn> inputColumnsMap,ECodeLanguage lang){
  Map<String,IMetadataColumn> columnsMap=new HashMap<String,IMetadataColumn>();
  for (  IMetadataColumn column : schema.getListColumns()) {
    columnsMap.put(column.getLabel(),column);
  }
  if (sourceKeys != null && !sourceKeys.isEmpty()) {
    for (    String key : sourceKeys) {
      IMetadataColumn column=columnsMap.get(key);
      if (column != null && GENERATE_COLUMN.equals(column.getComment())) {
        column.setKey(false);
      }
    }
  }
  if (surrogateKeys != null && !surrogateKeys.isEmpty()) {
    for (    SurrogateKey key : surrogateKeys) {
      if (StringUtils.isEmpty(key.getColumn())) {
        continue;
      }
      IMetadataColumn column=columnsMap.get(key.getColumn());
      if (column == null) {
        if (key.getCreation() == SurrogateCreationType.INPUT_FIELD) {
          IMetadataColumn inputCol=inputColumnsMap.get(key.getComplement());
          if (inputCol != null) {
            column=inputCol.clone();
            column.setLabel(key.getColumn());
            column.setOriginalDbColumnName(key.getColumn());
            column.setComment(GENERATE_COLUMN);
            column.setKey(true);
            schema.getListColumns().add(column);
          }
        }
 else {
          column=createMetadataColumn(columnsMap,schema,key.getColumn(),Integer.class,lang);
          column.setKey(true);
          if (key.getCreation() == SurrogateCreationType.ROUTINE) {
            column.setTalendType(getType(String.class,lang));
          }
 else           if (key.getCreation() == SurrogateCreationType.DB_SEQUENCE) {
            column.setTalendType(getType(String.class,lang));
          }
        }
      }
      if (column != null) {
        column.setCustomId(0);
        column.setCustom(true);
      }
    }
  }
}