Program: 125777
Project: 125777
Buggy source:
private Connection createHiveStandloneConnection(IMetadataConnection metadataConn) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  Connection hiveStandaloneConn=null;
  String connURL=metadataConn.getUrl();
  if (connURL != null) {
    boolean useKerberos=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USE_KRB));
    boolean useMaprTicket=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET));
    String hivePrincipal=(String)metadataConn.getParameter(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
    ClassLoader hiveClassLoader=HiveClassLoaderFactory.getInstance().getClassLoader(metadataConn);
    if (useKerberos) {
      System.setProperty(HiveConfKeysForTalend.HIVE_CONF_KEY_HIVE_METASTORE_KERBEROS_PRINCIPAL.getKey(),hivePrincipal);
      String principal=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
      String keytabPath=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
      boolean useKeytab=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB));
      if (useKeytab) {
        try {
          ReflectionUtils.invokeStaticMethod("String_Node_Str",hiveClassLoader,"String_Node_Str",new String[]{principal,keytabPath});
        }
 catch (        Exception e) {
          throw new SQLException(e);
        }
      }
      if (useMaprTicket) {
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        String mapRTicketCluster=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
        Object mapRTicketDuration=metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
        try {
          ReflectionUtils.invokeStaticMethod("String_Node_Str",hiveClassLoader,"String_Node_Str",new Object[]{mapRTicketCluster,mapRTicketDuration});
        }
 catch (        Exception e) {
          throw new SQLException(e);
        }
      }
    }
    if (useMaprTicket) {
      System.setProperty("String_Node_Str","String_Node_Str");
      System.setProperty("String_Node_Str","String_Node_Str");
      System.setProperty("String_Node_Str","String_Node_Str");
      String mapRTicketUsername=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
      String mapRTicketPassword=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
      String mapRTicketCluster=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
      Object mapRTicketDuration=metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
      try {
        String decryptedPassword=PasswordEncryptUtil.encryptPassword(mapRTicketPassword);
        ReflectionUtils.invokeStaticMethod("String_Node_Str",hiveClassLoader,"String_Node_Str",new Object[]{false},Boolean.class);
        ReflectionUtils.invokeStaticMethod("String_Node_Str",hiveClassLoader,"String_Node_Str",new Object[]{mapRTicketCluster,mapRTicketUsername,decryptedPassword,mapRTicketDuration});
      }
 catch (      Exception e) {
        throw new SQLException(e);
      }
    }
    if (connURL.startsWith(DatabaseConnConstants.HIVE_2_URL_FORMAT)) {
      hiveStandaloneConn=createHive2StandaloneConnection(metadataConn);
    }
 else     if (connURL.startsWith(DatabaseConnConstants.HIVE_1_URL_FORMAT)) {
      hiveStandaloneConn=createHive1StandaloneConnection(metadataConn);
    }
 else {
    }
  }
  setHiveJDBCProperties(metadataConn,hiveStandaloneConn);
  return hiveStandaloneConn;
}

Fixed version (ground truth):
private Connection createHiveStandloneConnection(IMetadataConnection metadataConn) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
  Connection hiveStandaloneConn=null;
  String connURL=metadataConn.getUrl();
  if (connURL != null) {
    boolean useKerberos=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USE_KRB));
    boolean useMaprTicket=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET));
    String hivePrincipal=(String)metadataConn.getParameter(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
    ClassLoader hiveClassLoader=HiveClassLoaderFactory.getInstance().getClassLoader(metadataConn);
    if (useKerberos) {
      System.setProperty(HiveConfKeysForTalend.HIVE_CONF_KEY_HIVE_METASTORE_KERBEROS_PRINCIPAL.getKey(),hivePrincipal);
      String principal=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
      String keytabPath=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
      boolean useKeytab=Boolean.valueOf((String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB));
      if (useKeytab) {
        try {
          ReflectionUtils.invokeStaticMethod("String_Node_Str",hiveClassLoader,"String_Node_Str",new String[]{principal,keytabPath});
        }
 catch (        Exception e) {
          throw new SQLException(e);
        }
      }
      if (useMaprTicket) {
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        System.setProperty("String_Node_Str","String_Node_Str");
        String mapRTicketCluster=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
        String mapRTicketDuration=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
        Long desiredTicketDurInSecs=86400L;
        if (mapRTicketDuration != null && StringUtils.isNotBlank(mapRTicketDuration)) {
          desiredTicketDurInSecs=Long.parseLong(mapRTicketDuration);
        }
        try {
          Object mapRClientConfig=ReflectionUtils.newInstance("String_Node_Str",hiveClassLoader,new Object[]{});
          ReflectionUtils.invokeMethod(mapRClientConfig,"String_Node_Str",new Object[]{mapRTicketCluster,desiredTicketDurInSecs});
        }
 catch (        Exception e) {
          throw new SQLException(e);
        }
      }
    }
    if (useMaprTicket) {
      System.setProperty("String_Node_Str","String_Node_Str");
      System.setProperty("String_Node_Str","String_Node_Str");
      System.setProperty("String_Node_Str","String_Node_Str");
      String mapRTicketUsername=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME);
      String mapRTicketPassword=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD);
      String mapRTicketCluster=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER);
      String mapRTicketDuration=(String)metadataConn.getParameter(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION);
      Long desiredTicketDurInSecs=86400L;
      if (mapRTicketDuration != null && StringUtils.isNotBlank(mapRTicketDuration)) {
        desiredTicketDurInSecs=Long.parseLong(mapRTicketDuration);
      }
      try {
        String decryptedPassword=PasswordEncryptUtil.encryptPassword(mapRTicketPassword);
        Object mapRClientConfig=ReflectionUtils.newInstance("String_Node_Str",hiveClassLoader,new Object[]{});
        ReflectionUtils.invokeMethod(mapRClientConfig,"String_Node_Str",new Object[]{false},boolean.class);
        ReflectionUtils.invokeMethod(mapRClientConfig,"String_Node_Str",new Object[]{mapRTicketCluster,mapRTicketUsername,decryptedPassword,desiredTicketDurInSecs});
      }
 catch (      Exception e) {
        throw new SQLException(e);
      }
    }
    if (connURL.startsWith(DatabaseConnConstants.HIVE_2_URL_FORMAT)) {
      hiveStandaloneConn=createHive2StandaloneConnection(metadataConn);
    }
 else     if (connURL.startsWith(DatabaseConnConstants.HIVE_1_URL_FORMAT)) {
      hiveStandaloneConn=createHive1StandaloneConnection(metadataConn);
    }
 else {
    }
  }
  setHiveJDBCProperties(metadataConn,hiveStandaloneConn);
  return hiveStandaloneConn;
}