nus-yam/ex-repair huggingface dataset:
Program: 7081
Project: 7081
Buggy source:
@Inject public ProgramLifecycleHttpHandler(Authenticator authenticator,Store store,CConfiguration cConf,ProgramRuntimeService runtimeService,ProgramLifecycleService lifecycleService,QueueAdmin queueAdmin,Scheduler scheduler,PreferencesStore preferencesStore,NamespacedLocationFactory namespacedLocationFactory,MRJobClient mrJobClient,MapReduceMetricsInfo mapReduceMetricsInfo,PropertiesResolver propertiesResolver,AdapterService adapterService,MetricStore metricStore){
  super(authenticator);
  this.namespacedLocationFactory=namespacedLocationFactory;
  this.store=store;
  this.runtimeService=runtimeService;
  this.lifecycleService=lifecycleService;
  this.metricStore=metricStore;
  this.appFabricDir=cConf.get(Constants.AppFabric.OUTPUT_DIR);
  this.queueAdmin=queueAdmin;
  this.scheduler=scheduler;
  this.preferencesStore=preferencesStore;
  this.mrJobClient=mrJobClient;
  this.mapReduceMetricsInfo=mapReduceMetricsInfo;
  this.propertiesResolver=propertiesResolver;
  this.adapterService=adapterService;
}

Fixed version (ground truth):
@Inject public ProgramLifecycleHttpHandler(Authenticator authenticator,Store store,CConfiguration cConf,ProgramRuntimeService runtimeService,ProgramLifecycleService lifecycleService,QueueAdmin queueAdmin,Scheduler scheduler,PreferencesStore preferencesStore,NamespacedLocationFactory namespacedLocationFactory,MRJobInfoFetcher mrJobInfoFetcher,PropertiesResolver propertiesResolver,AdapterService adapterService,MetricStore metricStore){
  super(authenticator);
  this.namespacedLocationFactory=namespacedLocationFactory;
  this.store=store;
  this.runtimeService=runtimeService;
  this.lifecycleService=lifecycleService;
  this.metricStore=metricStore;
  this.appFabricDir=cConf.get(Constants.AppFabric.OUTPUT_DIR);
  this.queueAdmin=queueAdmin;
  this.scheduler=scheduler;
  this.preferencesStore=preferencesStore;
  this.mrJobInfoFetcher=mrJobInfoFetcher;
  this.propertiesResolver=propertiesResolver;
  this.adapterService=adapterService;
}
Program: 7082
Project: 7082
Buggy source:
@Inject public WorkflowHttpHandler(Authenticator authenticator,Store store,WorkflowClient workflowClient,CConfiguration configuration,ProgramRuntimeService runtimeService,QueueAdmin queueAdmin,Scheduler scheduler,PreferencesStore preferencesStore,NamespacedLocationFactory namespacedLocationFactory,MRJobClient mrJobClient,MapReduceMetricsInfo mapReduceMetricsInfo,ProgramLifecycleService lifecycleService,PropertiesResolver resolver,AdapterService adapterService,MetricStore metricStore){
  super(authenticator,store,configuration,runtimeService,lifecycleService,queueAdmin,scheduler,preferencesStore,namespacedLocationFactory,mrJobClient,mapReduceMetricsInfo,resolver,adapterService,metricStore);
  this.workflowClient=workflowClient;
}

Fixed version (ground truth):
@Inject public WorkflowHttpHandler(Authenticator authenticator,Store store,WorkflowClient workflowClient,CConfiguration configuration,ProgramRuntimeService runtimeService,QueueAdmin queueAdmin,Scheduler scheduler,PreferencesStore preferencesStore,NamespacedLocationFactory namespacedLocationFactory,MRJobInfoFetcher mrJobInfoFetcher,ProgramLifecycleService lifecycleService,PropertiesResolver resolver,AdapterService adapterService,MetricStore metricStore){
  super(authenticator,store,configuration,runtimeService,lifecycleService,queueAdmin,scheduler,preferencesStore,namespacedLocationFactory,mrJobInfoFetcher,resolver,adapterService,metricStore);
  this.workflowClient=workflowClient;
}
Program: 7083
Project: 7083
Buggy source:
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  NamespaceMeta metadata;
  try {
    metadata=parseBody(request,NamespaceMeta.class);
  }
 catch (  JsonSyntaxException e) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
    return;
  }
  if (!isValid(namespaceId)) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
  if (isReserved(namespaceId)) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,String.format("String_Node_Str",namespaceId,namespaceId));
    return;
  }
  NamespaceMeta.Builder builder=new NamespaceMeta.Builder().setName(namespaceId);
  if (metadata != null && metadata.getDescription() != null) {
    builder.setDescription(metadata.getDescription());
  }
  try {
    namespaceAdmin.createNamespace(builder.build());
    responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
  }
 catch (  AlreadyExistsException e) {
    responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
  }
}

Fixed version (ground truth):
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  Id.Namespace namespace;
  try {
    namespace=Id.Namespace.from(namespaceId);
  }
 catch (  IllegalArgumentException e) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
  NamespaceMeta metadata;
  try {
    metadata=parseBody(request,NamespaceMeta.class);
  }
 catch (  JsonSyntaxException e) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
    return;
  }
  if (isReserved(namespaceId)) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,String.format("String_Node_Str",namespaceId,namespaceId));
    return;
  }
  NamespaceMeta.Builder builder=new NamespaceMeta.Builder().setName(namespace);
  if (metadata != null && metadata.getDescription() != null) {
    builder.setDescription(metadata.getDescription());
  }
  try {
    namespaceAdmin.createNamespace(builder.build());
    responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
  }
 catch (  AlreadyExistsException e) {
    responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
  }
}
Program: 7084
Project: 7084
Buggy source:
@Test public void testInvalidReservedId() throws Exception {
  HttpResponse response=createNamespace(METADATA_VALID,INVALID_NAME);
  assertResponseCode(400,response);
  response=createNamespace(METADATA_VALID,Constants.DEFAULT_NAMESPACE);
  assertResponseCode(400,response);
  response=createNamespace(METADATA_VALID,Constants.SYSTEM_NAMESPACE);
  assertResponseCode(400,response);
  deploy(AppWithDataset.class,Constants.Gateway.API_VERSION_3_TOKEN,Constants.DEFAULT_NAMESPACE,"String_Node_Str");
  response=deleteNamespace(Constants.DEFAULT_NAMESPACE);
  assertResponseCode(200,response);
  response=getNamespace(Constants.DEFAULT_NAMESPACE);
  Assert.assertEquals(0,getAppList(Constants.DEFAULT_NAMESPACE).size());
  assertResponseCode(200,response);
  response=deleteNamespace(Constants.SYSTEM_NAMESPACE);
  assertResponseCode(404,response);
}

