nus-yam/ex-repair huggingface dataset:
Program: 6925
Project: 6925
Buggy source:
@Override public Module getDistributedModules(){
  return new PrivateModule(){
    @Override protected void configure(){
      install(new SystemDatasetRuntimeModule().getDistributedModules());
      install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
      bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
      expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
      bind(MDSDatasetsRegistry.class).in(Singleton.class);
      Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class).addBinding().to(HBaseDatasetMetricsReporter.class);
      bind(DatasetService.class);
      expose(DatasetService.class);
      Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
      CommonHandlers.add(handlerBinder);
      handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
      bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
      expose(DatasetOpExecutorService.class);
      bind(DatasetOpExecutor.class).to(YarnDatasetOpExecutor.class);
      expose(DatasetOpExecutor.class);
      bind(UnderlyingSystemNamespaceAdmin.class).to(DistributedUnderlyingSystemNamespaceAdmin.class);
      expose(UnderlyingSystemNamespaceAdmin.class);
    }
  }
;
}

Fixed version (ground truth):
@Override public Module getDistributedModules(){
  return new PrivateModule(){
    @Override protected void configure(){
      install(new SystemDatasetRuntimeModule().getDistributedModules());
      install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
      bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
      expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
      bind(MDSDatasetsRegistry.class).in(Singleton.class);
      Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class).addBinding().to(HBaseDatasetMetricsReporter.class);
      bind(DatasetService.class);
      expose(DatasetService.class);
      Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
      CommonHandlers.add(handlerBinder);
      handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
      bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
      expose(DatasetOpExecutorService.class);
      bind(DatasetOpExecutor.class).to(YarnDatasetOpExecutor.class);
      expose(DatasetOpExecutor.class);
      bind(StorageProviderNamespaceAdmin.class).to(DistributedStorageProviderNamespaceAdmin.class);
      expose(StorageProviderNamespaceAdmin.class);
    }
  }
;
}
Program: 6926
Project: 6926
Buggy source:
@Override public Module getInMemoryModules(){
  return new PrivateModule(){
    @Override protected void configure(){
      install(new SystemDatasetRuntimeModule().getInMemoryModules());
      install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
      bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
      expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
      bind(MDSDatasetsRegistry.class).in(Singleton.class);
      bind(DatasetService.class);
      expose(DatasetService.class);
      Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
      CommonHandlers.add(handlerBinder);
      handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
      Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class);
      bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
      expose(DatasetOpExecutorService.class);
      bind(DatasetOpExecutor.class).to(LocalDatasetOpExecutor.class);
      expose(DatasetOpExecutor.class);
      bind(UnderlyingSystemNamespaceAdmin.class).to(LocalUnderlyingSystemNamespaceAdmin.class);
      expose(UnderlyingSystemNamespaceAdmin.class);
    }
  }
;
}

Fixed version (ground truth):
@Override public Module getInMemoryModules(){
  return new PrivateModule(){
    @Override protected void configure(){
      install(new SystemDatasetRuntimeModule().getInMemoryModules());
      install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
      bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
      expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
      bind(MDSDatasetsRegistry.class).in(Singleton.class);
      bind(DatasetService.class);
      expose(DatasetService.class);
      Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
      CommonHandlers.add(handlerBinder);
      handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
      Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class);
      bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
      expose(DatasetOpExecutorService.class);
      bind(DatasetOpExecutor.class).to(LocalDatasetOpExecutor.class);
      expose(DatasetOpExecutor.class);
      bind(StorageProviderNamespaceAdmin.class).to(LocalStorageProviderNamespaceAdmin.class);
      expose(StorageProviderNamespaceAdmin.class);
    }
  }
;
}
Program: 6927
Project: 6927
Buggy source:
@Override protected void configure(){
  install(new SystemDatasetRuntimeModule().getDistributedModules());
  install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
  bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
  expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
  bind(MDSDatasetsRegistry.class).in(Singleton.class);
  Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class).addBinding().to(HBaseDatasetMetricsReporter.class);
  bind(DatasetService.class);
  expose(DatasetService.class);
  Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
  Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
  CommonHandlers.add(handlerBinder);
  handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
  bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
  expose(DatasetOpExecutorService.class);
  bind(DatasetOpExecutor.class).to(YarnDatasetOpExecutor.class);
  expose(DatasetOpExecutor.class);
  bind(UnderlyingSystemNamespaceAdmin.class).to(DistributedUnderlyingSystemNamespaceAdmin.class);
  expose(UnderlyingSystemNamespaceAdmin.class);
}

