Program: 127334
Project: 127334
Buggy source:
@Override protected void run() throws LoginException, PersistenceException {
  monitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
  if (!monitor.isCanceled()) {
    final ManagerConnection managerConnection=new ManagerConnection();
    DatabaseConnection connection=(DatabaseConnection)item.getConnection();
    String oldContextName=connection.getContextName();
    IMetadataConnection metadataConnection=ConvertionHelper.convert(connection,false,null);
    String newContextName=connection.getContextName();
    if (oldContextName != null && newContextName != null && !oldContextName.equals(newContextName)) {
      if (node != null && node.getObject() != null && node.getObject().getProperty() != null) {
        Item itemTemp=node.getObject().getProperty().getItem();
        if (itemTemp != null && itemTemp instanceof ConnectionItem) {
          ConnectionItem connItem=(ConnectionItem)itemTemp;
          SwitchContextGroupNameImpl.getInstance().updateContextGroup(connItem,newContextName);
        }
      }
    }
    if (!metadataConnection.getDbType().equals(EDatabaseConnTemplate.GODBC.getDBDisplayName()) && !metadataConnection.getDbType().equals(EDatabaseConnTemplate.ACCESS.getDBDisplayName()) && !metadataConnection.getDbType().equals(EDatabaseConnTemplate.GENERAL_JDBC.getDBDisplayName())) {
      String hiveMode=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
        metadataConnection.setUrl(connection.getURL());
        if (HiveConnVersionInfo.MODE_EMBEDDED.getKey().equals(hiveMode)) {
          JavaSqlFactory.doHivePreSetup((DatabaseConnection)metadataConnection.getCurrentConnection());
        }
      }
 else {
        String genUrl=DatabaseConnStrUtil.getURLString(metadataConnection.getDbType(),metadataConnection.getDbVersionString(),metadataConnection.getServerName(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getPort(),metadataConnection.getDatabase(),metadataConnection.getFileFieldName(),metadataConnection.getDataSourceName(),metadataConnection.getDbRootPath(),metadataConnection.getAdditionalParams());
        metadataConnection.setUrl(genUrl);
      }
    }
    if (connection != null) {
      EList<orgomg.cwm.objectmodel.core.Package> dp=connection.getDataPackage();
      Collection<Package> newDataPackage=EcoreUtil.copyAll(dp);
      ConnectionHelper.addPackages(newDataPackage,(DatabaseConnection)metadataConnection.getCurrentConnection());
    }
    if (creation) {
      String hiveMode=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
        try {
          HiveConnectionManager.getInstance().checkConnection(metadataConnection);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else {
        managerConnection.check(metadataConnection);
      }
      ExtractMetaDataUtils.setUseAllSynonyms(false);
      DatabaseTableWizard databaseTableWizard=new DatabaseTableWizard(PlatformUI.getWorkbench(),creation,node.getObject(),metadataTable,getExistingNames(),forceReadOnly,managerConnection,metadataConnection);
      WizardDialog wizardDialog=new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),databaseTableWizard);
      wizardDialog.setBlockOnOpen(true);
      handleWizard(node,wizardDialog);
    }
 else {
      final boolean skipStep=true;
      DatabaseTableWizard databaseTableWizard=new DatabaseTableWizard(PlatformUI.getWorkbench(),creation,node.getObject(),metadataTable,getExistingNames(),forceReadOnly,managerConnection,metadataConnection);
      databaseTableWizard.setSkipStep(skipStep);
      WizardDialog wizardDialog=new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),databaseTableWizard);
      handleWizard(node,wizardDialog);
    }
  }
}

Fixed version (ground truth):
@Override protected void run() throws LoginException, PersistenceException {
  monitor.beginTask(Messages.getString("String_Node_Str"),IProgressMonitor.UNKNOWN);
  if (!monitor.isCanceled()) {
    final ManagerConnection managerConnection=new ManagerConnection();
    DatabaseConnection connection=(DatabaseConnection)item.getConnection();
    String oldContextName=connection.getContextName();
    IMetadataConnection metadataConnection=ConvertionHelper.convert(connection,false,null);
    String newContextName=connection.getContextName();
    if (oldContextName != null && newContextName != null && !oldContextName.equals(newContextName)) {
      if (node != null && node.getObject() != null && node.getObject().getProperty() != null) {
        Item itemTemp=node.getObject().getProperty().getItem();
        if (itemTemp != null && itemTemp instanceof ConnectionItem) {
          ConnectionItem connItem=(ConnectionItem)itemTemp;
          SwitchContextGroupNameImpl.getInstance().updateContextGroup(connItem,newContextName);
        }
      }
    }
    if (!metadataConnection.getDbType().equals(EDatabaseConnTemplate.GODBC.getDBDisplayName()) && !metadataConnection.getDbType().equals(EDatabaseConnTemplate.ACCESS.getDBDisplayName()) && !metadataConnection.getDbType().equals(EDatabaseConnTemplate.GENERAL_JDBC.getDBDisplayName())) {
      String hiveMode=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
        metadataConnection.setUrl(connection.getURL());
        if (HiveConnVersionInfo.MODE_EMBEDDED.getKey().equals(hiveMode)) {
          JavaSqlFactory.doHivePreSetup((DatabaseConnection)metadataConnection.getCurrentConnection());
        }
      }
 else {
        String genUrl=DatabaseConnStrUtil.getURLString(metadataConnection.getDbType(),metadataConnection.getDbVersionString(),metadataConnection.getServerName(),metadataConnection.getUsername(),metadataConnection.getPassword(),metadataConnection.getPort(),metadataConnection.getDatabase(),metadataConnection.getFileFieldName(),metadataConnection.getDataSourceName(),metadataConnection.getDbRootPath(),metadataConnection.getAdditionalParams());
        metadataConnection.setUrl(genUrl);
      }
    }
    if (connection != null) {
      EList<orgomg.cwm.objectmodel.core.Package> dp=connection.getDataPackage();
      Collection<Package> newDataPackage=EcoreUtil.copyAll(dp);
      ConnectionHelper.addPackages(newDataPackage,(DatabaseConnection)metadataConnection.getCurrentConnection());
    }
    if (creation) {
      String hiveMode=(String)metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
      if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
        try {
          HiveConnectionManager.getInstance().checkConnection(metadataConnection);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else {
        managerConnection.check(metadataConnection);
      }
      ExtractMetaDataUtils.getInstance().setUseAllSynonyms(false);
      DatabaseTableWizard databaseTableWizard=new DatabaseTableWizard(PlatformUI.getWorkbench(),creation,node.getObject(),metadataTable,getExistingNames(),forceReadOnly,managerConnection,metadataConnection);
      WizardDialog wizardDialog=new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),databaseTableWizard);
      wizardDialog.setBlockOnOpen(true);
      handleWizard(node,wizardDialog);
    }
 else {
      final boolean skipStep=true;
      DatabaseTableWizard databaseTableWizard=new DatabaseTableWizard(PlatformUI.getWorkbench(),creation,node.getObject(),metadataTable,getExistingNames(),forceReadOnly,managerConnection,metadataConnection);
      databaseTableWizard.setSkipStep(skipStep);
      WizardDialog wizardDialog=new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),databaseTableWizard);
      handleWizard(node,wizardDialog);
    }
  }
}