nus-yam/ex-repair huggingface dataset:
Program: 6320
Project: 6320
Buggy source:
private void generateLogs(LoggingContext loggingContext,Id.Program id,ProgramRunStatus runStatus) throws InterruptedException {
  String entityId=LoggingContextHelper.getEntityId(loggingContext).getValue();
  RunId runId=null;
  Long stopTs=null;
  for (int i=0; i < MAX; ++i) {
    if (i == 20) {
      runId=RunIds.generate(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    }
 else     if (i == 60 && runStatus != ProgramRunStatus.RUNNING && runStatus != ProgramRunStatus.SUSPENDED) {
      stopTs=getMockTimeSecs(i);
    }
    LoggingEvent event=new LoggingEvent("String_Node_Str",(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME),i % 2 == 0 ? Level.ERROR : Level.WARN,entityId + "String_Node_Str" + i,null,null);
    event.setTimeStamp(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    Map<String,String> tagMap=Maps.newHashMap(Maps.transformValues(loggingContext.getSystemTagsMap(),TAG_TO_STRING_FUNCTION));
    if (runId != null && i % 2 == 0) {
      tagMap.put(ApplicationLoggingContext.TAG_RUNID_ID,runId.getId());
    }
    event.setMDCPropertyMap(tagMap);
    logEvents.add(new LogEvent(event,new LogOffset(i,i)));
  }
  long startTs=RunIds.getTime(runId,TimeUnit.SECONDS);
  if (id != null) {
    runRecordMap.put(id,new RunRecord(runId.getId(),startTs,stopTs,runStatus,null));
    store.setStart(id,runId.getId(),startTs);
    if (stopTs != null) {
      store.setStop(id,runId.getId(),stopTs,runStatus);
    }
  }
}

Fixed version (ground truth):
private void generateLogs(LoggingContext loggingContext,Id.Program id,ProgramRunStatus runStatus) throws InterruptedException {
  String entityId=LoggingContextHelper.getEntityId(loggingContext).getValue();
  RunId runId=null;
  Long stopTs=null;
  for (int i=0; i < MAX; ++i) {
    if (i == 20) {
      runId=RunIds.generate(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    }
 else     if (i == 60 && runStatus != ProgramRunStatus.RUNNING && runStatus != ProgramRunStatus.SUSPENDED) {
      stopTs=getMockTimeSecs(i);
    }
    LoggingEvent event=new LoggingEvent("String_Node_Str",(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME),i % 2 == 0 ? Level.ERROR : Level.WARN,entityId + "String_Node_Str" + i,null,null);
    event.setTimeStamp(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    Map<String,String> tagMap=Maps.newHashMap(Maps.transformValues(loggingContext.getSystemTagsMap(),TAG_TO_STRING_FUNCTION));
    if (runId != null && stopTs == null && i % 2 == 0) {
      tagMap.put(ApplicationLoggingContext.TAG_RUNID_ID,runId.getId());
    }
    event.setMDCPropertyMap(tagMap);
    logEvents.add(new LogEvent(event,new LogOffset(i,i)));
  }
  long startTs=RunIds.getTime(runId,TimeUnit.SECONDS);
  if (id != null) {
    runRecordMap.put(id,new RunRecord(runId.getId(),startTs,stopTs,runStatus,null));
    store.setStart(id,runId.getId(),startTs);
    if (stopTs != null) {
      store.setStop(id,runId.getId(),stopTs,runStatus);
    }
  }
}
Program: 6321
Project: 6321
Buggy source:
/** 
 * If readRange is outside runRecord's range, then the readRange is adjusted to fall within runRecords range.
 */
private ReadRange adjustReadRange(ReadRange readRange,@Nullable RunRecordMeta runRecord){
  if (runRecord == null) {
    return readRange;
  }
  long fromTimeMillis=readRange.getFromMillis();
  long toTimeMillis=readRange.getToMillis();
  long runStartMillis=TimeUnit.SECONDS.toMillis(runRecord.getStartTs());
  if (fromTimeMillis < runStartMillis) {
    fromTimeMillis=runStartMillis;
  }
  if (runRecord.getStopTs() != null) {
    long runStopMillis=TimeUnit.SECONDS.toMillis(runRecord.getStopTs());
    if (toTimeMillis > runStopMillis) {
      toTimeMillis=runStopMillis;
    }
  }
  ReadRange adjusted=new ReadRange(fromTimeMillis,toTimeMillis,readRange.getKafkaOffset());
  LOG.trace("String_Node_Str",readRange,adjusted);
  return adjusted;
}

Fixed version (ground truth):
/** 
 * If readRange is outside runRecord's range, then the readRange is adjusted to fall within runRecords range.
 */
private ReadRange adjustReadRange(ReadRange readRange,@Nullable RunRecordMeta runRecord){
  if (runRecord == null) {
    return readRange;
  }
  long fromTimeMillis=readRange.getFromMillis();
  long toTimeMillis=readRange.getToMillis();
  long runStartMillis=TimeUnit.SECONDS.toMillis(runRecord.getStartTs());
  if (fromTimeMillis < runStartMillis) {
    fromTimeMillis=runStartMillis;
  }
  if (runRecord.getStopTs() != null) {
    long runStopMillis=TimeUnit.SECONDS.toMillis(runRecord.getStopTs() + 1);
    if (toTimeMillis > runStopMillis) {
      toTimeMillis=runStopMillis;
    }
  }
  ReadRange adjusted=new ReadRange(fromTimeMillis,toTimeMillis,readRange.getKafkaOffset());
  LOG.trace("String_Node_Str",readRange,adjusted);
  return adjusted;
}
Program: 6322
Project: 6322
Buggy source:
@Test public void testSystemServices() throws Exception {
  Type token=new TypeToken<List<SystemServiceMeta>>(){
  }
.getType();
  HttpURLConnection urlConn=openURL("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),urlConn.getResponseCode());
  List<SystemServiceMeta> actual=GSON.fromJson(new String(ByteStreams.toByteArray(urlConn.getInputStream()),Charsets.UTF_8),token);
  Assert.assertEquals(8,actual.size());
  urlConn.disconnect();
}

Fixed version (ground truth):
@Test public void testSystemServices() throws Exception {
  Type token=new TypeToken<List<SystemServiceMeta>>(){
  }
.getType();
  HttpURLConnection urlConn=openURL("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),urlConn.getResponseCode());
  List<SystemServiceMeta> actual=GSON.fromJson(new String(ByteStreams.toByteArray(urlConn.getInputStream()),Charsets.UTF_8),token);
  Assert.assertEquals(9,actual.size());
  urlConn.disconnect();
}
Program: 6323
Project: 6323
Buggy source:
@Test public void testSystemServicesStatus() throws Exception {
  Type token=new TypeToken<Map<String,String>>(){
  }
.getType();
  HttpURLConnection urlConn=openURL("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),urlConn.getResponseCode());
  Map<String,String> result=GSON.fromJson(new String(ByteStreams.toByteArray(urlConn.getInputStream()),Charsets.UTF_8),token);
  Assert.assertEquals(8,result.size());
  urlConn.disconnect();
  Assert.assertEquals("String_Node_Str",result.get(Constants.Service.APP_FABRIC_HTTP));
}

Fixed version (ground truth):
@Test public void testSystemServicesStatus() throws Exception {
  Type token=new TypeToken<Map<String,String>>(){
  }
.getType();
  HttpURLConnection urlConn=openURL("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(HttpResponseStatus.OK.getCode(),urlConn.getResponseCode());
  Map<String,String> result=GSON.fromJson(new String(ByteStreams.toByteArray(urlConn.getInputStream()),Charsets.UTF_8),token);
  Assert.assertEquals(9,result.size());
  urlConn.disconnect();
  Assert.assertEquals("String_Node_Str",result.get(Constants.Service.APP_FABRIC_HTTP));
}
Program: 6324
Project: 6324
Buggy source:
private void stopProgramIfRunning(Id.Program programId) throws InterruptedException, ExecutionException {
  ProgramRuntimeService.RuntimeInfo programRunInfo=findRuntimeInfo(programId.getNamespaceId(),programId.getApplicationId(),programId.getId(),programId.getType(),runtimeService);
  if (programRunInfo != null) {
    doStop(programRunInfo);
  }
}

Fixed version (ground truth):
private void stopProgramIfRunning(Id.Program programId) throws InterruptedException, ExecutionException {
  ProgramRuntimeService.RuntimeInfo programRunInfo=findRuntimeInfo(programId,runtimeService);
  if (programRunInfo != null) {
    ProgramController controller=programRunInfo.getController();
    controller.stop().get();
  }
}
Program: 6329
Project: 6329
Buggy source:
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(String namespaceId,String appId,String flowId,ProgramType type,ProgramRuntimeService runtimeService){
  Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos=runtimeService.list(type).values();
  Preconditions.checkNotNull(runtimeInfos,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),namespaceId,flowId);
  Id.Program programId=Id.Program.from(namespaceId,appId,type,flowId);
  for (  ProgramRuntimeService.RuntimeInfo info : runtimeInfos) {
    if (programId.equals(info.getProgramId())) {
      return info;
    }
  }
  return null;
}

Fixed version (ground truth):
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(Id.Program programId,ProgramRuntimeService runtimeService){
  Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos=runtimeService.list(programId.getType()).values();
  Preconditions.checkNotNull(runtimeInfos,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),programId);
  for (  ProgramRuntimeService.RuntimeInfo info : runtimeInfos) {
    if (programId.equals(info.getProgramId())) {
      return info;
    }
  }
  return null;
}
Program: 6330
Project: 6330
Buggy source:
/** 
 * Checks if all schedule requirements are satisfied, then executes the given program without blocking until its completion.
 * @param programId Program Id
 * @param systemOverrides Arguments that would be supplied as system runtime arguments for the program.
 * @return a {@link ListenableFuture} object that completes when the program completes
 * @throws TaskExecutionException if program is already running or program is not found.
 * @throws IOException if program failed to start.
 */
public ListenableFuture<?> run(Id.Program programId,Map<String,String> systemOverrides) throws TaskExecutionException, IOException {
  Map<String,String> userArgs=Maps.newHashMap();
  Map<String,String> systemArgs=Maps.newHashMap();
  String scheduleName=systemOverrides.get(ProgramOptionConstants.SCHEDULE_NAME);
  ApplicationSpecification appSpec=store.getApplication(programId.getApplication());
  if (appSpec == null || appSpec.getSchedules().get(scheduleName) == null) {
    throw new TaskExecutionException(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),false);
  }
  ScheduleSpecification spec=appSpec.getSchedules().get(scheduleName);
  if (!requirementsChecker.checkSatisfied(programId,spec.getSchedule())) {
    return Futures.<Void>immediateFuture(null);
  }
  userArgs.putAll(spec.getProperties());
  userArgs.putAll(propertiesResolver.getUserProperties(programId));
  systemArgs.putAll(propertiesResolver.getSystemProperties(programId));
  systemArgs.putAll(systemOverrides);
  return execute(programId,systemArgs,userArgs);
}

Fixed version (ground truth):
/** 
 * Checks if all schedule requirements are satisfied, then executes the given program without blocking until its completion.
 * @param programId Program Id
 * @param systemOverrides Arguments that would be supplied as system runtime arguments for the program.
 * @return a {@link ListenableFuture} object that completes when the program completes
 * @throws TaskExecutionException if program is already running or program is not found.
 * @throws IOException if program failed to start.
 */
public ListenableFuture<?> run(Id.Program programId,Map<String,String> systemOverrides) throws TaskExecutionException, IOException {
  Map<String,String> userArgs=Maps.newHashMap();
  Map<String,String> systemArgs=Maps.newHashMap();
  String scheduleName=systemOverrides.get(ProgramOptionConstants.SCHEDULE_NAME);
  ApplicationSpecification appSpec=store.getApplication(programId.getApplication());
  if (appSpec == null || appSpec.getSchedules().get(scheduleName) == null) {
    throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),programId),false);
  }
  ScheduleSpecification spec=appSpec.getSchedules().get(scheduleName);
  if (!requirementsChecker.checkSatisfied(programId,spec.getSchedule())) {
    return Futures.<Void>immediateFuture(null);
  }
  userArgs.putAll(spec.getProperties());
  userArgs.putAll(propertiesResolver.getUserProperties(programId));
  systemArgs.putAll(propertiesResolver.getSystemProperties(programId));
  systemArgs.putAll(systemOverrides);
  return execute(programId,systemArgs,userArgs);
}
Program: 6331
Project: 6331
Buggy source:
/** 
 * Executes a program without blocking until its completion.
 * @return a {@link ListenableFuture} object that completes when the program completes
 */
private ListenableFuture<?> execute(final Id.Program id,Map<String,String> sysArgs,Map<String,String> userArgs) throws IOException, TaskExecutionException {
  ProgramRuntimeService.RuntimeInfo runtimeInfo;
  try {
    runtimeInfo=lifecycleService.start(id,sysArgs,userArgs,false);
  }
 catch (  ProgramNotFoundException|ApplicationNotFoundException e) {
    throw new TaskExecutionException(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),e,false);
  }
  final ProgramController controller=runtimeInfo.getController();
  final CountDownLatch latch=new CountDownLatch(1);
  controller.addListener(new AbstractListener(){
    @Override public void init(    ProgramController.State state,    @Nullable Throwable cause){
      if (state == ProgramController.State.COMPLETED) {
        completed();
      }
      if (state == ProgramController.State.ERROR) {
        error(controller.getFailureCause());
      }
    }
    @Override public void killed(){
      latch.countDown();
    }
    @Override public void completed(){
      latch.countDown();
    }
    @Override public void error(    Throwable cause){
      latch.countDown();
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  return executorService.submit(new Callable<Void>(){
    @Override public Void call() throws Exception {
      latch.await();
      return null;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Executes a program without blocking until its completion.
 * @return a {@link ListenableFuture} object that completes when the program completes
 */
private ListenableFuture<?> execute(final Id.Program id,Map<String,String> sysArgs,Map<String,String> userArgs) throws IOException, TaskExecutionException {
  ProgramRuntimeService.RuntimeInfo runtimeInfo;
  try {
    runtimeInfo=lifecycleService.start(id,sysArgs,userArgs,false);
  }
 catch (  ProgramNotFoundException|ApplicationNotFoundException e) {
    throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),id),e,false);
  }
  final ProgramController controller=runtimeInfo.getController();
  final CountDownLatch latch=new CountDownLatch(1);
  controller.addListener(new AbstractListener(){
    @Override public void init(    ProgramController.State state,    @Nullable Throwable cause){
      if (state == ProgramController.State.COMPLETED) {
        completed();
      }
      if (state == ProgramController.State.ERROR) {
        error(controller.getFailureCause());
      }
    }
    @Override public void killed(){
      latch.countDown();
    }
    @Override public void completed(){
      latch.countDown();
    }
    @Override public void error(    Throwable cause){
      latch.countDown();
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  return executorService.submit(new Callable<Void>(){
    @Override public Void call() throws Exception {
      latch.await();
      return null;
    }
  }
);
}
Program: 6332
Project: 6332
Buggy source:
private void doStop(ProgramRuntimeService.RuntimeInfo runtimeInfo) throws ExecutionException, InterruptedException {
  Preconditions.checkNotNull(runtimeInfo,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND));
  ProgramController controller=runtimeInfo.getController();
  controller.stop().get();
}

Fixed version (ground truth):
private void doStop(ProgramRuntimeService.RuntimeInfo runtimeInfo,Id.Program programId) throws ExecutionException, InterruptedException {
  Preconditions.checkNotNull(runtimeInfo,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),programId);
  ProgramController controller=runtimeInfo.getController();
  controller.stop().get();
}
Program: 6333
Project: 6333
Buggy source:
private void stopProgramIfRunning(Id.Program programId) throws InterruptedException, ExecutionException {
  ProgramRuntimeService.RuntimeInfo programRunInfo=findRuntimeInfo(programId.getNamespaceId(),programId.getApplicationId(),programId.getId(),programId.getType(),runtimeService);
  if (programRunInfo != null) {
    doStop(programRunInfo);
  }
}

Fixed version (ground truth):
private void stopProgramIfRunning(Id.Program programId) throws InterruptedException, ExecutionException {
  ProgramRuntimeService.RuntimeInfo programRunInfo=findRuntimeInfo(programId,runtimeService);
  if (programRunInfo != null) {
    doStop(programRunInfo,programId);
  }
}
Program: 6338
Project: 6338
Buggy source:
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(String namespaceId,String appId,String flowId,ProgramType type,ProgramRuntimeService runtimeService){
  Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos=runtimeService.list(type).values();
  Preconditions.checkNotNull(runtimeInfos,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),namespaceId,flowId);
  Id.Program programId=Id.Program.from(namespaceId,appId,type,flowId);
  for (  ProgramRuntimeService.RuntimeInfo info : runtimeInfos) {
    if (programId.equals(info.getProgramId())) {
      return info;
    }
  }
  return null;
}

Fixed version (ground truth):
protected ProgramRuntimeService.RuntimeInfo findRuntimeInfo(Id.Program programId,ProgramRuntimeService runtimeService){
  Collection<ProgramRuntimeService.RuntimeInfo> runtimeInfos=runtimeService.list(programId.getType()).values();
  Preconditions.checkNotNull(runtimeInfos,UserMessages.getMessage(UserErrors.RUNTIME_INFO_NOT_FOUND),programId);
  for (  ProgramRuntimeService.RuntimeInfo info : runtimeInfos) {
    if (programId.equals(info.getProgramId())) {
      return info;
    }
  }
  return null;
}
Program: 6339
Project: 6339
Buggy source:
/** 
 * Checks if all schedule requirements are satisfied, then executes the given program without blocking until its completion.
 * @param programId Program Id
 * @param systemOverrides Arguments that would be supplied as system runtime arguments for the program.
 * @return a {@link ListenableFuture} object that completes when the program completes
 * @throws TaskExecutionException if program is already running or program is not found.
 * @throws IOException if program failed to start.
 */
public ListenableFuture<?> run(Id.Program programId,Map<String,String> systemOverrides) throws TaskExecutionException, IOException {
  Map<String,String> userArgs=Maps.newHashMap();
  Map<String,String> systemArgs=Maps.newHashMap();
  String scheduleName=systemOverrides.get(ProgramOptionConstants.SCHEDULE_NAME);
  ApplicationSpecification appSpec=store.getApplication(programId.getApplication());
  if (appSpec == null || appSpec.getSchedules().get(scheduleName) == null) {
    throw new TaskExecutionException(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),false);
  }
  ScheduleSpecification spec=appSpec.getSchedules().get(scheduleName);
  if (!requirementsChecker.checkSatisfied(programId,spec.getSchedule())) {
    return Futures.<Void>immediateFuture(null);
  }
  userArgs.putAll(spec.getProperties());
  userArgs.putAll(propertiesResolver.getUserProperties(programId));
  systemArgs.putAll(propertiesResolver.getSystemProperties(programId));
  systemArgs.putAll(systemOverrides);
  return execute(programId,systemArgs,userArgs);
}

Fixed version (ground truth):
/** 
 * Checks if all schedule requirements are satisfied, then executes the given program without blocking until its completion.
 * @param programId Program Id
 * @param systemOverrides Arguments that would be supplied as system runtime arguments for the program.
 * @return a {@link ListenableFuture} object that completes when the program completes
 * @throws TaskExecutionException if program is already running or program is not found.
 * @throws IOException if program failed to start.
 */
public ListenableFuture<?> run(Id.Program programId,Map<String,String> systemOverrides) throws TaskExecutionException, IOException {
  Map<String,String> userArgs=Maps.newHashMap();
  Map<String,String> systemArgs=Maps.newHashMap();
  String scheduleName=systemOverrides.get(ProgramOptionConstants.SCHEDULE_NAME);
  ApplicationSpecification appSpec=store.getApplication(programId.getApplication());
  if (appSpec == null || appSpec.getSchedules().get(scheduleName) == null) {
    throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),programId),false);
  }
  ScheduleSpecification spec=appSpec.getSchedules().get(scheduleName);
  if (!requirementsChecker.checkSatisfied(programId,spec.getSchedule())) {
    return Futures.<Void>immediateFuture(null);
  }
  userArgs.putAll(spec.getProperties());
  userArgs.putAll(propertiesResolver.getUserProperties(programId));
  systemArgs.putAll(propertiesResolver.getSystemProperties(programId));
  systemArgs.putAll(systemOverrides);
  return execute(programId,systemArgs,userArgs);
}
Program: 6340
Project: 6340
Buggy source:
/** 
 * Executes a program without blocking until its completion.
 * @return a {@link ListenableFuture} object that completes when the program completes
 */
private ListenableFuture<?> execute(final Id.Program id,Map<String,String> sysArgs,Map<String,String> userArgs) throws IOException, TaskExecutionException {
  ProgramRuntimeService.RuntimeInfo runtimeInfo;
  try {
    runtimeInfo=lifecycleService.start(id,sysArgs,userArgs,false);
  }
 catch (  ProgramNotFoundException|ApplicationNotFoundException e) {
    throw new TaskExecutionException(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),e,false);
  }
  final ProgramController controller=runtimeInfo.getController();
  final CountDownLatch latch=new CountDownLatch(1);
  controller.addListener(new AbstractListener(){
    @Override public void init(    ProgramController.State state,    @Nullable Throwable cause){
      if (state == ProgramController.State.COMPLETED) {
        completed();
      }
      if (state == ProgramController.State.ERROR) {
        error(controller.getFailureCause());
      }
    }
    @Override public void killed(){
      latch.countDown();
    }
    @Override public void completed(){
      latch.countDown();
    }
    @Override public void error(    Throwable cause){
      latch.countDown();
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  return executorService.submit(new Callable<Void>(){
    @Override public Void call() throws Exception {
      latch.await();
      return null;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Executes a program without blocking until its completion.
 * @return a {@link ListenableFuture} object that completes when the program completes
 */
private ListenableFuture<?> execute(final Id.Program id,Map<String,String> sysArgs,Map<String,String> userArgs) throws IOException, TaskExecutionException {
  ProgramRuntimeService.RuntimeInfo runtimeInfo;
  try {
    runtimeInfo=lifecycleService.start(id,sysArgs,userArgs,false);
  }
 catch (  ProgramNotFoundException|ApplicationNotFoundException e) {
    throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND),id),e,false);
  }
  final ProgramController controller=runtimeInfo.getController();
  final CountDownLatch latch=new CountDownLatch(1);
  controller.addListener(new AbstractListener(){
    @Override public void init(    ProgramController.State state,    @Nullable Throwable cause){
      if (state == ProgramController.State.COMPLETED) {
        completed();
      }
      if (state == ProgramController.State.ERROR) {
        error(controller.getFailureCause());
      }
    }
    @Override public void killed(){
      latch.countDown();
    }
    @Override public void completed(){
      latch.countDown();
    }
    @Override public void error(    Throwable cause){
      latch.countDown();
    }
  }
,Threads.SAME_THREAD_EXECUTOR);
  return executorService.submit(new Callable<Void>(){
    @Override public Void call() throws Exception {
      latch.await();
      return null;
    }
  }
);
}
Program: 6341
Project: 6341
Buggy source:
/** 
 * Deletes a dataset instance, which also deletes the data owned by it.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @throws Exception
 */
@DELETE @Path("String_Node_Str") public void drop(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  LOG.info("String_Node_Str",namespaceId,name);
  Id.DatasetInstance instance=Id.DatasetInstance.from(namespaceId,name);
  instanceService.drop(instance);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
/** 
 * Deletes a dataset instance, which also deletes the data owned by it.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @throws Exception
 */
@DELETE @Path("String_Node_Str") public void drop(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  Id.DatasetInstance instance=ConversionHelpers.toDatasetInstanceId(namespaceId,name);
  instanceService.drop(instance);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 6342
Project: 6342
Buggy source:
/** 
 * Updates an existing dataset specification properties.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @throws Exception
 */
@PUT @Path("String_Node_Str") public void update(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  Id.DatasetInstance instance=Id.DatasetInstance.from(namespaceId,name);
  Map<String,String> properties=getProperties(request);
  LOG.info("String_Node_Str",name,GSON.toJson(properties));
  instanceService.update(instance,properties);
  responder.sendStatus(HttpResponseStatus.OK);
}

Fixed version (ground truth):
/** 
 * Updates an existing dataset specification properties.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @throws Exception
 */
@PUT @Path("String_Node_Str") public void update(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  Id.DatasetInstance instance=ConversionHelpers.toDatasetInstanceId(namespaceId,name);
  Map<String,String> properties=ConversionHelpers.getProperties(request);
  instanceService.update(instance,properties);
  responder.sendStatus(HttpResponseStatus.OK);
}
Program: 6343
Project: 6343
Buggy source:
/** 
 * Executes an admin operation on a dataset instance.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @param method the admin operation to execute (e.g. "exists", "truncate", "upgrade")
 * @throws Exception
 */
@POST @Path("String_Node_Str") public void executeAdmin(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name,@PathParam("String_Node_Str") String method) throws Exception {
  Id.DatasetInstance instance=Id.DatasetInstance.from(namespaceId,name);
  try {
    DatasetAdminOpResponse response=instanceService.executeAdmin(instance,method);
    responder.sendJson(HttpResponseStatus.OK,response);
  }
 catch (  HandlerException e) {
    responder.sendStatus(e.getFailureStatus());
  }
}

Fixed version (ground truth):
/** 
 * Executes an admin operation on a dataset instance.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @param method the admin operation to execute (e.g. "exists", "truncate", "upgrade")
 * @throws Exception
 */
@POST @Path("String_Node_Str") public void executeAdmin(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name,@PathParam("String_Node_Str") String method) throws Exception {
  Id.DatasetInstance instance=ConversionHelpers.toDatasetInstanceId(namespaceId,name);
  try {
    DatasetAdminOpResponse response=instanceService.executeAdmin(instance,method);
    responder.sendJson(HttpResponseStatus.OK,response);
  }
 catch (  HandlerException e) {
    responder.sendStatus(e.getFailureStatus());
  }
}
Program: 6344
Project: 6344
Buggy source:
@GET @Path("String_Node_Str") public void list(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId) throws Exception {
  responder.sendJson(HttpResponseStatus.OK,spec2Summary(instanceService.list(Id.Namespace.from(namespaceId))));
}

Fixed version (ground truth):
@GET @Path("String_Node_Str") public void list(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId) throws Exception {
  responder.sendJson(HttpResponseStatus.OK,ConversionHelpers.spec2Summary(instanceService.list(ConversionHelpers.toNamespaceId(namespaceId))));
}
Program: 6345
Project: 6345
Buggy source:
/** 
 * Gets the   {@link DatasetMeta} for a dataset instance.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @param owners a list of owners of the dataset instance, in the form @{code <type>::<id>}(e.g. "program::namespace:default/application:PurchaseHistory/program:flow:PurchaseFlow")
 * @throws Exception if the dataset instance was not found
 */
@GET @Path("String_Node_Str") public void get(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name,@QueryParam("String_Node_Str") List<String> owners) throws Exception {
  Id.DatasetInstance instance=Id.DatasetInstance.from(namespaceId,name);
  responder.sendJson(HttpResponseStatus.OK,instanceService.get(instance,strings2Ids(owners)),DatasetMeta.class,GSON);
}

Fixed version (ground truth):
/** 
 * Gets the   {@link DatasetMeta} for a dataset instance.
 * @param namespaceId namespace of the dataset instance
 * @param name name of the dataset instance
 * @param owners a list of owners of the dataset instance, in the form @{code <type>::<id>}(e.g. "program::namespace:default/application:PurchaseHistory/program:flow:PurchaseFlow")
 * @throws Exception if the dataset instance was not found
 */
@GET @Path("String_Node_Str") public void get(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name,@QueryParam("String_Node_Str") List<String> owners) throws Exception {
  responder.sendJson(HttpResponseStatus.OK,instanceService.get(ConversionHelpers.toDatasetInstanceId(namespaceId,name),ConversionHelpers.strings2ProgramIds(owners)),DatasetMeta.class);
}
Program: 6346
Project: 6346
Buggy source:
/** 
 * Creates a new dataset instance.
 * @param namespaceId namespace of the new dataset instance
 * @param name name of the new dataset instance
 */
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  DatasetInstanceConfiguration creationProperties=getInstanceConfiguration(request);
  Id.Namespace namespace=Id.Namespace.from(namespaceId);
  LOG.info("String_Node_Str",namespaceId,name,creationProperties.getTypeName(),creationProperties.getProperties());
  try {
    instanceService.create(namespace,name,creationProperties);
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  DatasetAlreadyExistsException e) {
    responder.sendString(HttpResponseStatus.CONFLICT,e.getMessage());
  }
catch (  DatasetTypeNotFoundException e) {
    responder.sendString(HttpResponseStatus.NOT_FOUND,e.getMessage());
  }
catch (  HandlerException e) {
    responder.sendString(e.getFailureStatus(),e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new dataset instance.
 * @param namespaceId namespace of the new dataset instance
 * @param name name of the new dataset instance
 */
@PUT @Path("String_Node_Str") public void create(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String name) throws Exception {
  DatasetInstanceConfiguration creationProperties=ConversionHelpers.getInstanceConfiguration(request);
  try {
    instanceService.create(namespaceId,name,creationProperties);
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  DatasetAlreadyExistsException e) {
    responder.sendString(HttpResponseStatus.CONFLICT,e.getMessage());
  }
catch (  DatasetTypeNotFoundException e) {
    responder.sendString(HttpResponseStatus.NOT_FOUND,e.getMessage());
  }
catch (  HandlerException e) {
    responder.sendString(e.getFailureStatus(),e.getMessage());
  }
}
Program: 6347
Project: 6347
Buggy source:
@Test public void testThatDatasetsStayInTransaction() throws TransactionFailureException {
  final AtomicInteger hash=new AtomicInteger();
  Transactions.execute(cache.newTransactionContext(),"String_Node_Str",new Runnable(){
    @Override public void run(){
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str"));
        ds.write();
        hash.set(System.identityHashCode(ds));
        cache.discardDataset(ds);
        ds=cache.getDataset("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str"));
        Assert.assertEquals(hash.get(),System.identityHashCode(ds));
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str"));
        Assert.assertEquals(hash.get(),System.identityHashCode(ds));
        cache.discardDataset(ds);
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
    }
  }
);
  Transactions.execute(cache.newTransactionContext(),"String_Node_Str",new Runnable(){
    @Override public void run(){
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str"));
        Assert.assertEquals("String_Node_Str",ds.read());
        Assert.assertNotEquals(hash.get(),System.identityHashCode(ds));
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
      Assert.assertEquals(1,Iterables.size(cache.getTransactionAwares()) - Iterables.size(cache.getStaticTransactionAwares()));
    }
  }
);
}

Fixed version (ground truth):
@Test public void testThatDatasetsStayInTransaction() throws TransactionFailureException {
  final AtomicReference<Object> ref=new AtomicReference<>();
  Transactions.execute(cache.newTransactionContext(),"String_Node_Str",new Runnable(){
    @Override public void run(){
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",X_ARGUMENTS);
        ds.write();
        cache.discardDataset(ds);
        TestDataset ds2=cache.getDataset("String_Node_Str",X_ARGUMENTS);
        Assert.assertSame(ds,ds2);
        ref.set(ds);
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",X_ARGUMENTS);
        Assert.assertSame(ref.get(),ds);
        cache.discardDataset(ds);
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
    }
  }
);
  Transactions.execute(cache.newTransactionContext(),"String_Node_Str",new Runnable(){
    @Override public void run(){
      try {
        TestDataset ds=cache.getDataset("String_Node_Str",X_ARGUMENTS);
        Assert.assertEquals("String_Node_Str",ds.read());
        Assert.assertNotSame(ref.get(),ds);
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
      Assert.assertEquals(1,Iterables.size(cache.getTransactionAwares()) - Iterables.size(cache.getStaticTransactionAwares()));
    }
  }
);
}
Program: 6348
Project: 6348
Buggy source:
@Override public void run(){
  try {
    TestDataset ds=cache.getDataset("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str"));
    Assert.assertEquals("String_Node_Str",ds.read());
    Assert.assertNotEquals(hash.get(),System.identityHashCode(ds));
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
  Assert.assertEquals(1,Iterables.size(cache.getTransactionAwares()) - Iterables.size(cache.getStaticTransactionAwares()));
}

Fixed version (ground truth):
@Override public void run(){
  try {
    TestDataset ds=cache.getDataset("String_Node_Str",X_ARGUMENTS);
    Assert.assertEquals("String_Node_Str",ds.read());
    Assert.assertNotSame(ref.get(),ds);
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
  Assert.assertEquals(1,Iterables.size(cache.getTransactionAwares()) - Iterables.size(cache.getStaticTransactionAwares()));
}
Program: 6350
Project: 6350
Buggy source:
private Thread createThread(final Map<String,TestDataset> datasetMap){
  return new Thread(){
    @Override public void run(){
      try {
        testDatasetCache(datasetMap);
      }
 catch (      Exception e) {
        throw Throwables.propagate(e);
      }
    }
  }
;
}

Fixed version (ground truth):
private Thread createThread(final Map<String,TestDataset> datasetMap,final AtomicReference<Throwable> ref){
  return new Thread(){
    @Override public void run(){
      try {
        testDatasetCache(datasetMap);
      }
 catch (      Throwable e) {
        ref.set(e);
      }
    }
  }
;
}
Program: 6351
Project: 6351
Buggy source:
@Override public void run(){
  try {
    testDatasetCache(datasetMap);
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    testDatasetCache(datasetMap);
  }
 catch (  Throwable e) {
    ref.set(e);
  }
}
Program: 6352
Project: 6352
Buggy source:
@Test() public void testDatasetCache() throws Exception {
  Map<String,TestDataset> thread1map=new HashMap<>();
  Map<String,TestDataset> thread2map=new HashMap<>();
  Thread thread1=createThread(thread1map);
  Thread thread2=createThread(thread2map);
  thread1.start();
  thread2.start();
  thread1.join();
  thread2.join();
  Assert.assertNotSame(thread1map.get("String_Node_Str"),thread2map.get("String_Node_Str"));
  Assert.assertNotSame(thread1map.get("String_Node_Str"),thread2map.get("String_Node_Str"));
  thread1=thread2=null;
  thread1map=thread2map=null;
  Tasks.waitFor(true,new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      System.gc();
      return ((MultiThreadDatasetCache)cache).getCacheKeys().isEmpty();
    }
  }
,5,TimeUnit.SECONDS,100,TimeUnit.MILLISECONDS);
}

Fixed version (ground truth):
@Test public void testDatasetCache() throws Throwable {
  for (int i=0; i < 25; i++) {
    testDatasetCacheOnce();
  }
}
Program: 6353
Project: 6353
Buggy source:
@Override public boolean commitTx() throws Exception {
  clearSystemProperty("String_Node_Str");
  return super.commitTx();
}

Fixed version (ground truth):
@Override public boolean commitTx() throws Exception {
  currentTx=null;
  return super.commitTx();
}
Program: 6354
Project: 6354
Buggy source:
@Override public boolean rollbackTx() throws Exception {
  clearSystemProperty("String_Node_Str");
  return super.rollbackTx();
}

Fixed version (ground truth):
@Override public boolean rollbackTx() throws Exception {
  currentTx=null;
  return super.rollbackTx();
}
Program: 6355
Project: 6355
Buggy source:
@Override public void startTx(Transaction tx){
  setSystemProperty("String_Node_Str",Long.toString(tx.getWritePointer()));
  super.startTx(tx);
}

Fixed version (ground truth):
@Override public void startTx(Transaction tx){
  currentTx=tx;
  super.startTx(tx);
}
Program: 6356
Project: 6356
Buggy source:
public TestDataset(DatasetSpecification spec,KeyValueTable kv,Map<String,String> args){
  super(spec.getName(),kv);
  this.kvTable=kv;
  this.arguments=ImmutableSortedMap.copyOf(args);
  this.key=arguments.get("String_Node_Str") == null ? "String_Node_Str" : arguments.get("String_Node_Str");
  this.value=arguments.get("String_Node_Str") == null ? "String_Node_Str" : arguments.get("String_Node_Str");
  clearSystemProperty("String_Node_Str");
  clearSystemProperty("String_Node_Str");
}

Fixed version (ground truth):
public TestDataset(DatasetSpecification spec,KeyValueTable kv,Map<String,String> args){
  super(spec.getName(),kv);
  this.kvTable=kv;
  this.arguments=ImmutableSortedMap.copyOf(args);
  this.key=arguments.get("String_Node_Str") == null ? "String_Node_Str" : arguments.get("String_Node_Str");
  this.value=arguments.get("String_Node_Str") == null ? "String_Node_Str" : arguments.get("String_Node_Str");
}
Program: 6357
Project: 6357
Buggy source:
@Override public void close(){
  setSystemProperty("String_Node_Str",Integer.toString(System.identityHashCode(this)));
}

Fixed version (ground truth):
@Override public void close(){
  isClosed=true;
}
Program: 6358
Project: 6358
Buggy source:
private void startHBase() throws Exception {
  getConfiguration().setInt("String_Node_Str",5);
  getConfiguration().setInt("String_Node_Str",10);
  getConfiguration().setInt("String_Node_Str",10);
  getConfiguration().setInt("String_Node_Str",Networks.getRandomPort());
  getConfiguration().setInt("String_Node_Str",Networks.getRandomPort());
  getConfiguration().setInt("String_Node_Str",Networks.getRandomPort());
  getConfiguration().setInt("String_Node_Str",Networks.getRandomPort());
  doStartHBase();
}

Fixed version (ground truth):
private void startHBase() throws Exception {
  getConfiguration().setInt("String_Node_Str",5);
  getConfiguration().setInt("String_Node_Str",10);
  getConfiguration().setInt("String_Node_Str",10);
  getConfiguration().setInt("String_Node_Str",0);
  getConfiguration().setInt("String_Node_Str",0);
  getConfiguration().setInt("String_Node_Str",0);
  getConfiguration().setInt("String_Node_Str",0);
  doStartHBase();
}
Program: 6359
Project: 6359
Buggy source:
public static MDSKey getMDSKey(Id.NamespacedId targetId,MetadataDataset.MetadataType type,@Nullable String key){
  String targetType=KeyHelper.getTargetType(targetId);
  MDSKey.Builder builder=new MDSKey.Builder();
  builder.add(ROW_PREFIX);
  builder.add(targetType);
  KeyHelper.addNamespaceIdToKey(builder,targetId);
  builder.add(type.toString());
  if (key != null) {
    builder.add(key);
  }
  return builder.build();
}

Fixed version (ground truth):
public static MDSKey getMDSKey(Id.NamespacedId targetId,@Nullable MetadataDataset.MetadataType type,@Nullable String key){
  String targetType=KeyHelper.getTargetType(targetId);
  MDSKey.Builder builder=new MDSKey.Builder();
  builder.add(ROW_PREFIX);
  builder.add(targetType);
  KeyHelper.addNamespaceIdToKey(builder,targetId);
  if (type != null) {
    builder.add(type.toString());
  }
  if (key != null) {
    builder.add(key);
  }
  return builder.build();
}
Program: 6360
Project: 6360
Buggy source:
public static Id.NamespacedId getNamespaceIdFromKey(String type,MDSKey key){
  MDSKey.Splitter keySplitter=key.split();
  keySplitter.skipBytes();
  keySplitter.skipString();
  return KeyHelper.getNamespaceIdFromKey(keySplitter,type);
}

Fixed version (ground truth):
public static Id.NamespacedId getNamespaceIdFromKey(String type,byte[] rowKey){
  MDSKey.Splitter keySplitter=new MDSKey(rowKey).split();
  keySplitter.skipBytes();
  keySplitter.skipString();
  return KeyHelper.getNamespaceIdFromKey(keySplitter,type);
}
Program: 6362
Project: 6362
Buggy source:
private MetadataHistoryEntry getSnapshotBeforeTime(Id.NamespacedId targetId,long timeMillis){
  byte[] scanStartKey=MdsHistoryKey.getMdsScanStartKey(targetId,timeMillis).getKey();
  byte[] scanEndKey=MdsHistoryKey.getMdsScanEndKey(targetId).getKey();
  Scanner scanner=indexedTable.scan(scanStartKey,scanEndKey);
  try {
    Row next=scanner.next();
    if (next != null) {
      return GSON.fromJson(next.getString(HISTORY_COLUMN),MetadataHistoryEntry.class);
    }
 else {
      return new MetadataHistoryEntry(targetId);
    }
  }
  finally {
    scanner.close();
  }
}

Fixed version (ground truth):
private Metadata getSnapshotBeforeTime(Id.NamespacedId targetId,long timeMillis){
  byte[] scanStartKey=MdsHistoryKey.getMdsScanStartKey(targetId,timeMillis).getKey();
  byte[] scanEndKey=MdsHistoryKey.getMdsScanEndKey(targetId).getKey();
  Scanner scanner=indexedTable.scan(scanStartKey,scanEndKey);
  try {
    Row next=scanner.next();
    if (next != null) {
      return GSON.fromJson(next.getString(HISTORY_COLUMN),Metadata.class);
    }
 else {
      return new Metadata(targetId);
    }
  }
  finally {
    scanner.close();
  }
}
Program: 6363
Project: 6363
Buggy source:
/** 
 * Snapshots the metadata for the given targetId at the given time.
 * @param targetId target id for which metadata needs snapshotting
 */
private void writeHistory(Id.NamespacedId targetId){
  Map<String,String> properties=getProperties(targetId);
  Set<String> tags=getTags(targetId);
  MetadataHistoryEntry metadataHistoryEntry=new MetadataHistoryEntry(targetId,properties,tags);
  byte[] row=MdsHistoryKey.getMdsKey(targetId,System.currentTimeMillis()).getKey();
  indexedTable.put(row,Bytes.toBytes(HISTORY_COLUMN),Bytes.toBytes(GSON.toJson(metadataHistoryEntry)));
}

Fixed version (ground truth):
/** 
 * Snapshots the metadata for the given targetId at the given time.
 * @param targetId target id for which metadata needs snapshotting
 */
private void writeHistory(Id.NamespacedId targetId){
  Map<String,String> properties=getProperties(targetId);
  Set<String> tags=getTags(targetId);
  Metadata metadata=new Metadata(targetId,properties,tags);
  byte[] row=MdsHistoryKey.getMdsKey(targetId,System.currentTimeMillis()).getKey();
  indexedTable.put(row,Bytes.toBytes(HISTORY_COLUMN),Bytes.toBytes(GSON.toJson(metadata)));
}
Program: 6364
Project: 6364
Buggy source:
@Override public Set<MetadataHistoryEntry> apply(MetadataDataset input) throws Exception {
  return input.getSnapshotBeforeTime(entityIds,timeMillis);
}

Fixed version (ground truth):
@Override public Set<Metadata> apply(MetadataDataset input) throws Exception {
  return input.getSnapshotBeforeTime(entityIds,timeMillis);
}
Program: 6365
Project: 6365
Buggy source:
@Override public Set<MetadataRecord> getSnapshotBeforeTime(MetadataScope scope,final Set<Id.NamespacedId> entityIds,final long timeMillis){
  Set<MetadataHistoryEntry> metadataHistoryEntries=execute(new TransactionExecutor.Function<MetadataDataset,Set<MetadataHistoryEntry>>(){
    @Override public Set<MetadataHistoryEntry> apply(    MetadataDataset input) throws Exception {
      return input.getSnapshotBeforeTime(entityIds,timeMillis);
    }
  }
,scope);
  ImmutableSet.Builder<MetadataRecord> builder=ImmutableSet.builder();
  for (  MetadataHistoryEntry metadataHistoryEntry : metadataHistoryEntries) {
    builder.add(new MetadataRecord(metadataHistoryEntry.getEntityId(),scope,metadataHistoryEntry.getProperties(),metadataHistoryEntry.getTags()));
  }
  return builder.build();
}

Fixed version (ground truth):
@Override public Set<MetadataRecord> getSnapshotBeforeTime(MetadataScope scope,final Set<Id.NamespacedId> entityIds,final long timeMillis){
  Set<Metadata> metadataHistoryEntries=execute(new TransactionExecutor.Function<MetadataDataset,Set<Metadata>>(){
    @Override public Set<Metadata> apply(    MetadataDataset input) throws Exception {
      return input.getSnapshotBeforeTime(entityIds,timeMillis);
    }
  }
,scope);
  ImmutableSet.Builder<MetadataRecord> builder=ImmutableSet.builder();
  for (  Metadata metadata : metadataHistoryEntries) {
    builder.add(new MetadataRecord(metadata.getEntityId(),scope,metadata.getProperties(),metadata.getTags()));
  }
  return builder.build();
}
Program: 6366
Project: 6366
Buggy source:
private void addMetadataHistory(MetadataDataset dataset,MetadataHistoryEntry record){
  for (  Map.Entry<String,String> entry : record.getProperties().entrySet()) {
    dataset.setProperty(record.getEntityId(),entry.getKey(),entry.getValue());
  }
  dataset.addTags(record.getEntityId(),record.getTags().toArray(new String[0]));
}

Fixed version (ground truth):
private void addMetadataHistory(MetadataDataset dataset,Metadata record){
  for (  Map.Entry<String,String> entry : record.getProperties().entrySet()) {
    dataset.setProperty(record.getEntityId(),entry.getKey(),entry.getValue());
  }
  dataset.addTags(record.getEntityId(),record.getTags().toArray(new String[0]));
}