Fixed version (ground truth):
@Test public void testInvalidReservedId() throws Exception {
  HttpResponse response=createNamespace(METADATA_VALID,INVALID_NAME);
  assertResponseCode(400,response);
  response=createNamespace(METADATA_VALID,"String_Node_Str");
  assertResponseCode(400,response);
  response=createNamespace(METADATA_VALID,Constants.DEFAULT_NAMESPACE);
  assertResponseCode(400,response);
  response=createNamespace(METADATA_VALID,Constants.SYSTEM_NAMESPACE);
  assertResponseCode(400,response);
  deploy(AppWithDataset.class,Constants.Gateway.API_VERSION_3_TOKEN,Constants.DEFAULT_NAMESPACE,"String_Node_Str");
  response=deleteNamespace(Constants.DEFAULT_NAMESPACE);
  assertResponseCode(200,response);
  response=getNamespace(Constants.DEFAULT_NAMESPACE);
  Assert.assertEquals(0,getAppList(Constants.DEFAULT_NAMESPACE).size());
  assertResponseCode(200,response);
  response=deleteNamespace(Constants.SYSTEM_NAMESPACE);
  assertResponseCode(404,response);
}
Program: 7085
Project: 7085
Buggy source:
@Nullable private PluginInstantiator getPluginInstantiator(CConfiguration cConf){
  if (contextConfig.getAdapterSpec() == null) {
    return null;
  }
  ClassLoader classLoader=cConf.getClassLoader();
  if (!(classLoader instanceof MapReduceClassLoader)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return ((MapReduceClassLoader)classLoader).getPluginInstantiator();
}

Fixed version (ground truth):
@Nullable private PluginInstantiator getPluginInstantiator(CConfiguration cConf){
  if (contextConfig.getAdapterSpec() == null) {
    return null;
  }
  ClassLoader classLoader=Delegators.getDelegate(cConf.getClassLoader(),MapReduceClassLoader.class);
  if (!(classLoader instanceof MapReduceClassLoader)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return ((MapReduceClassLoader)classLoader).getPluginInstantiator();
}
Program: 7086
Project: 7086
Buggy source:
/** 
 * Returns the   {@link ClassLoader} for the MapReduce program. The ClassLoader for MapReduce job is alwaysan  {@link MapReduceClassLoader}, which set by   {@link MapReduceRuntimeService} in local mode and created by MRframework in distributed mode.
 */
static ClassLoader getProgramClassLoader(Configuration hConf){
  ClassLoader classLoader=hConf.getClassLoader();
  if (!(classLoader instanceof MapReduceClassLoader)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return ((MapReduceClassLoader)classLoader).getProgramClassLoader();
}

Fixed version (ground truth):
/** 
 * Returns the   {@link ClassLoader} for the MapReduce program. The ClassLoader for MapReduce job is alwaysan  {@link MapReduceClassLoader}, which set by   {@link MapReduceRuntimeService} in local mode and created by MRframework in distributed mode.
 */
static ClassLoader getProgramClassLoader(Configuration hConf){
  ClassLoader classLoader=Delegators.getDelegate(hConf.getClassLoader(),MapReduceClassLoader.class);
  if (!(classLoader instanceof MapReduceClassLoader)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return ((MapReduceClassLoader)classLoader).getProgramClassLoader();
}
Program: 7087
Project: 7087
Buggy source:
private boolean isLocal(Configuration hConf){
  String mrFramework=hConf.get(MRConfig.FRAMEWORK_NAME,MRConfig.LOCAL_FRAMEWORK_NAME);
  return "String_Node_Str".equals(mrFramework);
}

Fixed version (ground truth):
/** 
 * Helper method to tell if the MR is running in local mode or not. This method doesn't really belongs to this class, but currently there is no better place for it.
 */
static boolean isLocal(Configuration hConf){
  String mrFramework=hConf.get(MRConfig.FRAMEWORK_NAME,MRConfig.LOCAL_FRAMEWORK_NAME);
  return MRConfig.LOCAL_FRAMEWORK_NAME.equals(mrFramework);
}
Program: 7089
Project: 7089
Buggy source:
@Override protected void shutDown() throws Exception {
  boolean success=job.isSuccessful();
  try {
    if (success) {
      LOG.info("String_Node_Str",context);
      if (!txClient.commit(transaction)) {
        LOG.warn("String_Node_Str");
        throw new TransactionFailureException("String_Node_Str" + context.toString());
      }
    }
 else {
      txClient.invalidate(transaction.getWritePointer());
    }
  }
  finally {
    try {
      onFinish(success);
    }
  finally {
      context.close();
      cleanupTask.run();
      job.getConfiguration().setClassLoader(null);
    }
  }
}

Fixed version (ground truth):
@Override protected void shutDown() throws Exception {
  boolean success=job.isSuccessful();
  try {
    if (success) {
      LOG.info("String_Node_Str",context);
      if (!txClient.commit(transaction)) {
        LOG.warn("String_Node_Str");
        throw new TransactionFailureException("String_Node_Str" + context.toString());
      }
    }
 else {
      txClient.invalidate(transaction.getWritePointer());
    }
  }
  finally {
    try {
      onFinish(success);
    }
  finally {
      context.close();
      cleanupTask.run();
    }
  }
}
Program: 7091
Project: 7091
Buggy source:
public Job(JobID jobid,String jobSubmitDir) throws IOException {
  this.systemJobDir=new Path(jobSubmitDir);
  this.systemJobFile=new Path(systemJobDir,"String_Node_Str");
  this.id=jobid;
  JobConf conf=new JobConf(systemJobFile);
  this.localFs=FileSystem.getLocal(conf);
  String user=UserGroupInformation.getCurrentUser().getShortUserName();
  this.localJobDir=localFs.makeQualified(new Path(new Path(conf.getLocalPath(jobDir),user),jobid.toString()));
  this.localJobFile=new Path(this.localJobDir,id + "String_Node_Str");
  DistributedCache.addFileToClassPath(new Path(conf.getJar()),conf,FileSystem.get(conf));
  ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(conf);
  localDistributedCacheManager=new LocalDistributedCacheManagerWithFix(id);
  localDistributedCacheManager.setup(conf);
  OutputStream out=localFs.create(localJobFile);
  try {
    conf.writeXml(out);
  }
  finally {
    out.close();
  }
  this.job=new JobConf(localJobFile);
  if (localDistributedCacheManager.hasLocalClasspaths()) {
    ClassLoader classLoader=localDistributedCacheManager.makeClassLoader(getContextClassLoader());
    setContextClassLoader(classLoader);
    this.job.setClassLoader(classLoader);
  }
  profile=new JobProfile(job.getUser(),id,systemJobFile.toString(),"String_Node_Str",job.getJobName());
  status=new JobStatus(id,0.0f,0.0f,JobStatus.RUNNING,profile.getUser(),profile.getJobName(),profile.getJobFile(),profile.getURL().toString());
  jobs.put(id,this);
  this.start();
}

Fixed version (ground truth):
public Job(JobID jobid,String jobSubmitDir) throws IOException {
  this.systemJobDir=new Path(jobSubmitDir);
  this.systemJobFile=new Path(systemJobDir,"String_Node_Str");
  this.id=jobid;
  JobConf conf=new JobConf(systemJobFile);
  this.localFs=FileSystem.getLocal(conf);
  String user=UserGroupInformation.getCurrentUser().getShortUserName();
  this.localJobDir=localFs.makeQualified(new Path(new Path(conf.getLocalPath(jobDir),user),jobid.toString()));
  this.localJobFile=new Path(this.localJobDir,id + "String_Node_Str");
  ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(conf);
  localDistributedCacheManager=new LocalDistributedCacheManagerWithFix(id);
  localDistributedCacheManager.setup(conf);
  OutputStream out=localFs.create(localJobFile);
  try {
    conf.writeXml(out);
  }
  finally {
    out.close();
  }
  this.job=new JobConf(localJobFile);
  if (localDistributedCacheManager.hasLocalClasspaths()) {
    ClassLoader classLoader=localDistributedCacheManager.makeClassLoader(getContextClassLoader());
    setContextClassLoader(classLoader);
    this.job.setClassLoader(classLoader);
  }
  profile=new JobProfile(job.getUser(),id,systemJobFile.toString(),"String_Node_Str",job.getJobName());
  status=new JobStatus(id,0.0f,0.0f,JobStatus.RUNNING,profile.getUser(),profile.getJobName(),profile.getJobFile(),profile.getURL().toString());
  jobs.put(id,this);
  this.start();
}
Program: 7092
Project: 7092
Buggy source:
@Ignore @Category(XSlowTests.class) @Test public void testWorkflowAdapter() throws Exception {
  Id.ApplicationTemplate templateId=Id.ApplicationTemplate.from(WorkflowTemplate.NAME);
  addTemplatePlugins(templateId,"String_Node_Str",FlipPlugin.class);
  deployTemplate(Constants.DEFAULT_NAMESPACE_ID,templateId,WorkflowTemplate.class);
  WorkflowTemplate.Config config=new WorkflowTemplate.Config("String_Node_Str");
  Id.Adapter adapterId=Id.Adapter.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  AdapterConfig adapterConfig=new AdapterConfig("String_Node_Str",WorkflowTemplate.NAME,GSON.toJsonTree(config));
  AdapterManager manager=createAdapter(adapterId,adapterConfig);
  DataSetManager<KeyValueTable> inputManager=getDataset(Constants.DEFAULT_NAMESPACE_ID,WorkflowTemplate.INPUT);
  inputManager.get().write(Bytes.toBytes(1L),Bytes.toBytes(10L));
  inputManager.flush();
  manager.start();
  manager.waitForOneRunToFinish(4,TimeUnit.MINUTES);
  manager.stop();
  DataSetManager<KeyValueTable> outputManager=getDataset(Constants.DEFAULT_NAMESPACE_ID,WorkflowTemplate.OUTPUT);
  long outputVal=Bytes.toLong(outputManager.get().read(Bytes.toBytes(1L)));
  Assert.assertEquals(-10L,outputVal);
}

Fixed version (ground truth):
@Category(XSlowTests.class) @Test public void testWorkflowAdapter() throws Exception {
  Id.ApplicationTemplate templateId=Id.ApplicationTemplate.from(WorkflowTemplate.NAME);
  addTemplatePlugins(templateId,"String_Node_Str",FlipPlugin.class);
  deployTemplate(Constants.DEFAULT_NAMESPACE_ID,templateId,WorkflowTemplate.class);
  WorkflowTemplate.Config config=new WorkflowTemplate.Config("String_Node_Str");
  Id.Adapter adapterId=Id.Adapter.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  AdapterConfig adapterConfig=new AdapterConfig("String_Node_Str",WorkflowTemplate.NAME,GSON.toJsonTree(config));
  AdapterManager manager=createAdapter(adapterId,adapterConfig);
  DataSetManager<KeyValueTable> inputManager=getDataset(Constants.DEFAULT_NAMESPACE_ID,WorkflowTemplate.INPUT);
  inputManager.get().write(Bytes.toBytes(1L),Bytes.toBytes(10L));
  inputManager.flush();
  manager.start();
  manager.waitForOneRunToFinish(4,TimeUnit.MINUTES);
  manager.stop();
  DataSetManager<KeyValueTable> outputManager=getDataset(Constants.DEFAULT_NAMESPACE_ID,WorkflowTemplate.OUTPUT);
  long outputVal=Bytes.toLong(outputManager.get().read(Bytes.toBytes(1L)));
  Assert.assertEquals(-10L,outputVal);
}
Program: 7094
Project: 7094
Buggy source:
/** 
 * @param runId for which information will be returned.
 * @return a {@link MRJobInfo} containing information about a particular MapReduce program run.
 * @throws IOException if there is failure to communicate through the JobClient.
 * @throws NotFoundException if a Job with the given runId is not found.
 */
public MRJobInfo getMRJobInfo(Id.Run runId) throws IOException, NotFoundException {
  Preconditions.checkArgument(ProgramType.MAPREDUCE.equals(runId.getProgram().getType()));
  JobClient jobClient;
  JobStatus[] jobs;
  try {
    jobClient=new JobClient(hConf);
    jobs=jobClient.getAllJobs();
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
    throw new IOException(e);
  }
  JobStatus thisJob=findJobForRunId(jobs,runId);
  Counters counters=jobClient.getJob(thisJob.getJobID()).getCounters();
  TaskReport[] mapTaskReports=jobClient.getMapTaskReports(thisJob.getJobID());
  TaskReport[] reduceTaskReports=jobClient.getReduceTaskReports(thisJob.getJobID());
  return new MRJobInfo(thisJob.getMapProgress(),thisJob.getReduceProgress(),groupToMap(counters.getGroup(TaskCounter.class.getName())),toMRTaskInfos(mapTaskReports),toMRTaskInfos(reduceTaskReports),true);
}

Fixed version (ground truth):
/** 
 * @param runId for which information will be returned.
 * @return a {@link MRJobInfo} containing information about a particular MapReduce program run.
 * @throws IOException if there is failure to communicate through the JobClient.
 * @throws NotFoundException if a Job with the given runId is not found.
 */
public MRJobInfo getMRJobInfo(Id.Run runId) throws IOException, NotFoundException {
  Preconditions.checkArgument(ProgramType.MAPREDUCE.equals(runId.getProgram().getType()));
  JobClient jobClient;
  JobStatus[] jobs;
  try {
    jobClient=new JobClient(hConf);
    jobs=jobClient.getAllJobs();
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
    throw new IOException(e);
  }
  JobStatus thisJob=findJobForRunId(jobs,runId);
  RunningJob runningJob=jobClient.getJob(thisJob.getJobID());
  Counters counters=runningJob.getCounters();
  TaskReport[] mapTaskReports=jobClient.getMapTaskReports(thisJob.getJobID());
  TaskReport[] reduceTaskReports=jobClient.getReduceTaskReports(thisJob.getJobID());
  return new MRJobInfo(runningJob.mapProgress(),runningJob.reduceProgress(),groupToMap(counters.getGroup(TaskCounter.class.getName())),toMRTaskInfos(mapTaskReports),toMRTaskInfos(reduceTaskReports),true);
}
Program: 7095
Project: 7095
Buggy source:
/** 
 * Returns the metric context.  A metric context is of the form {applicationId}.{programTypeId}.{programId}.{componentId}.  So for flows, it will look like appX.f.flowY.flowletZ. For mapreduce jobs, appX.b.mapredY.{optional m|r}.
 */
private static Map<String,String> getMetricContext(Program program,TwillContext context){
  ImmutableMap.Builder<String,String> builder=ImmutableMap.<String,String>builder().put(Constants.Metrics.Tag.RUN_ID,context.getRunId().getId()).put(Constants.Metrics.Tag.APP,program.getApplicationId());
  if (program.getType() == ProgramType.FLOW) {
    builder.put(Constants.Metrics.Tag.FLOW,program.getName());
    builder.put(Constants.Metrics.Tag.FLOWLET,context.getSpecification().getName());
  }
 else {
    builder.put(ProgramTypeMetricTag.getTagName(program.getType()),context.getSpecification().getName());
  }
  return builder.build();
}

Fixed version (ground truth):
/** 
 * Returns the metric context.  A metric context is of the form {applicationId}.{programTypeId}.{programId}.{componentId}.  So for flows, it will look like appX.f.flowY.flowletZ. For mapreduce jobs, appX.b.mapredY.{optional m|r}.
 */
private static Map<String,String> getMetricContext(Program program,TwillContext context){
  ImmutableMap.Builder<String,String> builder=ImmutableMap.<String,String>builder().put(Constants.Metrics.Tag.NAMESPACE,program.getNamespaceId()).put(Constants.Metrics.Tag.RUN_ID,context.getRunId().getId()).put(Constants.Metrics.Tag.APP,program.getApplicationId());
  if (program.getType() == ProgramType.FLOW) {
    builder.put(Constants.Metrics.Tag.FLOW,program.getName());
    builder.put(Constants.Metrics.Tag.FLOWLET,context.getSpecification().getName());
  }
 else {
    builder.put(ProgramTypeMetricTag.getTagName(program.getType()),context.getSpecification().getName());
  }
  return builder.build();
}
Program: 7096
Project: 7096
Buggy source:
protected AbstractHttpHandlerDelegator(DelegatorContext<T> context,MetricsCollector metricsCollector){
  this.context=context;
  this.metricsCollector=metricsCollector;
  if (context.getServiceContext() != null && context.getServiceContext().getSpecification() != null) {
    this.metricsCollector=metricsCollector.childCollector(Constants.Metrics.Tag.HANDLER,context.getServiceContext().getSpecification().getName());
  }
}

Fixed version (ground truth):
protected AbstractHttpHandlerDelegator(DelegatorContext<T> context,MetricsCollector metricsCollector){
  this.context=context;
  this.metricsCollector=metricsCollector;
}
Program: 7097
Project: 7097
Buggy source:
protected final DelayedHttpServiceResponder wrapResponder(HttpResponder responder){
  return new DelayedHttpServiceResponder(responder,metricsCollector);
}

Fixed version (ground truth):
protected final DelayedHttpServiceResponder wrapResponder(HttpResponder responder){
  MetricsCollector collector=this.metricsCollector;
  if (context.getServiceContext() != null && context.getServiceContext().getSpecification() != null) {
    collector=metricsCollector.childCollector(Constants.Metrics.Tag.HANDLER,context.getServiceContext().getSpecification().getName());
  }
  return new DelayedHttpServiceResponder(responder,collector);
}
Program: 7098
Project: 7098
Buggy source:
public void updateAppSpec(String namespaceId,String appId,ApplicationSpecification spec){
  spec=DefaultApplicationSpecification.from(spec);
  LOG.trace("String_Node_Str",appId,GSON.toJson(spec));
  MDSKey key=new MDSKey.Builder().add(TYPE_APP_META,namespaceId,appId).build();
  ApplicationMeta existing=getFirst(key,ApplicationMeta.class);
  if (existing == null) {
    String msg=String.format("String_Node_Str",namespaceId,appId);
    LOG.error(msg);
    throw new IllegalArgumentException(msg);
  }
  LOG.trace("String_Node_Str",existing);
  ApplicationMeta updated=ApplicationMeta.updateSpec(existing,spec);
  write(key,updated);
  for (  StreamSpecification stream : spec.getStreams().values()) {
    writeStream(namespaceId,stream);
  }
}

Fixed version (ground truth):
public void updateAppSpec(String namespaceId,String appId,ApplicationSpecification spec){
  spec=DefaultApplicationSpecification.from(spec);
  LOG.trace("String_Node_Str",appId,GSON.toJson(spec));
  MDSKey key=new MDSKey.Builder().add(TYPE_APP_META,namespaceId,appId).build();
  ApplicationMeta existing=getFirst(key,ApplicationMeta.class);
  if (existing == null) {
    String msg=String.format("String_Node_Str",namespaceId,appId);
    LOG.error(msg);
    throw new IllegalArgumentException(msg);
  }
  LOG.trace("String_Node_Str",existing);
  ApplicationMeta updated=ApplicationMeta.updateSpec(existing,spec);
  write(key,updated);
}
Program: 7099
Project: 7099
Buggy source:
@Override public void addApplication(final Id.Application id,final ApplicationSpecification spec,final Location appArchiveLocation){
  txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,Void>(){
    @Override public Void apply(    AppMds mds) throws Exception {
      mds.apps.writeApplication(id.getNamespaceId(),id.getId(),spec,appArchiveLocation.toURI().toString());
      for (      StreamSpecification stream : spec.getStreams().values()) {
        mds.apps.writeStream(id.getNamespaceId(),stream);
      }
      return null;
    }
  }
);
}

Fixed version (ground truth):
@Override public void addApplication(final Id.Application id,final ApplicationSpecification spec,final Location appArchiveLocation){
  txnl.executeUnchecked(new TransactionExecutor.Function<AppMds,Void>(){
    @Override public Void apply(    AppMds mds) throws Exception {
      mds.apps.writeApplication(id.getNamespaceId(),id.getId(),spec,appArchiveLocation.toURI().toString());
      return null;
    }
  }
);
}
Program: 7100
Project: 7100
Buggy source:
@Test public void testRemoveAll() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,"String_Node_Str");
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  Assert.assertEquals(1,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
  store.removeAll(namespaceId);
  Assert.assertNull(store.getApplication(appId));
  Assert.assertEquals(0,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
}

Fixed version (ground truth):
@Test public void testRemoveAll() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,"String_Node_Str");
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  store.removeAll(namespaceId);
  Assert.assertNull(store.getApplication(appId));
}
Program: 7101
Project: 7101
Buggy source:
@Test public void testRemoveApplication() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,spec.getName());
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  Assert.assertEquals(1,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
  store.removeApplication(appId);
  Assert.assertNull(store.getApplication(appId));
  Assert.assertEquals(1,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
}

Fixed version (ground truth):
@Test public void testRemoveApplication() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,spec.getName());
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  store.removeApplication(appId);
  Assert.assertNull(store.getApplication(appId));
}
Program: 7102
Project: 7102
Buggy source:
@Test public void testRemoveAllApplications() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,spec.getName());
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  Assert.assertEquals(1,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
  store.removeAllApplications(namespaceId);
  Assert.assertNull(store.getApplication(appId));
  Assert.assertEquals(1,store.getAllStreams(new Id.Namespace("String_Node_Str")).size());
}