Fixed version (ground truth):
@Override protected void configure(){
  install(new SystemDatasetRuntimeModule().getDistributedModules());
  install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class,DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
  bind(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str")).toProvider(DatasetMdsProvider.class);
  expose(DatasetFramework.class).annotatedWith(Names.named("String_Node_Str"));
  bind(MDSDatasetsRegistry.class).in(Singleton.class);
  Multibinder.newSetBinder(binder(),DatasetMetricsReporter.class).addBinding().to(HBaseDatasetMetricsReporter.class);
  bind(DatasetService.class);
  expose(DatasetService.class);
  Named datasetUserName=Names.named(Constants.Service.DATASET_EXECUTOR);
  Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,datasetUserName);
  CommonHandlers.add(handlerBinder);
  handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
  bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
  expose(DatasetOpExecutorService.class);
  bind(DatasetOpExecutor.class).to(YarnDatasetOpExecutor.class);
  expose(DatasetOpExecutor.class);
  bind(StorageProviderNamespaceAdmin.class).to(DistributedStorageProviderNamespaceAdmin.class);
  expose(StorageProviderNamespaceAdmin.class);
}
Program: 6929
Project: 6929
Buggy source:
@PUT @Path("String_Node_Str") public void createNamespace(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  try {
    underlyingSystemNamespaceAdmin.create(Id.Namespace.from(namespaceId));
  }
 catch (  IOException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  ExploreException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  SQLException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
  responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
}

Fixed version (ground truth):
@PUT @Path("String_Node_Str") public void createNamespace(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  try {
    storageProviderNamespaceAdmin.create(Id.Namespace.from(namespaceId));
  }
 catch (  IOException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  ExploreException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  SQLException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
  responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
}
Program: 6930
Project: 6930
Buggy source:
@Inject public UnderlyingSystemNamespaceHandler(UnderlyingSystemNamespaceAdmin underlyingSystemNamespaceAdmin){
  this.underlyingSystemNamespaceAdmin=underlyingSystemNamespaceAdmin;
}

Fixed version (ground truth):
@Inject public UnderlyingSystemNamespaceHandler(StorageProviderNamespaceAdmin storageProviderNamespaceAdmin){
  this.storageProviderNamespaceAdmin=storageProviderNamespaceAdmin;
}
Program: 6931
Project: 6931
Buggy source:
@DELETE @Path("String_Node_Str") public void deleteNamespace(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  try {
    underlyingSystemNamespaceAdmin.delete(Id.Namespace.from(namespaceId));
  }
 catch (  IOException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  ExploreException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  SQLException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
  responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
}

Fixed version (ground truth):
@DELETE @Path("String_Node_Str") public void deleteNamespace(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId){
  try {
    storageProviderNamespaceAdmin.delete(Id.Namespace.from(namespaceId));
  }
 catch (  IOException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  ExploreException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
catch (  SQLException e) {
    responder.sendString(HttpResponseStatus.INTERNAL_SERVER_ERROR,"String_Node_Str" + e.getMessage());
    return;
  }
  responder.sendString(HttpResponseStatus.OK,String.format("String_Node_Str",namespaceId));
}
Program: 6934
Project: 6934
Buggy source:
@Test public void test() throws IOException {
  Assert.assertEquals(200,createNamespace("String_Node_Str").getResponseCode());
  Assert.assertEquals(500,createNamespace("String_Node_Str").getResponseCode());
  Assert.assertEquals(200,deleteNamespace("String_Node_Str").getResponseCode());
}

Fixed version (ground truth):
@Test public void test() throws IOException {
  Assert.assertEquals(200,createNamespace("String_Node_Str").getResponseCode());
  Assert.assertEquals(200,createNamespace("String_Node_Str").getResponseCode());
  Assert.assertEquals(200,deleteNamespace("String_Node_Str").getResponseCode());
}
Program: 6935
Project: 6935
Buggy source:
@Test public void testNamespaceCreationDeletion() throws DatasetManagementException {
  DatasetFramework framework=getFramework();
  Id.Namespace namespace=Id.Namespace.from("String_Node_Str");
  framework.createNamespace(namespace);
  try {
    framework.createNamespace(namespace);
    Assert.fail("String_Node_Str");
  }
 catch (  DatasetManagementException e) {
  }
  framework.deleteNamespace(namespace);
}

Fixed version (ground truth):
@Test public void testNamespaceCreationDeletion() throws DatasetManagementException {
  DatasetFramework framework=getFramework();
  Id.Namespace namespace=Id.Namespace.from("String_Node_Str");
  framework.createNamespace(namespace);
  framework.deleteNamespace(namespace);
}
Program: 6936
Project: 6936
Buggy source:
protected String determinePattern(String action){
  if (action.equals("String_Node_Str")) {
switch (type) {
case INSTANCE:
      return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS);
case NAMESPACE:
    return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS);
case APP:
  return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS,type.getArgumentName());
case FLOW:
case MAPREDUCE:
case WORKFLOW:
case SERVICE:
case SPARK:
return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS,type.getArgumentName());
}
}
 else if (action.equals("String_Node_Str")) {
switch (type) {
case INSTANCE:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE);
case NAMESPACE:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE);
case APP:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE,type.getArgumentName());
case FLOW:
case MAPREDUCE:
case WORKFLOW:
case SERVICE:
case SPARK:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE,type.getArgumentName());
}
}
return "String_Node_Str";
}

