Program: 121373
Project: 121373
Buggy source:
/** 
 * Add a new connection input to the node.
 * @param connection
 */
@Override public void addInput(final IConnection conn){
  this.inputs.add(conn);
  fireStructureChange(INPUTS,conn);
  if (conn instanceof Connection) {
    Connection connection=(Connection)conn;
    if (!ConnectionCreateCommand.isCreatingConnection()) {
      calculateSubtreeStartAndEnd();
      return;
    }
    INodeConnector mainConnector;
    if (isELTComponent()) {
      mainConnector=this.getConnectorFromType(EConnectionType.TABLE);
    }
 else {
      mainConnector=this.getConnectorFromType(EConnectionType.FLOW_MAIN);
    }
    if (insertSet) {
      return;
    }
    if (!mainConnector.isMultiSchema() && (connection.getLineStyle() == EConnectionType.FLOW_MAIN || (connection.getLineStyle() == EConnectionType.TABLE) || ((connection.getLineStyle() == EConnectionType.FLOW_MERGE) && (connection.getInputId() == 1))) && ((Process)getProcess()).isActivate()) {
      boolean repositoryMode=false;
      IMetadataTable mainTargetTable=this.getMetadataFromConnector(mainConnector.getName());
      for (      IElementParameter param : getElementParameters()) {
        if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) && (param.getContext().equals(mainConnector.getName()))) {
          IElementParameter schemaTypeParam=param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
          if (schemaTypeParam.getValue().equals(EmfComponent.REPOSITORY)) {
            repositoryMode=true;
            break;
          }
        }
      }
      String inputConnector=null;
      IMetadataTable inputTable=connection.getMetadataTable();
      if (MetadataToolHelper.hasCustomColumns(inputTable)) {
        inputConnector=conn.getConnectorName();
      }
 else {
        inputConnector=mainConnector.getName();
      }
      IElementParameter inputSchemaParam=null;
      for (      IElementParameter param : conn.getSource().getElementParameters()) {
        if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) && (param.getContext().equals(inputConnector))) {
          inputSchemaParam=param;
          break;
        }
      }
      if (!generatedByJobscriptBool && component.isSchemaAutoPropagated() && !repositoryMode&& (inputTable.getListColumns().size() != 0)) {
        for (        INodeConnector connector : getListConnector()) {
          if (mainConnector.getName().equals(connector.getBaseSchema())) {
            IMetadataTable targetTable=this.getMetadataFromConnector(connector.getName());
            if (targetTable == null) {
              continue;
            }
            boolean customFound=false;
            int customColNumber=0;
            for (int i=0; i < targetTable.getListColumns().size(); i++) {
              IMetadataColumn column=targetTable.getListColumns().get(i);
              if (column.isCustom()) {
                customColNumber++;
              }
            }
            customFound=customColNumber > 0;
            int nonCustomColNumber=targetTable.getListColumns().size() - customColNumber;
            if (nonCustomColNumber == 0 && (((customFound && targetTable.isReadOnly()) || (outputs.size() == 0) || (connection.getLineStyle() == EConnectionType.FLOW_MERGE)) && (inputTable.getListColumns().size() != 0))) {
              String dbmsId=targetTable.getDbms();
              MetadataToolHelper.copyTable(dbmsId,inputTable,targetTable);
              ChangeMetadataCommand cmc=new ChangeMetadataCommand(this,null,null,targetTable,inputSchemaParam);
              cmc.execute();
              ColumnListController.updateColumnList(this,null,true);
            }
 else             if (connection.getTarget().getComponent().getName().equals("String_Node_Str")) {
              String dbmsId=targetTable.getDbms();
              MetadataToolHelper.copyTable(dbmsId,inputTable,targetTable);
              ChangeMetadataCommand cmc=new ChangeMetadataCommand(this,null,null,targetTable,inputSchemaParam);
              cmc.execute();
            }
          }
        }
      }
 else {
        if ((mainTargetTable == null) || (mainTargetTable.getListColumns().size() == 0) || mainTargetTable.sameMetadataAs(connection.getMetadataTable(),IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT| IMetadataColumn.OPTIONS_IGNORE_PATTERN| IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME| IMetadataColumn.OPTIONS_IGNORE_DBTYPE| IMetadataColumn.OPTIONS_IGNORE_DEFAULT| IMetadataColumn.OPTIONS_IGNORE_BIGGER_SIZE)) {
          return;
        }
        IConnection outputConnection=null;
        if ((connection.getSource().getSchemaParameterFromConnector(mainConnector.getName()) != null)) {
          if (connection.getSource().getOutgoingConnections(connection.getConnectorName()).size() == 1) {
            outputConnection=connection.getSource().getOutgoingConnections(connection.getConnectorName()).get(0);
          }
          if (template) {
            if (takeSchema == null) {
              takeSchema=true;
            }
          }
 else {
            if (takeSchema == null) {
              takeSchema=getTakeSchema();
            }
          }
          if (takeSchema) {
            ((Node)connection.getSource()).takeSchemaFrom(this,mainConnector.getName());
          }
        }
 else         if (connection.getSourceNodeConnector().isMultiSchema()) {
          if (template) {
            if (takeSchema == null) {
              takeSchema=true;
            }
          }
 else {
            if (takeSchema == null) {
              takeSchema=getTakeSchema();
            }
          }
          if (takeSchema.booleanValue()) {
            MetadataToolHelper.copyTable(mainTargetTable,connection.getMetadataTable());
            if (connection.getTarget().isELTComponent()) {
              IElementParameter elemParam=connection.getTarget().getElementParameter("String_Node_Str");
              if (elemParam != null && elemParam.getFieldType().equals(EParameterFieldType.TEXT)) {
                String removeQuotes=TalendTextUtils.removeQuotes(elemParam.getValue().toString());
                if (!removeQuotes.equals("String_Node_Str") && "String_Node_Str".equals(connection.getName())) {
                  connection.setName(removeQuotes);
                }
              }
            }
          }
 else {
            IMetadataTable sourceTable=connection.getMetadataTable();
            if (sourceTable != null) {
              MetadataDialog dialog=new MetadataDialog(new Shell(),sourceTable.clone(),connection.getSource(),null);
              dialog.setInputReadOnly(false);
              dialog.setOutputReadOnly(false);
              if (dialog.open() == MetadataDialog.OK) {
                final IMetadataTable oldTable=sourceTable;
                final IMetadataTable newTable=dialog.getOutputMetaData();
                if (!oldTable.sameMetadataAs(newTable,IMetadataColumn.OPTIONS_NONE)) {
                  CommandStack cmdStack=getCommandStack();
                  if (cmdStack != null) {
                    cmdStack.execute(new Command(){
                      @Override public void execute(){
                        oldTable.setListColumns(newTable.getListColumns());
                      }
                    }
);
                  }
                }
              }
            }
          }
        }
 else {
          ((Node)connection.getSource()).checkAndRefreshNode();
          checkAndRefreshNode();
        }
      }
    }
    calculateSubtreeStartAndEnd();
  }
}

