Program: 125906
Project: 125906
Buggy source:
/** 
 * Initializes hive info for Hive UI. If the distribution value from connection is <code>null</code>, the default selected indexs of hive combos like distribution, hive vesion and hive mode are 0. Added by Marvin Wang on Aug 10, 2012.
 */
protected void initHiveInfo(){
  DatabaseConnection connection=getConnection();
  String distributionObj=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION);
  String hiveVersion=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION);
  String hiveMode=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
  IHDistribution hiveDistribution=HiveMetadataHelper.getDistribution(distributionObj,false);
  IHDistributionVersion hdVersion=null;
  if (hiveDistribution != null) {
    hdVersion=hiveDistribution.getHDVersion(hiveVersion,false);
    updateHiveDistributionAndMakeSelection(hiveDistribution);
    updateHiveVersionAndMakeSelection(hiveDistribution,hdVersion);
    updateHiveModeAndMakeSelection(HiveModeInfo.valueOf(hiveMode));
    updateHiveServerAndMakeSelection(hiveDistribution,hdVersion);
  }
 else {
    updateHiveDistributionAndMakeSelection(null);
    updateHiveVersionAndMakeSelection(null,null);
    updateHiveModeAndMakeSelection(null);
    updateHiveServerAndMakeSelection(null,null);
  }
  doHiveModeModify();
  if (isHiveEmbeddedMode()) {
    String nameNodeURLstr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
    String jobTrackerURLStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
    String hadoopUserName=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USERNAME);
    String metastoreConnURLStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_URL);
    String metastoreConnUserNameStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_USERNAME);
    String metastoreConnPasswordStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_PASSWORD);
    String metastoreConnDriverJarStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_DRIVER_JAR);
    String metastoreConnDriverNameStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_DRIVER_NAME);
    nameNodeURLTxt.setText(nameNodeURLstr == null ? "String_Node_Str" : nameNodeURLstr);
    jobTrackerURLTxt.setText(jobTrackerURLStr == null ? "String_Node_Str" : jobTrackerURLStr);
    usernameText.setText(hadoopUserName == null ? "String_Node_Str" : hadoopUserName);
    metastoreConnURLTxt.setText(metastoreConnURLStr == null ? "String_Node_Str" : metastoreConnURLStr);
    metastoreConnUserName.setText(metastoreConnUserNameStr == null ? "String_Node_Str" : metastoreConnUserNameStr);
    metastoreConnPassword.setText(metastoreConnPasswordStr == null ? "String_Node_Str" : metastoreConnPasswordStr);
    metastoreConnDriverJar.setText(metastoreConnDriverJarStr == null ? "String_Node_Str" : metastoreConnDriverJarStr);
    metastoreConnDriverName.setText(metastoreConnDriverNameStr == null ? "String_Node_Str" : metastoreConnDriverNameStr);
  }
  String useKrb=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB);
  String hivePrincipla=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
  String metastoreUrl=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
  String driverJarPath=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
  String driverClass=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
  String username=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
  String password=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
  String useKeytabString=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB);
  String Principla=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
  String keytab=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
  if (Boolean.valueOf(useKrb)) {
    useKerberos.setSelection(true);
    GridData hadoopData=(GridData)authenticationCom.getLayoutData();
    hadoopData.exclude=false;
    authenticationCom.setVisible(true);
    authenticationCom.setLayoutData(hadoopData);
    authenticationCom.getParent().layout();
    authenticationGrp.layout();
    authenticationGrp.getParent().layout();
  }
  hivePrincipalTxt.setText(hivePrincipla == null ? "String_Node_Str" : hivePrincipla);
  metastoreUrlTxt.setText(metastoreUrl == null ? "String_Node_Str" : metastoreUrl);
  driverJarTxt.setText(driverJarPath == null ? "String_Node_Str" : driverJarPath);
  driverClassTxt.setText(driverClass == null ? "String_Node_Str" : driverClass);
  usernameTxt.setText(username == null ? "String_Node_Str" : username);
  passwordTxt.setText(password == null ? "String_Node_Str" : password);
  if (Boolean.valueOf(useKeytabString)) {
    useKeyTab.setSelection(true);
    GridData hadoopData=(GridData)keyTabComponent.getLayoutData();
    hadoopData.exclude=false;
    keyTabComponent.setVisible(true);
    keyTabComponent.setLayoutData(hadoopData);
    keyTabComponent.getParent().layout();
    authenticationGrp.layout();
    authenticationGrp.getParent().layout();
  }
  principalTxt.setText(Principla == null ? "String_Node_Str" : Principla);
  keytabTxt.setText(keytab == null ? "String_Node_Str" : keytab);
  String executionEngine=connection.getParameters().get(ConnParameterKeys.HIVE_EXECUTION_ENGINE);
  EHiveExecutionTypes executionType=EHiveExecutionTypes.getTypeFromValue(executionEngine);
  if (executionType != null) {
    hiveExecutionEngineCombo.setText(executionType.getLabel());
  }
 else {
    getConnection().getParameters().put(ConnParameterKeys.HIVE_EXECUTION_ENGINE,null);
  }
  updateYarnStatus();
  updateYarnInfo(hiveDistribution,hdVersion);
}

