Program: 125528
Project: 125528
Buggy source:
static List<IContextParameter> getDBVariables(String prefixName,DatabaseConnection conn,Set<IConnParamName> paramSet){
  if (conn == null || prefixName == null || paramSet == null || paramSet.isEmpty()) {
    return Collections.emptyList();
  }
  List<IContextParameter> varList=new ArrayList<IContextParameter>();
  String paramPrefix=prefixName + ConnectionContextHelper.LINE;
  String paramName=null;
  for (  IConnParamName param : paramSet) {
    if (param instanceof EDBParamName) {
      EDBParamName dbParam=(EDBParamName)param;
      paramName=paramPrefix + dbParam;
switch (dbParam) {
case AdditionalParams:
        ConnectionContextHelper.createParameters(varList,paramName,conn.getAdditionalParams());
      break;
case Datasource:
    ConnectionContextHelper.createParameters(varList,paramName,conn.getDatasourceName());
  break;
case DBRootPath:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDBRootPath(),JavaTypesManager.DIRECTORY);
break;
case File:
ConnectionContextHelper.createParameters(varList,paramName,conn.getFileFieldName(),JavaTypesManager.FILE);
break;
case Password:
ConnectionContextHelper.createParameters(varList,paramName,conn.getRawPassword(),JavaTypesManager.PASSWORD);
break;
case JdbcUrl:
String url=conn.getURL();
String h2Prefix="String_Node_Str";
if (url.startsWith(h2Prefix)) {
String path=url.substring(h2Prefix.length(),url.length());
path=PathUtils.getPortablePath(path);
url=h2Prefix + path;
}
ConnectionContextHelper.createParameters(varList,paramName,url);
break;
case DriverJar:
String path=conn.getDriverJarPath();
PathUtils.getOSPath(path);
if (path.contains("String_Node_Str")) {
Path p=new Path(path);
String newPath=p.getDevice();
for (int i=0; i < p.segmentCount(); i++) {
newPath=newPath + "String_Node_Str" + p.segment(i);
}
path=newPath;
}
ConnectionContextHelper.createParameters(varList,paramName,path);
break;
case MappingFile:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDbmsId());
break;
case ClassName:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDriverClass());
break;
case Port:
ConnectionContextHelper.createParameters(varList,paramName,conn.getPort(),JavaTypesManager.STRING);
break;
case Schema:
if (conn.getProductId().equals(EDatabaseTypeName.ORACLEFORSID.getProduct())) {
String schema=conn.getUiSchema();
if (schema != null) {
conn.setUiSchema(schema.toUpperCase());
}
}
ConnectionContextHelper.createParameters(varList,paramName,conn.getUiSchema());
break;
case Server:
ConnectionContextHelper.createParameters(varList,paramName,conn.getServerName());
break;
case Sid:
case Database:
case ServiceName:
ConnectionContextHelper.createParameters(varList,paramName,conn.getSID());
break;
case Login:
ConnectionContextHelper.createParameters(varList,paramName,conn.getUsername());
break;
case JobTrackerOrResourceManager:
String value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case NameNode:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HivePrincipal:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveMetastore:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveDriverJar:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveDriveClass:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveUserName:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HivePassword:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case HiveKeyTabPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveKeyTab:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveAdditionalJDBCParameters:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveSSLTrustStorePath:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveSSLTrustStorePassword:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
value=conn.getValue(value,false);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case MasterPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case RegionPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HbaseKeyTabPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HbaseKeyTab:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case ImpalaPrincipal:
value=conn.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Username:
String key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Maprticket_Password:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case Maprticket_Cluster:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Maprticket_Duration:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
default :
}
}
}
createAdditionalContextParameters(prefixName,varList,getHiveOrHbaseHadoopProperties(conn));
createAdditionalContextParameters(prefixName,varList,getHiveJdbcProperties(conn));
return varList;
}

