Program: 125780
Project: 125780
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);
    updateHiveServerAndMakeSelection(hiveDistribution,hdVersion);
    updateHiveModeAndMakeSelection(HiveModeInfo.get(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);
  String additionalJDBCSettings=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
  boolean useSSL=Boolean.parseBoolean(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_SSL));
  String trustStorePathStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
  String trustStorePasswordStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
  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);
  additionalJDBCSettingsText.setText(additionalJDBCSettings == null ? "String_Node_Str" : additionalJDBCSettings);
  useSSLEncryption.setSelection(useSSL);
  trustStorePath.setText(trustStorePathStr == null ? "String_Node_Str" : trustStorePathStr);
  if (trustStorePasswordStr == null) {
    trustStorePasswordStr="String_Node_Str";
  }
 else {
    trustStorePasswordStr=connection.getValue(trustStorePasswordStr,false);
  }
  trustStorePassword.setText(trustStorePasswordStr);
  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);
  }
  boolean doSupportMapRTicket=false;
  IHadoopDistributionService hadoopService=getHadoopDistributionService();
  if (hadoopService != null && hiveDistribution != null) {
    doSupportMapRTicket=hadoopService.doSupportMapRTicket(hiveDistribution.getHDVersion(hiveVersion,false));
  }
  String useMaprTForHiveString=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET);
  String maprTUsernameForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
  String maprTPasswordForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
  String maprTClusterForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
  String maprTDurationForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
  boolean checkMaprTForHive=Boolean.valueOf(useMaprTForHiveString);
  useMaprTForHive.setEnabled(doSupportMapRTicket);
  useMaprTForHive.setSelection(checkMaprTForHive);
  if (checkMaprTForHive) {
    maprTUsernameForHiveTxt.setText(StringUtils.trimToEmpty(maprTUsernameForHive));
    maprTPasswordForHiveTxt.setText(StringUtils.trimToEmpty(maprTPasswordForHive));
    maprTClusterForHiveTxt.setText(StringUtils.trimToEmpty(maprTClusterForHive));
    maprTDurationForHiveTxt.setText(StringUtils.trimToEmpty(maprTDurationForHive));
  }
  hideControl(authenticationMaprTComForHive,!checkMaprTForHive);
  hideControl(authenticationUserPassComForHive,Boolean.valueOf(useKrb));
  updateYarnStatus();
  updateYarnInfo(hiveDistribution,hdVersion);
  showIfSupportEncryption();
  updateSSLEncryptionDetailsDisplayStatus();
}

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.get(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);
  String additionalJDBCSettings=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
  boolean useSSL=Boolean.parseBoolean(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_SSL));
  String trustStorePathStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
  String trustStorePasswordStr=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
  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);
  additionalJDBCSettingsText.setText(additionalJDBCSettings == null ? "String_Node_Str" : additionalJDBCSettings);
  useSSLEncryption.setSelection(useSSL);
  trustStorePath.setText(trustStorePathStr == null ? "String_Node_Str" : trustStorePathStr);
  if (trustStorePasswordStr == null) {
    trustStorePasswordStr="String_Node_Str";
  }
 else {
    trustStorePasswordStr=connection.getValue(trustStorePasswordStr,false);
  }
  trustStorePassword.setText(trustStorePasswordStr);
  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);
  }
  boolean doSupportMapRTicket=false;
  IHadoopDistributionService hadoopService=getHadoopDistributionService();
  if (hadoopService != null && hiveDistribution != null) {
    doSupportMapRTicket=hadoopService.doSupportMapRTicket(hiveDistribution.getHDVersion(hiveVersion,false));
  }
  String useMaprTForHiveString=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET);
  String maprTUsernameForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
  String maprTPasswordForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
  String maprTClusterForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
  String maprTDurationForHive=connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
  boolean checkMaprTForHive=Boolean.valueOf(useMaprTForHiveString);
  useMaprTForHive.setEnabled(doSupportMapRTicket);
  useMaprTForHive.setSelection(checkMaprTForHive);
  if (checkMaprTForHive) {
    maprTUsernameForHiveTxt.setText(StringUtils.trimToEmpty(maprTUsernameForHive));
    maprTPasswordForHiveTxt.setText(StringUtils.trimToEmpty(maprTPasswordForHive));
    maprTClusterForHiveTxt.setText(StringUtils.trimToEmpty(maprTClusterForHive));
    maprTDurationForHiveTxt.setText(maprTDurationForHive == null ? "String_Node_Str" : maprTDurationForHive.trim());
  }
  hideControl(authenticationMaprTComForHive,!checkMaprTForHive);
  hideControl(authenticationUserPassComForHive,Boolean.valueOf(useKrb));
  updateYarnStatus();
  updateYarnInfo(hiveDistribution,hdVersion);
  showIfSupportEncryption();
  updateSSLEncryptionDetailsDisplayStatus();
}