Fixed version (ground truth):
@Test public void testRemoveAllApplications() throws Exception {
  ApplicationSpecification spec=Specifications.from(new WordCountApp());
  Id.Namespace namespaceId=new Id.Namespace("String_Node_Str");
  Id.Application appId=new Id.Application(namespaceId,spec.getName());
  store.addApplication(appId,spec,new LocalLocationFactory().create("String_Node_Str"));
  Assert.assertNotNull(store.getApplication(appId));
  store.removeAllApplications(namespaceId);
  Assert.assertNull(store.getApplication(appId));
}
Program: 7103
Project: 7103
Buggy source:
@Override public void configurePipeline(ETLStage stageConfig,PipelineConfigurer pipelineConfigurer){
  new Config(stageConfig.getProperties());
}

Fixed version (ground truth):
@Override public void configurePipeline(ETLStage stageConfig,PipelineConfigurer pipelineConfigurer){
  Config config=new Config(stageConfig.getProperties());
  pipelineConfigurer.addStream(new Stream(config.name));
}
Program: 7104
Project: 7104
Buggy source:
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String stream) throws Exception {
  try {
    Id.Stream streamId=Id.Stream.from(namespaceId,stream);
    namespaceClient.get(namespaceId);
    streamAdmin.create(streamId);
    streamMetaStore.addStream(streamId);
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  IllegalArgumentException e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
  }
catch (  NotFoundException e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
  }
}

