Program: 121551
Project: 121551
Buggy source:
/** 
 * Add a new connection output to the node.
 * @param connection
 */
@Override public void addOutput(final IConnection conn){
  if (conn instanceof Connection) {
    int order=((Connection)conn).getOrder();
    if (order != -1) {
      if (order > outputs.size()) {
        outputs.add(conn);
      }
 else {
        outputs.add(order,conn);
      }
      fireStructureChange(OUTPUTS,conn);
      return;
    }
  }
  List<IConnection> listNm=(List<IConnection>)conn.getSource().getOutgoingConnections(conn.getLineStyle());
  int deactiveNum=0;
  for (int i=0; i < outputs.size(); i++) {
    if (!outputs.get(i).isActivate()) {
      deactiveNum=deactiveNum + 1;
    }
  }
  if (outputs != null && outputs.size() > 0) {
    this.outputs.add(outputs.size() - deactiveNum,conn);
  }
 else {
    this.outputs.add(conn);
  }
  Node target=(Node)conn.getTarget();
  if (isBasedOnInputSchemas(target)) {
    IElementParameter elementParameter=target.getElementParameter(EParameterName.SCHEMAS.getName());
    List<Map<String,String>> vlist=(List<Map<String,String>>)elementParameter.getValue();
    IMetadataTable table=conn.getMetadataTable();
    table.setTableName(conn.getName());
    String label=table.getTableName();
    IMetadataTable metadataTable=MetadataToolHelper.getMetadataTableFromNode(target,label);
    if (metadataTable == null) {
      table.setLabel(label);
      target.metadataList.add(table);
      Map<String,String> map=new HashMap<String,String>();
      map.put(IEbcdicConstant.FIELD_SCHEMA,label);
      vlist.add(map);
    }
  }
  calculateSubtreeStart();
  fireStructureChange(OUTPUTS,conn);
}

Fixed version (ground truth):
/** 
 * Add a new connection output to the node.
 * @param connection
 */
@Override public void addOutput(final IConnection conn){
  if (conn instanceof Connection) {
    int order=((Connection)conn).getOrder();
    if (order != -1) {
      if (order > outputs.size()) {
        outputs.add(conn);
      }
 else {
        outputs.add(order,conn);
      }
      calculateSubtreeStartAndEnd();
      fireStructureChange(OUTPUTS,conn);
      return;
    }
  }
  List<IConnection> listNm=(List<IConnection>)conn.getSource().getOutgoingConnections(conn.getLineStyle());
  int deactiveNum=0;
  for (int i=0; i < outputs.size(); i++) {
    if (!outputs.get(i).isActivate()) {
      deactiveNum=deactiveNum + 1;
    }
  }
  if (outputs != null && outputs.size() > 0) {
    this.outputs.add(outputs.size() - deactiveNum,conn);
  }
 else {
    this.outputs.add(conn);
  }
  Node target=(Node)conn.getTarget();
  if (isBasedOnInputSchemas(target)) {
    IElementParameter elementParameter=target.getElementParameter(EParameterName.SCHEMAS.getName());
    List<Map<String,String>> vlist=(List<Map<String,String>>)elementParameter.getValue();
    IMetadataTable table=conn.getMetadataTable();
    table.setTableName(conn.getName());
    String label=table.getTableName();
    IMetadataTable metadataTable=MetadataToolHelper.getMetadataTableFromNode(target,label);
    if (metadataTable == null) {
      table.setLabel(label);
      target.metadataList.add(table);
      Map<String,String> map=new HashMap<String,String>();
      map.put(IEbcdicConstant.FIELD_SCHEMA,label);
      vlist.add(map);
    }
  }
  calculateSubtreeStartAndEnd();
  fireStructureChange(OUTPUTS,conn);
}