Fixed version (ground truth):
protected String determinePattern(String action){
  if ("String_Node_Str".equals(action)) {
switch (type) {
case INSTANCE:
case NAMESPACE:
      return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS);
case APP:
    return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS,type.getArgumentName());
case FLOW:
case MAPREDUCE:
case WORKFLOW:
case SERVICE:
case SPARK:
  return String.format("String_Node_Str",type.getName(),ArgumentName.RUNTIME_ARGS,type.getArgumentName());
}
}
 else if ("String_Node_Str".equals(action)) {
switch (type) {
case INSTANCE:
case NAMESPACE:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE);
case APP:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE,type.getArgumentName());
case FLOW:
case MAPREDUCE:
case WORKFLOW:
case SERVICE:
case SPARK:
return String.format("String_Node_Str",type.getName(),ArgumentName.LOCAL_FILE_PATH,ArgumentName.CONTENT_TYPE,type.getArgumentName());
}
}
return "String_Node_Str";
}
Program: 6937
Project: 6937
Buggy source:
@Override public String getPattern(){
  return this.determinePattern("String_Node_Str");
}

Fixed version (ground truth):
@Override public String getPattern(){
  return determinePattern("String_Node_Str");
}
Program: 6938
Project: 6938
Buggy source:
@Override public String getPattern(){
  return this.determinePattern("String_Node_Str");
}