Fixed version (ground truth):
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String stream) throws Exception {
  try {
    Id.Stream streamId=Id.Stream.from(namespaceId,stream);
    namespaceClient.get(namespaceId);
    streamAdmin.create(streamId);
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  IllegalArgumentException e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
  }
catch (  NotFoundException e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.BAD_REQUEST,e.getMessage());
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",stream,e);
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,e.getMessage());
  }
}
Program: 7105
Project: 7105
Buggy source:
@Inject public HBaseQueueClientFactory(CConfiguration cConf,Configuration hConf,HBaseTableUtil hBaseTableUtil,QueueAdmin queueAdmin,HBaseStreamAdmin streamAdmin,TransactionExecutorFactory txExecutorFactory){
  this.cConf=cConf;
  this.hConf=hConf;
  this.queueAdmin=(HBaseQueueAdmin)queueAdmin;
  this.streamAdmin=streamAdmin;
  this.queueUtil=new HBaseQueueUtilFactory().get();
  this.hBaseTableUtil=hBaseTableUtil;
  this.txExecutorFactory=txExecutorFactory;
}

Fixed version (ground truth):
@Inject public HBaseQueueClientFactory(CConfiguration cConf,Configuration hConf,HBaseTableUtil hBaseTableUtil,QueueAdmin queueAdmin,TransactionExecutorFactory txExecutorFactory){
  this.cConf=cConf;
  this.hConf=hConf;
  this.queueAdmin=(HBaseQueueAdmin)queueAdmin;
  this.queueUtil=new HBaseQueueUtilFactory().get();
  this.hBaseTableUtil=hBaseTableUtil;
  this.txExecutorFactory=txExecutorFactory;
}
Program: 7106
Project: 7106
Buggy source:
/** 
 * Helper method to select the queue or stream admin, and to ensure it's table exists.
 * @param queueName name of the queue to be opened.
 * @return the queue admin for that queue.
 * @throws IOException
 */
