Program: 127923
Project: 127923
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>();
  prefixName=prefixName + ConnectionContextHelper.LINE;
  String paramName=null;
  for (  IConnParamName param : paramSet) {
    if (param instanceof EDBParamName) {
      EDBParamName dbParam=(EDBParamName)param;
      paramName=prefixName + 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.getPassword(),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;
default :
}
}
}
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>();
  prefixName=prefixName + ConnectionContextHelper.LINE;
  String paramName=null;
  for (  IConnParamName param : paramSet) {
    if (param instanceof EDBParamName) {
      EDBParamName dbParam=(EDBParamName)param;
      paramName=prefixName + 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.getPassword(),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 JobTracker:
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;
default :
}
}
}
return varList;
}