Fixed version (ground truth):
static List<IContextParameter> getDBVariables(String prefixName,DatabaseConnection conn,Set<IConnParamName> paramSet){
  if (conn == null || prefixName == null || paramSet == null || paramSet.isEmpty()) {
    return Collections.emptyList();
  }
  List<IContextParameter> varList=new ArrayList<IContextParameter>();
  String paramPrefix=prefixName + ConnectionContextHelper.LINE;
  String paramName=null;
  for (  IConnParamName param : paramSet) {
    if (param instanceof EDBParamName) {
      EDBParamName dbParam=(EDBParamName)param;
      paramName=paramPrefix + dbParam;
switch (dbParam) {
case AdditionalParams:
        ConnectionContextHelper.createParameters(varList,paramName,conn.getAdditionalParams());
      break;
case Datasource:
    ConnectionContextHelper.createParameters(varList,paramName,conn.getDatasourceName());
  break;
case DBRootPath:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDBRootPath(),JavaTypesManager.DIRECTORY);
break;
case File:
ConnectionContextHelper.createParameters(varList,paramName,conn.getFileFieldName(),JavaTypesManager.FILE);
break;
case Password:
ConnectionContextHelper.createParameters(varList,paramName,conn.getRawPassword(),JavaTypesManager.PASSWORD);
break;
case JdbcUrl:
String url=conn.getURL();
String h2Prefix="String_Node_Str";
if (url.startsWith(h2Prefix)) {
String path=url.substring(h2Prefix.length(),url.length());
path=PathUtils.getPortablePath(path);
url=h2Prefix + path;
}
ConnectionContextHelper.createParameters(varList,paramName,url);
break;
case DriverJar:
String path=conn.getDriverJarPath();
PathUtils.getOSPath(path);
if (path.contains("String_Node_Str")) {
Path p=new Path(path);
String newPath=p.getDevice();
for (int i=0; i < p.segmentCount(); i++) {
newPath=newPath + "String_Node_Str" + p.segment(i);
}
path=newPath;
}
ConnectionContextHelper.createParameters(varList,paramName,path);
break;
case MappingFile:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDbmsId());
break;
case ClassName:
ConnectionContextHelper.createParameters(varList,paramName,conn.getDriverClass());
break;
case Port:
ConnectionContextHelper.createParameters(varList,paramName,conn.getPort(),JavaTypesManager.STRING);
break;
case Schema:
if (conn.getProductId().equals(EDatabaseTypeName.ORACLEFORSID.getProduct())) {
String schema=conn.getUiSchema();
if (schema != null) {
conn.setUiSchema(schema.toUpperCase());
}
}
ConnectionContextHelper.createParameters(varList,paramName,conn.getUiSchema());
break;
case Server:
ConnectionContextHelper.createParameters(varList,paramName,conn.getServerName());
break;
case Sid:
case Database:
case ServiceName:
ConnectionContextHelper.createParameters(varList,paramName,conn.getSID());
break;
case Login:
ConnectionContextHelper.createParameters(varList,paramName,conn.getUsername());
break;
case JobTrackerOrResourceManager:
String value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case NameNode:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HivePrincipal:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_HIVEPRINCIPLA);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveMetastore:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_METASTOREURL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveDriverJar:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERJAR_PATH);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveDriveClass:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_DRIVERCLASS);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveUserName:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_USERNAME);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HivePassword:
value=conn.getParameters().get(ConnParameterKeys.HIVE_AUTHENTICATION_PASSWORD);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case HiveKeyTabPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HiveKeyTab:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveAdditionalJDBCParameters:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveSSLTrustStorePath:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case hiveSSLTrustStorePassword:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD);
value=conn.getValue(value,false);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case MasterPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case RegionPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Znode_Parent:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HBASE_ZNODE_PARENT);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HbaseKeyTabPrincipal:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case HbaseKeyTab:
value=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KEYTAB);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case ImpalaPrincipal:
value=conn.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Username:
String key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Maprticket_Password:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value,JavaTypesManager.PASSWORD);
break;
case Maprticket_Cluster:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
case Maprticket_Duration:
key=ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION;
if (EDatabaseTypeName.HBASE.getDisplayName().equals(conn.getDatabaseType())) {
key=ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION;
}
value=conn.getParameters().get(key);
ConnectionContextHelper.createParameters(varList,paramName,value);
break;
default :
}
}
}
createAdditionalContextParameters(prefixName,varList,getHiveOrHbaseHadoopProperties(conn));
createAdditionalContextParameters(prefixName,varList,getHiveJdbcProperties(conn));
return varList;
}