private HBaseQueueAdmin ensureTableExists(QueueName queueName) throws IOException {
  HBaseQueueAdmin admin=queueName.isStream() ? streamAdmin : queueAdmin;
  try {
    if (!admin.exists(queueName)) {
      admin.create(queueName);
    }
  }
 catch (  Exception e) {
    throw new IOException("String_Node_Str" + admin.getDataTableId(queueName),e);
  }
  return admin;
}

Fixed version (ground truth):
/** 
 * Helper method to select the queue or stream admin, and to ensure it's table exists.
 * @param queueName name of the queue to be opened.
 * @return the queue admin for that queue.
 * @throws IOException
 */
private HBaseQueueAdmin ensureTableExists(QueueName queueName) throws IOException {
  try {
    if (!queueAdmin.exists(queueName)) {
      queueAdmin.create(queueName);
    }
  }
 catch (  Exception e) {
    throw new IOException("String_Node_Str" + queueAdmin.getDataTableId(queueName),e);
  }
  return queueAdmin;
}
Program: 7107
Project: 7107
Buggy source:
@Override public void drop(Id.Stream streamId) throws Exception {
  drop(QueueName.fromStream(streamId));
}

Fixed version (ground truth):
@Override public void drop(Id.Stream streamId) throws Exception {
  drop(QueueName.fromStream(streamId));
  streamMetaStore.removeStream(streamId);
}
Program: 7108
Project: 7108
Buggy source:
@Inject public InMemoryStreamAdmin(InMemoryQueueService queueService,UsageRegistry usageRegistry){
  super(queueService);
  this.usageRegistry=usageRegistry;
}