Fixed version (ground truth):
/** 
 * Initializes hive info for Hive UI. If the distribution value from connection is <code>null</code>, the default selected indexs of hive combos like distribution, hive vesion and hive mode are 0. Added by Marvin Wang on Aug 10, 2012.
 */
protected void initHiveInfo(){
  DatabaseConnection connection=getConnection();
  String distributionObj=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION);
  String hiveVersion=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION);
  String hiveMode=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_MODE);
  IHDistribution hiveDistribution=HiveMetadataHelper.getDistribution(distributionObj,false);
  IHDistributionVersion hdVersion=null;
  if (hiveDistribution != null) {
    hdVersion=hiveDistribution.getHDVersion(hiveVersion,false);
    updateHiveDistributionAndMakeSelection(hiveDistribution);
    updateHiveVersionAndMakeSelection(hiveDistribution,hdVersion);
    updateHiveServerAndMakeSelection(hiveDistribution,hdVersion);
    updateHiveModeAndMakeSelection(HiveModeInfo.valueOf(hiveMode));
  }
 else {
    updateHiveDistributionAndMakeSelection(null);
    updateHiveVersionAndMakeSelection(null,null);
    updateHiveServerAndMakeSelection(null,null);
    updateHiveModeAndMakeSelection(null);
  }
  doHiveModeModify();
  if (isHiveEmbeddedMode()) {
    String nameNodeURLstr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
    String jobTrackerURLStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
    String hadoopUserName=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USERNAME);
    String metastoreConnURLStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_URL);
    String metastoreConnUserNameStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_USERNAME);
    String metastoreConnPasswordStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_PASSWORD);
    String metastoreConnDriverJarStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_DRIVER_JAR);
    String metastoreConnDriverNameStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_METASTORE_CONN_DRIVER_NAME);
    nameNodeURLTxt.setText(nameNodeURLstr == null ? "String_Node_Str" : nameNodeURLstr);
    jobTrackerURLTxt.setText(jobTrackerURLStr == null ? "String_Node_Str" : jobTrackerURLStr);
    usernameText.setText(hadoopUserName == null ? "String_Node_Str" : hadoopUserName);
    metastoreConnURLTxt.setText(metastoreConnURLStr == null ? "String_Node_Str" : metastoreConnURLStr);
    metastoreConnUserName.setText(metastoreConnUserNameStr == null ? "String_Node_Str" : metastoreConnUserNameStr);
    metastoreConnPassword.setText(metastoreConnPasswordStr == null ? "String_Node_Str" : metastoreConnPasswordStr);
    metastoreConnDriverJar.setText(metastoreConnDriverJarStr == null ? "String_Node_Str" : metastoreConnDriverJarStr);
    metastoreConnDriverName.setText(metastoreConnDriverNameStr == null ? "String_Node_Str" : metastoreConnDriverNameStr);
  }
  String useKrb=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB);
  String hivePrincipla=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
  String metastoreUrl=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
  String driverJarPath=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
  String driverClass=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
  String username=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
  String password=connection.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
  String useKeytabString=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB);
  String Principla=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
  String keytab=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
  if (Boolean.valueOf(useKrb)) {
    useKerberos.setSelection(true);
    GridData hadoopData=(GridData)authenticationCom.getLayoutData();
    hadoopData.exclude=false;
    authenticationCom.setVisible(true);
    authenticationCom.setLayoutData(hadoopData);
    authenticationCom.getParent().layout();
    authenticationGrp.layout();
    authenticationGrp.getParent().layout();
  }
  hivePrincipalTxt.setText(hivePrincipla == null ? "String_Node_Str" : hivePrincipla);
  metastoreUrlTxt.setText(metastoreUrl == null ? "String_Node_Str" : metastoreUrl);
  driverJarTxt.setText(driverJarPath == null ? "String_Node_Str" : driverJarPath);
  driverClassTxt.setText(driverClass == null ? "String_Node_Str" : driverClass);
  usernameTxt.setText(username == null ? "String_Node_Str" : username);
  passwordTxt.setText(password == null ? "String_Node_Str" : password);
  if (Boolean.valueOf(useKeytabString)) {
    useKeyTab.setSelection(true);
    GridData hadoopData=(GridData)keyTabComponent.getLayoutData();
    hadoopData.exclude=false;
    keyTabComponent.setVisible(true);
    keyTabComponent.setLayoutData(hadoopData);
    keyTabComponent.getParent().layout();
    authenticationGrp.layout();
    authenticationGrp.getParent().layout();
  }
  principalTxt.setText(Principla == null ? "String_Node_Str" : Principla);
  keytabTxt.setText(keytab == null ? "String_Node_Str" : keytab);
  String executionEngine=connection.getParameters().get(ConnParameterKeys.HIVE_EXECUTION_ENGINE);
  EHiveExecutionTypes executionType=EHiveExecutionTypes.getTypeFromValue(executionEngine);
  if (executionType != null) {
    hiveExecutionEngineCombo.setText(executionType.getLabel());
  }
 else {
    getConnection().getParameters().put(ConnParameterKeys.HIVE_EXECUTION_ENGINE,null);
  }
  updateYarnStatus();
  updateYarnInfo(hiveDistribution,hdVersion);
}