Fixed version (ground truth):
@Override public String getPattern(){
  return determinePattern("String_Node_Str");
}
Program: 6939
Project: 6939
Buggy source:
@VisibleForTesting public void registerTemplates(){
  try {
    Map<String,ApplicationTemplateInfo> newInfoMap=Maps.newHashMap();
    Map<File,ApplicationTemplateInfo> newFileTemplateMap=Maps.newHashMap();
    File baseDir=new File(configuration.get(Constants.AppFabric.APP_TEMPLATE_DIR));
    List<File> files=DirUtils.listFiles(baseDir,"String_Node_Str");
    for (    File file : files) {
      try {
        ApplicationTemplateInfo info=getTemplateInfo(file);
        newInfoMap.put(info.getName(),info);
        newFileTemplateMap.put(info.getFile().getAbsoluteFile(),info);
      }
 catch (      IllegalArgumentException e) {
        LOG.error("String_Node_Str",file.getName(),e);
      }
    }
    appTemplateInfos.set(newInfoMap);
    fileToTemplateMap.set(newFileTemplateMap);
    pluginRepository.inspectPlugins(newInfoMap.values());
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
@VisibleForTesting public void registerTemplates(){
  try {
    Map<String,ApplicationTemplateInfo> newInfoMap=Maps.newHashMap();
    Map<File,ApplicationTemplateInfo> newFileTemplateMap=Maps.newHashMap();
    File baseDir=new File(configuration.get(Constants.AppFabric.APP_TEMPLATE_DIR));
    List<File> files=DirUtils.listFiles(baseDir,"String_Node_Str");
    for (    File file : files) {
      try {
        ApplicationTemplateInfo info=getTemplateInfo(file);
        newInfoMap.put(info.getName(),info);
        newFileTemplateMap.put(info.getFile().getAbsoluteFile(),info);
      }
 catch (      IllegalArgumentException e) {
        LOG.error("String_Node_Str",file.getName(),e);
      }
    }
    appTemplateInfos.set(newInfoMap);
    fileToTemplateMap.set(newFileTemplateMap);
    pluginRepository.inspectPlugins(newInfoMap.values());
  }
 catch (  Exception e) {
    LOG.warn("String_Node_Str",e);
  }
}
Program: 6940
Project: 6940
Buggy source:
/** 
 * Creates a ClassLoader for the given template application.
 * @param templateJar the template jar file.
 * @return a {@link CloseableClassLoader} for the template application.
 * @throws IOException if failed to expand the jar
 */
private CloseableClassLoader createTemplateClassLoader(File templateJar) throws IOException {
  final File unpackDir=DirUtils.createTempDir(tmpDir);
  BundleJarUtil.unpackProgramJar(Files.newInputStreamSupplier(templateJar),unpackDir);
  ProgramClassLoader programClassLoader=ProgramClassLoader.create(unpackDir,getClass().getClassLoader());
  return new CloseableClassLoader(programClassLoader,new Closeable(){
    @Override public void close() throws IOException {
      DirUtils.deleteDirectoryContents(unpackDir);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates a ClassLoader for the given template application.
 * @param templateJar the template jar file.
 * @return a {@link CloseableClassLoader} for the template application.
 * @throws IOException if failed to expand the jar
 */
private CloseableClassLoader createTemplateClassLoader(File templateJar) throws IOException {
  final File unpackDir=DirUtils.createTempDir(tmpDir);
  BundleJarUtil.unpackProgramJar(Files.newInputStreamSupplier(templateJar),unpackDir);
  ProgramClassLoader programClassLoader=ProgramClassLoader.create(unpackDir,getClass().getClassLoader());
  return new CloseableClassLoader(programClassLoader,new Closeable(){
    @Override public void close(){
      try {
        DirUtils.deleteDirectoryContents(unpackDir);
      }
 catch (      IOException e) {
        LOG.warn("String_Node_Str",unpackDir,e);
      }
    }
  }
);
}
Program: 6941
Project: 6941
Buggy source:
/** 
 * Helper method to get program id for a run record if it exists in the store.
 * @param store
 * @param namespaceName
 * @param appName
 * @param programType
 * @param programName
 * @param runId
 * @return instance of {@link Id.Program} if exist for the runId or null if does not.
 */
@Nullable private static Id.Program validateProgramForRunRecord(Store store,String namespaceName,String appName,ProgramType programType,String programName,String runId){
  Id.Program programId=Id.Program.from(namespaceName,appName,programType,programName);
  RunRecord runRecord=store.getRun(programId,runId);
  if (runRecord != null) {
    return programId;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Helper method to get program id for a run record if it exists in the store.
 * @return instance of {@link Id.Program} if exist for the runId or null if does not.
 */
@Nullable private Id.Program validateProgramForRunRecord(String namespaceName,String appName,ProgramType programType,String programName,String runId){
  Id.Program programId=Id.Program.from(namespaceName,appName,programType,programName);
  RunRecord runRecord=store.getRun(programId,runId);
  if (runRecord != null) {
    return programId;
  }
 else {
    return null;
  }
}
Program: 6942
Project: 6942
Buggy source:
@Override public void run(){
  for (  ProgramType programType : ProgramType.values()) {
    programLifecycleService.validateAndCorrectRunningRunRecords(programType);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    RunRecordsCorrectorRunnable.LOG.debug("String_Node_Str");
    programLifecycleService.validateAndCorrectRunningRunRecords();
    RunRecordsCorrectorRunnable.LOG.debug("String_Node_Str");
  }
 catch (  Throwable t) {
  }
}
Program: 6943
Project: 6943
Buggy source:
/** 
 * Helper method to check if the run record is a child program of a Workflow
 * @param runRecord The target {@link RunRecord} to check
 * @return {@code true} of we should check and {@code false} otherwise
 */
private boolean shouldCorrectForWorkflowChildren(RunRecord runRecord){
  if (runRecord.getProperties() != null && runRecord.getProperties().get("String_Node_Str") != null) {
    String workflowRunId=runRecord.getProperties().get("String_Node_Str");
    Id.Program workflowProgramId=retrieveProgramIdForRunRecord(ProgramType.WORKFLOW,workflowRunId);
    if (workflowProgramId != null) {
      RunRecord wfRunRecord=store.getRun(workflowProgramId,workflowRunId);
      RuntimeInfo wfRuntimeInfo=runtimeService.lookup(workflowProgramId,RunIds.fromString(workflowRunId));
      if (wfRunRecord != null && wfRunRecord.getStatus() == ProgramRunStatus.RUNNING && wfRuntimeInfo != null) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Helper method to check if the run record is a child program of a Workflow
 * @param runRecord The target {@link RunRecord} to check
 * @param processedInvalidRunRecordIds the {@link Set} of processed invalid run record ids.
 * @return {@code true} of we should check and {@code false} otherwise
 */
private boolean shouldCorrectForWorkflowChildren(RunRecord runRecord,Set<String> processedInvalidRunRecordIds){
  if (runRecord.getProperties() != null && runRecord.getProperties().get("String_Node_Str") != null) {
    String workflowRunId=runRecord.getProperties().get("String_Node_Str");
    if (!processedInvalidRunRecordIds.contains(workflowRunId)) {
      Id.Program workflowProgramId=retrieveProgramIdForRunRecord(ProgramType.WORKFLOW,workflowRunId);
      if (workflowProgramId != null) {
        RunRecord wfRunRecord=store.getRun(workflowProgramId,workflowRunId);
        RuntimeInfo wfRuntimeInfo=runtimeService.lookup(workflowProgramId,RunIds.fromString(workflowRunId));
        if (wfRunRecord != null && wfRunRecord.getStatus() == ProgramRunStatus.RUNNING && wfRuntimeInfo != null) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 6945
Project: 6945
Buggy source:
/** 
 * Fix all the possible inconsistent states for RunRecords that shows it is in RUNNING state but actually not via check to   {@link ProgramRuntimeService}.
 * @param programType The type of programs the run records nee to validate and update.
 */
private void validateAndCorrectRunningRunRecords(ProgramType programType){
  final Map<RunId,RuntimeInfo> runIdToRuntimeInfo=runtimeService.list(programType);
  List<RunRecord> invalidRunRecords=store.getRuns(ProgramRunStatus.RUNNING,new Predicate<RunRecord>(){
    @Override public boolean apply(    @Nullable RunRecord input){
      if (input == null) {
        return false;
      }
      String runId=input.getPid();
      return !runIdToRuntimeInfo.containsKey(RunIds.fromString(runId));
    }
  }
);
  if (!invalidRunRecords.isEmpty()) {
    LOG.warn("String_Node_Str",invalidRunRecords.size(),programType.getPrettyName());
  }
  for (  RunRecord rr : invalidRunRecords) {
    boolean shouldCorrect=shouldCorrectForWorkflowChildren(rr);
    if (!shouldCorrect) {
      continue;
    }
    String runId=rr.getPid();
    Id.Program targetProgramId=retrieveProgramIdForRunRecord(programType,runId);
    if (targetProgramId != null) {
      store.compareAndSetStatus(targetProgramId,runId,ProgramController.State.ALIVE.getRunStatus(),ProgramController.State.ERROR.getRunStatus());
    }
  }
}

Fixed version (ground truth):
/** 
 * Fix all the possible inconsistent states for RunRecords that shows it is in RUNNING state but actually not via check to   {@link ProgramRuntimeService} for a type of CDAP program.
 * @param programType The type of program the run records need to validate and update.
 * @param processedInvalidRunRecordIds the {@link Set} of processed invalid run record ids.
 */
void validateAndCorrectRunningRunRecords(ProgramType programType,Set<String> processedInvalidRunRecordIds){
  final Map<RunId,RuntimeInfo> runIdToRuntimeInfo=runtimeService.list(programType);
  List<RunRecord> invalidRunRecords=store.getRuns(ProgramRunStatus.RUNNING,new Predicate<RunRecord>(){
    @Override public boolean apply(    @Nullable RunRecord input){
      if (input == null) {
        return false;
      }
      String runId=input.getPid();
      return !runIdToRuntimeInfo.containsKey(RunIds.fromString(runId));
    }
  }
);
  if (!invalidRunRecords.isEmpty()) {
    LOG.warn("String_Node_Str",invalidRunRecords.size(),programType.getPrettyName());
  }
  for (  RunRecord rr : invalidRunRecords) {
    boolean shouldCorrect=shouldCorrectForWorkflowChildren(rr,processedInvalidRunRecordIds);
    if (!shouldCorrect) {
      continue;
    }
    String runId=rr.getPid();
    Id.Program targetProgramId=retrieveProgramIdForRunRecord(programType,runId);
    if (targetProgramId != null) {
      store.compareAndSetStatus(targetProgramId,runId,ProgramController.State.ALIVE.getRunStatus(),ProgramController.State.ERROR.getRunStatus());
      processedInvalidRunRecordIds.add(runId);
    }
  }
}
Program: 6946
Project: 6946
Buggy source:
@POST @Path("String_Node_Str") public void suspendWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      sendInvalidResponse(responder,id);
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.SUSPENDED) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getMessage());
      return;
    }
    controller.suspend().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void suspendWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId) throws NotFoundException, ExecutionException, InterruptedException {
  Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
  ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
  if (runtimeInfo == null) {
    throw new NotFoundException(new Id.Run(id,runId));
  }
  ProgramController controller=runtimeInfo.getController();
  if (controller.getState() == ProgramController.State.SUSPENDED) {
    responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getMessage());
    return;
  }
  controller.suspend().get();
  responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
}
Program: 6947
Project: 6947
Buggy source:
@POST @Path("String_Node_Str") public void resumeWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      sendInvalidResponse(responder,id);
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.ALIVE) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getMessage());
      return;
    }
    controller.resume().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void resumeWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId) throws NotFoundException, ExecutionException, InterruptedException {
  Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
  ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
  if (runtimeInfo == null) {
    throw new NotFoundException(new Id.Run(id,runId));
  }
  ProgramController controller=runtimeInfo.getController();
  if (controller.getState() == ProgramController.State.ALIVE) {
    responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getMessage());
    return;
  }
  controller.resume().get();
  responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
}
Program: 6949
Project: 6949
Buggy source:
/** 
 * Helper method to get program id for a run record if it exists in the store.
 * @param store
 * @param namespaceName
 * @param appName
 * @param programType
 * @param programName
 * @param runId
 * @return instance of {@link Id.Program} if exist for the runId or null if does not.
 */
@Nullable private static Id.Program validateProgramForRunRecord(Store store,String namespaceName,String appName,ProgramType programType,String programName,String runId){
  Id.Program programId=Id.Program.from(namespaceName,appName,programType,programName);
  RunRecord runRecord=store.getRun(programId,runId);
  if (runRecord != null) {
    return programId;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Helper method to get program id for a run record if it exists in the store.
 * @return instance of {@link Id.Program} if exist for the runId or null if does not.
 */
@Nullable private Id.Program validateProgramForRunRecord(String namespaceName,String appName,ProgramType programType,String programName,String runId){
  Id.Program programId=Id.Program.from(namespaceName,appName,programType,programName);
  RunRecord runRecord=store.getRun(programId,runId);
  if (runRecord != null) {
    return programId;
  }
 else {
    return null;
  }
}
Program: 6950
Project: 6950
Buggy source:
@Override public void run(){
  for (  ProgramType programType : ProgramType.values()) {
    programLifecycleService.validateAndCorrectRunningRunRecords(programType);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    RunRecordsCorrectorRunnable.LOG.debug("String_Node_Str");
    programLifecycleService.validateAndCorrectRunningRunRecords();
    RunRecordsCorrectorRunnable.LOG.debug("String_Node_Str");
  }
 catch (  Throwable t) {
  }
}
Program: 6951
Project: 6951
Buggy source:
/** 
 * Helper method to check if the run record is a child program of a Workflow
 * @param runRecord The target {@link RunRecord} to check
 * @return {@code true} of we should check and {@code false} otherwise
 */
private boolean shouldCorrectForWorkflowChildren(RunRecord runRecord){
  if (runRecord.getProperties() != null && runRecord.getProperties().get("String_Node_Str") != null) {
    String workflowRunId=runRecord.getProperties().get("String_Node_Str");
    Id.Program workflowProgramId=retrieveProgramIdForRunRecord(ProgramType.WORKFLOW,workflowRunId);
    if (workflowProgramId != null) {
      RunRecord wfRunRecord=store.getRun(workflowProgramId,workflowRunId);
      RuntimeInfo wfRuntimeInfo=runtimeService.lookup(workflowProgramId,RunIds.fromString(workflowRunId));
      if (wfRunRecord != null && wfRunRecord.getStatus() == ProgramRunStatus.RUNNING && wfRuntimeInfo != null) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Helper method to check if the run record is a child program of a Workflow
 * @param runRecord The target {@link RunRecord} to check
 * @param processedInvalidRunRecordIds the {@link Set} of processed invalid run record ids.
 * @return {@code true} of we should check and {@code false} otherwise
 */
private boolean shouldCorrectForWorkflowChildren(RunRecord runRecord,Set<String> processedInvalidRunRecordIds){
  if (runRecord.getProperties() != null && runRecord.getProperties().get("String_Node_Str") != null) {
    String workflowRunId=runRecord.getProperties().get("String_Node_Str");
    if (!processedInvalidRunRecordIds.contains(workflowRunId)) {
      Id.Program workflowProgramId=retrieveProgramIdForRunRecord(ProgramType.WORKFLOW,workflowRunId);
      if (workflowProgramId != null) {
        RunRecord wfRunRecord=store.getRun(workflowProgramId,workflowRunId);
        RuntimeInfo wfRuntimeInfo=runtimeService.lookup(workflowProgramId,RunIds.fromString(workflowRunId));
        if (wfRunRecord != null && wfRunRecord.getStatus() == ProgramRunStatus.RUNNING && wfRuntimeInfo != null) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 6953
Project: 6953
Buggy source:
/** 
 * Fix all the possible inconsistent states for RunRecords that shows it is in RUNNING state but actually not via check to   {@link ProgramRuntimeService}.
 * @param programType The type of programs the run records nee to validate and update.
 */
void validateAndCorrectRunningRunRecords(ProgramType programType){
  final Map<RunId,RuntimeInfo> runIdToRuntimeInfo=runtimeService.list(programType);
  List<RunRecord> invalidRunRecords=store.getRuns(ProgramRunStatus.RUNNING,new Predicate<RunRecord>(){
    @Override public boolean apply(    @Nullable RunRecord input){
      if (input == null) {
        return false;
      }
      String runId=input.getPid();
      return !runIdToRuntimeInfo.containsKey(RunIds.fromString(runId));
    }
  }
);
  if (!invalidRunRecords.isEmpty()) {
    LOG.warn("String_Node_Str",invalidRunRecords.size());
  }
  for (  RunRecord rr : invalidRunRecords) {
    boolean shouldCorrect=shouldCorrectForWorkflowChildren(rr);
    if (!shouldCorrect) {
      continue;
    }
    String runId=rr.getPid();
    Id.Program targetProgramId=retrieveProgramIdForRunRecord(programType,runId);
    if (targetProgramId != null) {
      LOG.warn("String_Node_Str",runId,targetProgramId,programType.getPrettyName());
      store.compareAndSetStatus(targetProgramId,runId,ProgramController.State.ALIVE.getRunStatus(),ProgramController.State.ERROR.getRunStatus());
    }
  }
}

Fixed version (ground truth):
/** 
 * Fix all the possible inconsistent states for RunRecords that shows it is in RUNNING state but actually not via check to   {@link ProgramRuntimeService} for a type of CDAP program.
 * @param programType The type of program the run records need to validate and update.
 * @param processedInvalidRunRecordIds the {@link Set} of processed invalid run record ids.
 */
void validateAndCorrectRunningRunRecords(ProgramType programType,Set<String> processedInvalidRunRecordIds){
  final Map<RunId,RuntimeInfo> runIdToRuntimeInfo=runtimeService.list(programType);
  List<RunRecord> invalidRunRecords=store.getRuns(ProgramRunStatus.RUNNING,new Predicate<RunRecord>(){
    @Override public boolean apply(    @Nullable RunRecord input){
      if (input == null) {
        return false;
      }
      String runId=input.getPid();
      return !runIdToRuntimeInfo.containsKey(RunIds.fromString(runId));
    }
  }
);
  if (!invalidRunRecords.isEmpty()) {
    LOG.warn("String_Node_Str",invalidRunRecords.size());
  }
  for (  RunRecord rr : invalidRunRecords) {
    boolean shouldCorrect=shouldCorrectForWorkflowChildren(rr,processedInvalidRunRecordIds);
    if (!shouldCorrect) {
      continue;
    }
    String runId=rr.getPid();
    Id.Program targetProgramId=retrieveProgramIdForRunRecord(programType,runId);
    if (targetProgramId != null) {
      LOG.warn("String_Node_Str",runId,targetProgramId,programType.getPrettyName());
      store.compareAndSetStatus(targetProgramId,runId,ProgramController.State.ALIVE.getRunStatus(),ProgramController.State.ERROR.getRunStatus());
      processedInvalidRunRecordIds.add(runId);
    }
  }
}
Program: 6955
Project: 6955
Buggy source:
@POST @Path("String_Node_Str") public void suspendWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      sendInvalidResponse(responder,id);
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.SUSPENDED) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getMessage());
      return;
    }
    controller.suspend().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void suspendWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      responder.sendString(HttpResponseStatus.NOT_FOUND,String.format("String_Node_Str",runId));
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.SUSPENDED) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_SUSPENDED.getMessage());
      return;
    }
    controller.suspend().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}
Program: 6956
Project: 6956
Buggy source:
@POST @Path("String_Node_Str") public void resumeWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      sendInvalidResponse(responder,id);
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.ALIVE) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getMessage());
      return;
    }
    controller.resume().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") public void resumeWorkflowRun(HttpRequest request,final HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String workflowName,@PathParam("String_Node_Str") String runId){
  try {
    Id.Program id=Id.Program.from(namespaceId,appId,ProgramType.WORKFLOW,workflowName);
    ProgramRuntimeService.RuntimeInfo runtimeInfo=runtimeService.list(id).get(RunIds.fromString(runId));
    if (runtimeInfo == null) {
      responder.sendString(HttpResponseStatus.NOT_FOUND,String.format("String_Node_Str",runId));
      return;
    }
    ProgramController controller=runtimeInfo.getController();
    if (controller.getState() == ProgramController.State.ALIVE) {
      responder.sendString(AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getCode(),AppFabricServiceStatus.PROGRAM_ALREADY_RUNNING.getMessage());
      return;
    }
    controller.resume().get();
    responder.sendString(HttpResponseStatus.OK,"String_Node_Str");
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
  }
}
Program: 6958
Project: 6958
Buggy source:
/** 
 * Will be called by external source to start poll the Kafka messages one at the time.
 * @param emitter instance of {@link Emitter} to emit the messages.
 */
public void pollMessages(Emitter<StructuredRecord> emitter){
  boolean infosUpdated=false;
  for (  KafkaConsumerInfo<OFFSET> info : consumerInfos.values()) {
    Iterator<KafkaMessage<OFFSET>> iterator=readMessages(info);
    while (iterator.hasNext()) {
      KafkaMessage<OFFSET> message=iterator.next();
      processMessage(message,emitter);
      info.setReadOffset(message.getNextOffset());
    }
    if (info.hasPendingChanges()) {
      infosUpdated=true;
    }
  }
  if (infosUpdated) {
    saveReadOffsets(Maps.transformValues(consumerInfos,consumerToOffset));
  }
}

Fixed version (ground truth):
/** 
 * Will be called by external source to start poll the Kafka messages one at the time.
 * @param emitter instance of {@link Emitter} to emit the messages.
 */
public void pollMessages(Emitter<StructuredRecord> emitter){
  if (consumerInfos == null) {
    consumerInfos=createConsumerInfos(kafkaConfigurer.getTopicPartitions());
  }
  boolean infosUpdated=false;
  for (  KafkaConsumerInfo<OFFSET> info : consumerInfos.values()) {
    Iterator<KafkaMessage<OFFSET>> iterator=readMessages(info);
    while (iterator.hasNext()) {
      KafkaMessage<OFFSET> message=iterator.next();
      processMessage(message,emitter);
      info.setReadOffset(message.getNextOffset());
    }
    if (info.hasPendingChanges()) {
      infosUpdated=true;
    }
  }
  if (infosUpdated) {
    saveReadOffsets(Maps.transformValues(consumerInfos,consumerToOffset));
  }
}
Program: 6959
Project: 6959
Buggy source:
/** 
 * <p> The method should be called to initialized the consumer when being used by the   {@code RealtimeSource}</p>
 * @param context
 * @throws Exception
 */
public void initialize(RealtimeContext context) throws Exception {
  sourceContext=context;
  Type superType=TypeToken.of(getClass()).getSupertype(KafkaSimpleApiConsumer.class).getType();
  if (superType instanceof ParameterizedType) {
    Type[] typeArgs=((ParameterizedType)superType).getActualTypeArguments();
    keyDecoder=createKeyDecoder(typeArgs[0]);
    payloadDecoder=createPayloadDecoder(typeArgs[1]);
  }
  DefaultKafkaConfigurer kafkaConfigurer=new DefaultKafkaConfigurer();
  configureKafka(kafkaConfigurer);
  if (kafkaConfigurer.getZookeeper() == null && kafkaConfigurer.getBrokers() == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  kafkaConfig=new KafkaConfig(kafkaConfigurer.getZookeeper(),kafkaConfigurer.getBrokers());
  consumerInfos=createConsumerInfos(kafkaConfigurer.getTopicPartitions());
}

Fixed version (ground truth):
/** 
 * <p> The method should be called to initialized the consumer when being used by the   {@code RealtimeSource}</p>
 * @param context
 * @throws Exception
 */
public void initialize(RealtimeContext context) throws Exception {
  sourceContext=context;
  Type superType=TypeToken.of(getClass()).getSupertype(KafkaSimpleApiConsumer.class).getType();
  if (superType instanceof ParameterizedType) {
    Type[] typeArgs=((ParameterizedType)superType).getActualTypeArguments();
    keyDecoder=createKeyDecoder(typeArgs[0]);
    payloadDecoder=createPayloadDecoder(typeArgs[1]);
  }
  kafkaConfigurer=new DefaultKafkaConfigurer();
  configureKafka(kafkaConfigurer);
  if (kafkaConfigurer.getZookeeper() == null && kafkaConfigurer.getBrokers() == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  kafkaConfig=new KafkaConfig(kafkaConfigurer.getZookeeper(),kafkaConfigurer.getBrokers());
}
Program: 6960
Project: 6960
Buggy source:
@Test public void testKafkaConsumerSimple() throws Exception {
  final String topic="String_Node_Str";
  initializeKafkaSource(topic,PARTITIONS,false);
  int msgCount=5;
  Map<String,String> messages=Maps.newHashMap();
  for (int i=0; i < msgCount; i++) {
    messages.put(Integer.toString(i),"String_Node_Str" + i);
  }
  sendMessage(topic,messages);
  TimeUnit.SECONDS.sleep(2);
  verifyEmittedMessages(kafkaSource,msgCount);
}

Fixed version (ground truth):
@Test public void testKafkaConsumerSimple() throws Exception {
  final String topic="String_Node_Str";
  initializeKafkaSource(topic,PARTITIONS,false);
  int msgCount=5;
  Map<String,String> messages=Maps.newHashMap();
  for (int i=0; i < msgCount; i++) {
    messages.put(Integer.toString(i),"String_Node_Str" + i);
  }
  sendMessage(topic,messages);
  TimeUnit.SECONDS.sleep(2);
  verifyEmittedMessages(kafkaSource,msgCount,new SourceState());
}