Fixed version (ground truth):
@Inject public InMemoryStreamAdmin(InMemoryQueueService queueService,UsageRegistry usageRegistry,StreamMetaStore streamMetaStore){
  super(queueService);
  this.usageRegistry=usageRegistry;
  this.streamMetaStore=streamMetaStore;
}
Program: 7109
Project: 7109
Buggy source:
@Override public void dropAllInNamespace(Id.Namespace namespace) throws Exception {
  queueService.resetStreamsWithPrefix(QueueName.prefixForNamedspacedStream(namespace.getId()));
}

Fixed version (ground truth):
@Override public void dropAllInNamespace(Id.Namespace namespace) throws Exception {
  queueService.resetStreamsWithPrefix(QueueName.prefixForNamedspacedStream(namespace.getId()));
  for (  StreamSpecification spec : streamMetaStore.listStreams(namespace)) {
    streamMetaStore.removeStream(Id.Stream.from(namespace,spec.getName()));
  }
}
Program: 7110
Project: 7110
Buggy source:
@Override public void create(Id.Stream streamId,@Nullable Properties props) throws Exception {
  create(QueueName.fromStream(streamId),props);
}

Fixed version (ground truth):
@Override public void create(Id.Stream streamId,@Nullable Properties props) throws Exception {
  create(QueueName.fromStream(streamId),props);
  streamMetaStore.addStream(streamId);
}
Program: 7111
Project: 7111
Buggy source:
private void stopWorkflowAdapter(Id.Namespace namespace,AdapterSpecification adapterSpec) throws NotFoundException, SchedulerException, ExecutionException, InterruptedException {
  Id.Program workflowId=getProgramId(namespace,adapterSpec);
  String scheduleName=adapterSpec.getScheduleSpec().getSchedule().getName();
  scheduler.deleteSchedule(workflowId,SchedulableProgramType.WORKFLOW,scheduleName);
  store.deleteSchedule(workflowId,SchedulableProgramType.WORKFLOW,scheduleName);
  List<RunRecord> activeRuns=getRuns(namespace,adapterSpec.getName(),ProgramRunStatus.RUNNING,0,Long.MAX_VALUE,Integer.MAX_VALUE);
  for (  RunRecord record : activeRuns) {
    lifecycleService.stopProgram(RunIds.fromString(record.getPid()));
  }
}

