Program: 42563
Project: 42563
Buggy source:
/** 
 * Build a ML model asynchronously and persist the built model in a given storage.
 * @param modelId id of the model to be built.
 * @param storageType type of the storage bam, hdfs, file. Default storage is file.
 * @param StoragePath path of the provided storage where the model should be saved.
 * @throws MLModelHandlerException
 * @throws MLModelBuilderException
 */
public void buildModel(int tenantId,String userName,long modelId) throws MLModelHandlerException, MLModelBuilderException {
  if (!isValidModelId(tenantId,userName,modelId)) {
    String msg=String.format("String_Node_Str",modelId,tenantId,userName);
    throw new MLModelHandlerException(msg);
  }
  ClassLoader tccl=Thread.currentThread().getContextClassLoader();
  try {
    MLModelNew model=databaseService.getModel(tenantId,userName,modelId);
    Thread.currentThread().setContextClassLoader(JavaSparkContext.class.getClassLoader());
    long datasetVersionId=databaseService.getDatasetVersionIdOfModel(modelId);
    String dataType=databaseService.getDataTypeOfModel(modelId);
    String columnSeparator=ColumnSeparatorFactory.getColumnSeparator(dataType);
    String dataUrl=databaseService.getDatasetVersionUri(datasetVersionId);
    SparkConf sparkConf=MLCoreServiceValueHolder.getInstance().getSparkConf();
    Workflow facts=databaseService.getWorkflow(modelId,model.getAnalysisId());
    MLModelConfigurationContext context=new MLModelConfigurationContext();
    context.setModelId(modelId);
    context.setColumnSeparator(columnSeparator);
    context.setFacts(facts);
    context.setModel(model);
    JavaSparkContext sparkContext=null;
    sparkConf.setAppName(String.valueOf(modelId));
    sparkContext=new JavaSparkContext(sparkConf);
    JavaRDD<String> lines=sparkContext.textFile(dataUrl);
    String headerRow=lines.take(1).get(0);
    context.setSparkContext(sparkContext);
    context.setLines(lines);
    context.setHeaderRow(headerRow);
    threadExecutor.execute(new ModelBuilder(modelId,context));
    log.info(String.format("String_Node_Str",modelId));
  }
 catch (  DatabaseHandlerException e) {
    throw new MLModelBuilderException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    Thread.currentThread().setContextClassLoader(tccl);
  }
}

Fixed version (ground truth):
/** 
 * Build a ML model asynchronously and persist the built model in a given storage.
 * @param modelId id of the model to be built.
 * @param storageType type of the storage bam, hdfs, file. Default storage is file.
 * @param StoragePath path of the provided storage where the model should be saved.
 * @throws MLModelHandlerException
 * @throws MLModelBuilderException
 */
public void buildModel(int tenantId,String userName,long modelId) throws MLModelHandlerException, MLModelBuilderException {
  if (!isValidModelId(tenantId,userName,modelId)) {
    String msg=String.format("String_Node_Str",modelId,tenantId,userName);
    throw new MLModelHandlerException(msg);
  }
  ClassLoader tccl=Thread.currentThread().getContextClassLoader();
  try {
    MLModelNew model=databaseService.getModel(tenantId,userName,modelId);
    Thread.currentThread().setContextClassLoader(JavaSparkContext.class.getClassLoader());
    long datasetVersionId=databaseService.getDatasetVersionIdOfModel(modelId);
    String dataType=databaseService.getDataTypeOfModel(modelId);
    String columnSeparator=ColumnSeparatorFactory.getColumnSeparator(dataType);
    String dataUrl=databaseService.getDatasetVersionUri(datasetVersionId);
    SparkConf sparkConf=MLCoreServiceValueHolder.getInstance().getSparkConf();
    Workflow facts=databaseService.getWorkflow(model.getAnalysisId());
    MLModelConfigurationContext context=new MLModelConfigurationContext();
    context.setModelId(modelId);
    context.setColumnSeparator(columnSeparator);
    context.setFacts(facts);
    context.setModel(model);
    JavaSparkContext sparkContext=null;
    sparkConf.setAppName(String.valueOf(modelId));
    sparkContext=new JavaSparkContext(sparkConf);
    JavaRDD<String> lines=sparkContext.textFile(dataUrl);
    String headerRow=lines.take(1).get(0);
    context.setSparkContext(sparkContext);
    context.setLines(lines);
    context.setHeaderRow(headerRow);
    threadExecutor.execute(new ModelBuilder(modelId,context));
    log.info(String.format("String_Node_Str",modelId));
  }
 catch (  DatabaseHandlerException e) {
    throw new MLModelBuilderException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    Thread.currentThread().setContextClassLoader(tccl);
  }
}