Fixed version (ground truth):
/** 
 * Add a new connection input to the node.
 * @param connection
 */
@Override public void addInput(final IConnection conn){
  this.inputs.add(conn);
  fireStructureChange(INPUTS,conn);
  if (conn instanceof Connection) {
    Connection connection=(Connection)conn;
    if (!ConnectionCreateCommand.isCreatingConnection()) {
      calculateSubtreeStartAndEnd();
      return;
    }
    INodeConnector mainConnector;
    if (isELTComponent()) {
      mainConnector=this.getConnectorFromType(EConnectionType.TABLE);
    }
 else {
      mainConnector=this.getConnectorFromType(EConnectionType.FLOW_MAIN);
    }
    if (insertSet) {
      return;
    }
    if (!mainConnector.isMultiSchema() && (connection.getLineStyle() == EConnectionType.FLOW_MAIN || (connection.getLineStyle() == EConnectionType.TABLE) || ((connection.getLineStyle() == EConnectionType.FLOW_MERGE) && (connection.getInputId() == 1))) && ((Process)getProcess()).isActivate()) {
      boolean repositoryMode=false;
      IMetadataTable mainTargetTable=this.getMetadataFromConnector(mainConnector.getName());
      for (      IElementParameter param : getElementParameters()) {
        if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) && (param.getContext().equals(mainConnector.getName()))) {
          IElementParameter schemaTypeParam=param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
          if (schemaTypeParam.getValue().equals(EmfComponent.REPOSITORY)) {
            repositoryMode=true;
            break;
          }
        }
      }
      String inputConnector=null;
      IMetadataTable inputTable=connection.getMetadataTable();
      if (MetadataToolHelper.hasCustomColumns(inputTable)) {
        inputConnector=conn.getConnectorName();
      }
 else {
        inputConnector=mainConnector.getName();
      }
      IElementParameter inputSchemaParam=null;
      for (      IElementParameter param : conn.getSource().getElementParameters()) {
        if ((param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) && (param.getContext().equals(inputConnector))) {
          inputSchemaParam=param;
          break;
        }
      }
      if (!generatedByJobscriptBool && component.isSchemaAutoPropagated() && !repositoryMode&& (inputTable.getListColumns().size() != 0)) {
        for (        INodeConnector connector : getListConnector()) {
          if (mainConnector.getName().equals(connector.getBaseSchema())) {
            IMetadataTable targetTable=this.getMetadataFromConnector(connector.getName());
            if (targetTable == null) {
              continue;
            }
            boolean customFound=false;
            int customColNumber=0;
            for (int i=0; i < targetTable.getListColumns().size(); i++) {
              IMetadataColumn column=targetTable.getListColumns().get(i);
              if (column.isCustom()) {
                customColNumber++;
              }
            }
            customFound=customColNumber > 0;
            int nonCustomColNumber=targetTable.getListColumns().size() - customColNumber;
            if (nonCustomColNumber == 0 && (((customFound && targetTable.isReadOnly()) || (outputs.size() == 0) || (connection.getLineStyle() == EConnectionType.FLOW_MERGE)) && (inputTable.getListColumns().size() != 0))) {
              String dbmsId=targetTable.getDbms();
              MetadataToolHelper.copyTable(dbmsId,inputTable,targetTable);
              ChangeMetadataCommand cmc=new ChangeMetadataCommand(this,null,null,targetTable,inputSchemaParam);
              cmc.execute();
              ColumnListController.updateColumnList(this,null,true);
            }
 else             if (connection.getTarget().getComponent().getName().equals("String_Node_Str")) {
              String dbmsId=targetTable.getDbms();
              MetadataToolHelper.copyTable(dbmsId,inputTable,targetTable);
              ChangeMetadataCommand cmc=new ChangeMetadataCommand(this,null,null,targetTable,inputSchemaParam);
              cmc.execute();
            }
          }
        }
      }
 else {
        if (mainTargetTable == null) {
          return;
        }
        boolean haveNonCustomColumn=false;
        for (        IMetadataColumn column : mainTargetTable.getListColumns()) {
          if (!column.isCustom()) {
            haveNonCustomColumn=true;
            break;
          }
        }
        if ((!haveNonCustomColumn) || mainTargetTable.sameMetadataAs(connection.getMetadataTable(),IMetadataColumn.OPTIONS_IGNORE_KEY | IMetadataColumn.OPTIONS_IGNORE_NULLABLE | IMetadataColumn.OPTIONS_IGNORE_COMMENT| IMetadataColumn.OPTIONS_IGNORE_PATTERN| IMetadataColumn.OPTIONS_IGNORE_DBCOLUMNNAME| IMetadataColumn.OPTIONS_IGNORE_DBTYPE| IMetadataColumn.OPTIONS_IGNORE_DEFAULT| IMetadataColumn.OPTIONS_IGNORE_BIGGER_SIZE)) {
          return;
        }
        IConnection outputConnection=null;
        if ((connection.getSource().getSchemaParameterFromConnector(mainConnector.getName()) != null)) {
          if (connection.getSource().getOutgoingConnections(connection.getConnectorName()).size() == 1) {
            outputConnection=connection.getSource().getOutgoingConnections(connection.getConnectorName()).get(0);
          }
          if (template) {
            if (takeSchema == null) {
              takeSchema=true;
            }
          }
 else {
            if (takeSchema == null) {
              takeSchema=getTakeSchema();
            }
          }
          if (takeSchema) {
            ((Node)connection.getSource()).takeSchemaFrom(this,mainConnector.getName());
          }
        }
 else         if (connection.getSourceNodeConnector().isMultiSchema()) {
          if (template) {
            if (takeSchema == null) {
              takeSchema=true;
            }
          }
 else {
            if (takeSchema == null) {
              takeSchema=getTakeSchema();
            }
          }
          if (takeSchema.booleanValue()) {
            MetadataToolHelper.copyTable(mainTargetTable,connection.getMetadataTable());
            if (connection.getTarget().isELTComponent()) {
              IElementParameter elemParam=connection.getTarget().getElementParameter("String_Node_Str");
              if (elemParam != null && elemParam.getFieldType().equals(EParameterFieldType.TEXT)) {
                String removeQuotes=TalendTextUtils.removeQuotes(elemParam.getValue().toString());
                if (!removeQuotes.equals("String_Node_Str") && "String_Node_Str".equals(connection.getName())) {
                  connection.setName(removeQuotes);
                }
              }
            }
          }
 else {
            IMetadataTable sourceTable=connection.getMetadataTable();
            if (sourceTable != null) {
              MetadataDialog dialog=new MetadataDialog(new Shell(),sourceTable.clone(),connection.getSource(),null);
              dialog.setInputReadOnly(false);
              dialog.setOutputReadOnly(false);
              if (dialog.open() == MetadataDialog.OK) {
                final IMetadataTable oldTable=sourceTable;
                final IMetadataTable newTable=dialog.getOutputMetaData();
                if (!oldTable.sameMetadataAs(newTable,IMetadataColumn.OPTIONS_NONE)) {
                  CommandStack cmdStack=getCommandStack();
                  if (cmdStack != null) {
                    cmdStack.execute(new Command(){
                      @Override public void execute(){
                        oldTable.setListColumns(newTable.getListColumns());
                      }
                    }
);
                  }
                }
              }
            }
          }
        }
 else {
          ((Node)connection.getSource()).checkAndRefreshNode();
          checkAndRefreshNode();
        }
      }
    }
    calculateSubtreeStartAndEnd();
  }
}