Fixed version (ground truth):
private void stopWorkflowAdapter(Id.Namespace namespace,AdapterSpecification adapterSpec) throws NotFoundException, SchedulerException, ExecutionException, InterruptedException {
  Id.Program workflowId=getProgramId(namespace,adapterSpec);
  String scheduleName=adapterSpec.getScheduleSpec().getSchedule().getName();
  try {
    scheduler.deleteSchedule(workflowId,SchedulableProgramType.WORKFLOW,scheduleName);
    store.deleteSchedule(workflowId,SchedulableProgramType.WORKFLOW,scheduleName);
  }
 catch (  NotFoundException e) {
  }
  List<RunRecord> activeRuns=getRuns(namespace,adapterSpec.getName(),ProgramRunStatus.RUNNING,0,Long.MAX_VALUE,Integer.MAX_VALUE);
  for (  RunRecord record : activeRuns) {
    lifecycleService.stopProgram(RunIds.fromString(record.getPid()));
  }
}
Program: 7112
Project: 7112
Buggy source:
@Override public synchronized RuntimeInfo lookup(final RunId runId){
  RuntimeInfo runtimeInfo=super.lookup(runId);
  if (runtimeInfo != null) {
    return runtimeInfo;
  }
  String appName=null;
  TwillController controller=null;
  for (  TwillRunner.LiveInfo liveInfo : twillRunner.lookupLive()) {
    for (    TwillController c : liveInfo.getControllers()) {
      if (c.getRunId().equals(runId)) {
        appName=liveInfo.getApplicationName();
        controller=c;
        break;
      }
    }
    if (controller != null) {
      break;
    }
  }
  if (controller == null) {
    LOG.info("String_Node_Str",runId);
    return null;
  }
  Matcher matcher=APP_NAME_PATTERN.matcher(appName);
  if (!matcher.matches()) {
    LOG.warn("String_Node_Str",appName);
    return null;
  }
  ProgramType type=getType(matcher.group(1));
  if (type == null) {
    LOG.warn("String_Node_Str",appName);
    return null;
  }
  Id.Program programId=Id.Program.from(matcher.group(2),matcher.group(3),type,matcher.group(4));
  if (runtimeInfo != null) {
    runtimeInfo=createRuntimeInfo(type,programId,controller);
    updateRuntimeInfo(type,runId,runtimeInfo);
    return runtimeInfo;
  }
 else {
    LOG.warn("String_Node_Str",type,programId);
    return null;
  }
}

