Program: 119534
Project: 119534
Buggy source:
private void initCDC(CompoundCommand cc,ConnectionItem originalConnectionItem){
  if (!(elem instanceof Node)) {
    return;
  }
  Node node=(Node)elem;
  ConnectionItem connectionItem=originalConnectionItem;
  Connection originalConnection=connectionItem.getConnection();
  Connection connection=connectionItem.getConnection();
  if (node.getComponent().getName().contains("String_Node_Str")) {
    if (originalConnectionItem instanceof DatabaseConnectionItem) {
      final DatabaseConnection databaseConnection=(DatabaseConnection)connection;
      CDCConnection cdcConn=databaseConnection.getCdcConns();
      if (cdcConn != null) {
        EList cdcTypes=cdcConn.getCdcTypes();
        if (cdcTypes != null && !cdcTypes.isEmpty()) {
          CDCType cdcType=(CDCType)cdcTypes.get(0);
          String propertyId=cdcType.getLinkDB();
          try {
            IRepositoryViewObject object=ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
            if (object != null) {
              if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                DatabaseConnectionItem dbConnItem=(DatabaseConnectionItem)object.getProperty().getItem();
                connectionItem=dbConnItem;
                connection=dbConnItem.getConnection();
              }
            }
          }
 catch (          PersistenceException e) {
            ExceptionHandler.process(e);
          }
          IElementParameter logModeParam=node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
          if (logModeParam != null) {
            String cdcTypeMode=((DatabaseConnection)originalConnection).getCdcTypeMode();
            Command logModeCmd=new PropertyChangeCommand(node,EParameterName.CDC_TYPE_MODE.getName(),CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
            cc.add(logModeCmd);
          }
          final String name="String_Node_Str";
          IElementParameter libParam=node.getElementParameter(name);
          if (libParam != null) {
            Command libSettingCmd=new PropertyChangeCommand(node,name,TalendTextUtils.addQuotes(databaseConnection.getSID()));
            cc.add(libSettingCmd);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void initCDC(CompoundCommand cc,ConnectionItem originalConnectionItem){
  if (!(elem instanceof Node)) {
    return;
  }
  Node node=(Node)elem;
  ConnectionItem connectionItem=originalConnectionItem;
  Connection originalConnection=connectionItem.getConnection();
  Connection connection=connectionItem.getConnection();
  if (node.getComponent().getName().contains("String_Node_Str")) {
    if (originalConnectionItem instanceof DatabaseConnectionItem) {
      final DatabaseConnection databaseConnection=(DatabaseConnection)connection;
      CDCConnection cdcConn=databaseConnection.getCdcConns();
      if (cdcConn != null) {
        EList cdcTypes=cdcConn.getCdcTypes();
        if (cdcTypes != null && !cdcTypes.isEmpty()) {
          CDCType cdcType=(CDCType)cdcTypes.get(0);
          String propertyId=cdcType.getLinkDB();
          try {
            IRepositoryViewObject object=ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
            if (object != null) {
              if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                DatabaseConnectionItem dbConnItem=(DatabaseConnectionItem)object.getProperty().getItem();
                connectionItem=dbConnItem;
                connection=dbConnItem.getConnection();
              }
            }
          }
 catch (          PersistenceException e) {
            ExceptionHandler.process(e);
          }
          IElementParameter logModeParam=node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
          if (logModeParam != null) {
            String cdcTypeMode=((DatabaseConnection)originalConnection).getCdcTypeMode();
            Command logModeCmd=new PropertyChangeCommand(node,EParameterName.CDC_TYPE_MODE.getName(),CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
            cc.add(logModeCmd);
          }
          final String name="String_Node_Str";
          IElementParameter libParam=node.getElementParameter(name);
          if (libParam != null) {
            Object propValue;
            if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
              propValue=databaseConnection.getSID();
            }
 else {
              propValue=TalendTextUtils.addQuotes(databaseConnection.getSID());
            }
            Command libSettingCmd=new PropertyChangeCommand(node,name,propValue);
            cc.add(libSettingCmd);
          }
        }
      }
    }
  }
}