Fixed version (ground truth):
@Override public synchronized RuntimeInfo lookup(final RunId runId){
  RuntimeInfo runtimeInfo=super.lookup(runId);
  if (runtimeInfo != null) {
    return runtimeInfo;
  }
  String appName=null;
  TwillController controller=null;
  for (  TwillRunner.LiveInfo liveInfo : twillRunner.lookupLive()) {
    for (    TwillController c : liveInfo.getControllers()) {
      if (c.getRunId().equals(runId)) {
        appName=liveInfo.getApplicationName();
        controller=c;
        break;
      }
    }
    if (controller != null) {
      break;
    }
  }
  if (controller == null) {
    LOG.info("String_Node_Str",runId);
    return null;
  }
  Matcher matcher=APP_NAME_PATTERN.matcher(appName);
  if (!matcher.matches()) {
    LOG.warn("String_Node_Str",appName);
    return null;
  }
  ProgramType type=getType(matcher.group(1));
  if (type == null) {
    LOG.warn("String_Node_Str",appName);
    return null;
  }
  Id.Program programId=Id.Program.from(matcher.group(2),matcher.group(3),type,matcher.group(4));
  runtimeInfo=createRuntimeInfo(type,programId,controller);
  if (runtimeInfo != null) {
    updateRuntimeInfo(type,runId,runtimeInfo);
    return runtimeInfo;
  }
 else {
    LOG.warn("String_Node_Str",type,programId);
    return null;
  }
}
Program: 7113
Project: 7113
Buggy source:
public <T>Map<MDSKey,T> listKV(MDSKey startId,@Nullable MDSKey stopId,Type typeOfT,int limit,Predicate<T> filter){
  byte[] startKey=startId.getKey();
  byte[] stopKey=stopId == null ? Bytes.stopKeyForPrefix(startKey) : stopId.getKey();
  try {
    Map<MDSKey,T> map=Maps.newLinkedHashMap();
    Scanner scan=table.scan(startKey,stopKey);
    try {
      Row next;
      while ((limit-- > 0) && (next=scan.next()) != null) {
        byte[] columnValue=next.get(COLUMN);
        if (columnValue == null) {
          continue;
        }
        T value=deserialize(columnValue,typeOfT);
        if (filter.apply(value)) {
          MDSKey key=new MDSKey(next.getRow());
          map.put(key,value);
          --limit;
        }
      }
      return map;
    }
  finally {
      scan.close();
    }
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
public <T>Map<MDSKey,T> listKV(MDSKey startId,@Nullable MDSKey stopId,Type typeOfT,int limit,Predicate<T> filter){
  byte[] startKey=startId.getKey();
  byte[] stopKey=stopId == null ? Bytes.stopKeyForPrefix(startKey) : stopId.getKey();
  try {
    Map<MDSKey,T> map=Maps.newLinkedHashMap();
    Scanner scan=table.scan(startKey,stopKey);
    try {
      Row next;
      while ((limit > 0) && (next=scan.next()) != null) {
        byte[] columnValue=next.get(COLUMN);
        if (columnValue == null) {
          continue;
        }
        T value=deserialize(columnValue,typeOfT);
        if (filter.apply(value)) {
          MDSKey key=new MDSKey(next.getRow());
          map.put(key,value);
          --limit;
        }
      }
      return map;
    }
  finally {
      scan.close();
    }
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
}
Program: 7115
Project: 7115
Buggy source:
public RunRecord(RunRecord started,long stopTs,ProgramRunStatus status){
  this(started.pid,started.startTs,stopTs,status,started.getAdapterName());
}

Fixed version (ground truth):
public RunRecord(RunRecord started,@Nullable Long stopTs,ProgramRunStatus status){
  this(started.pid,started.startTs,stopTs,status,started.getAdapterName());
}
Program: 7116
Project: 7116
Buggy source:
public long getStopTs(){
  return stopTs;
}

Fixed version (ground truth):
@Nullable public Long getStopTs(){
  return stopTs;
}
Program: 7117
Project: 7117
Buggy source:
@Override public MetricsCollector childCollector(Map<String,String> tags){
  if (tags.isEmpty()) {
    return this;
  }
  Map<String,String> allTags=Maps.newHashMap();
  allTags.putAll(this.tags);
  allTags.putAll(tags);
  return new MetricsCollectorImpl(allTags);
}

Fixed version (ground truth):
@Override public MetricsCollector childCollector(Map<String,String> tags){
  if (tags.isEmpty()) {
    return this;
  }
  Map<String,String> allTags=Maps.newHashMap();
  allTags.putAll(this.tags);
  allTags.putAll(tags);
  return collectors.getUnchecked(allTags);
}
Program: 7118
Project: 7118
Buggy source:
private MetricsCollectorImpl(final Map<String,String> tags){
  this.tags=tags;
  emitters.put(tags,new AggregatedMetricsEmitter(tags));
}

Fixed version (ground truth):
private MetricsCollectorImpl(final Map<String,String> tags){
  this.tags=tags;
}
Program: 7119
Project: 7119
Buggy source:
public V getEmitted(K key){
  return emitted.get(key);
}

Fixed version (ground truth):
public List<Entry<K,V>> getEmitted(){
  return emitted;
}
Program: 7120
Project: 7120
Buggy source:
@Override public void emit(K key,V value){
  emitted.put(key,value);
}

Fixed version (ground truth):
@Override public void emit(K key,V value){
  emitted.add(new Entry(key,value));
}
Program: 7122
Project: 7122
Buggy source:
/** 
 * Check if this is a simple type or a nullable simple type, which is a union of a null and one other non-null simple type, where a simple type is a boolean, int, long, float, double, bytes, or string type.
 * @return whether or not this is a nullable simple type.
 */
public boolean isSimpleOrNullableSimple(){
  return type.isSimpleType() || (type == Type.UNION && getNonNullable().getType().isSimpleType());
}

Fixed version (ground truth):
/** 
 * Check if this is a simple type or a nullable simple type, which is a union of a null and one other non-null simple type, where a simple type is a boolean, int, long, float, double, bytes, or string type.
 * @return whether or not this is a nullable simple type.
 */
public boolean isSimpleOrNullableSimple(){
  return type.isSimpleType() || isNullableSimple();
}
Program: 7123
Project: 7123
Buggy source:
abstract Object get(byte[] rowKey);

Fixed version (ground truth):
T get(byte[] rowKey);
Program: 7126
Project: 7126
Buggy source:
public Iterator<MetricValue> getMetaMetrics(){
  long currentTimeMs=System.currentTimeMillis();
  long currentTimeSec=TimeUnit.MILLISECONDS.toSeconds(currentTimeMs);
  MetricValue delayAvg=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis((long)processDelayStats.getAverage()),MetricType.GAUGE);
  MetricValue delayMin=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis(processDelayStats.getMin()),MetricType.GAUGE);
  MetricValue delayMax=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis(processDelayStats.getMax()),MetricType.GAUGE);
  MetricValue count=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,processDelayStats.getCount(),MetricType.COUNTER);
  return ImmutableList.of(delayAvg,delayMin,delayMax,count).iterator();
}

Fixed version (ground truth):
public Iterator<MetricValue> getMetaMetrics(){
  if (processDelayStats.isEmpty()) {
    return Iterators.emptyIterator();
  }
  long currentTimeMs=System.currentTimeMillis();
  long currentTimeSec=TimeUnit.MILLISECONDS.toSeconds(currentTimeMs);
  MetricValue delayAvg=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis(processDelayStats.getAverage()),MetricType.GAUGE);
  MetricValue delayMin=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis(processDelayStats.getMin()),MetricType.GAUGE);
  MetricValue delayMax=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,currentTimeMs - TimeUnit.SECONDS.toMillis(processDelayStats.getMax()),MetricType.GAUGE);
  MetricValue count=new MetricValue(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE,"String_Node_Str"),"String_Node_Str",currentTimeSec,processDelayStats.getCount(),MetricType.COUNTER);
  return ImmutableList.of(delayAvg,delayMin,delayMax,count).iterator();
}
Program: 7127
Project: 7127
Buggy source:
public float getAverage(){
  long sum=0;
  for (  Long value : values) {
    int valueCount=values.count(value);
    sum+=value * valueCount;
  }
  return sum * 1.0f / count;
}

Fixed version (ground truth):
public long getAverage(){
  if (count == 0) {
    return 0;
  }
  double average=0;
  for (  Long value : values.elementSet()) {
    int valueCount=values.count(value);
    average+=value * (valueCount * 1.0 / count);
  }
  return (long)average;
}