nus-yam/ex-repair huggingface dataset:
Program: 295
Project: 295
Buggy source:
@ReceiveEvent(components=LocationComponent.class,netFilter=RegisterMode.AUTHORITY) public void onAttackRequest(AttackRequest event,EntityRef character,CharacterComponent characterComponent){
  if (event.getItem().exists()) {
    if (!character.equals(event.getItem().getOwner())) {
      return;
    }
  }
  OnItemUseEvent onItemUseEvent=new OnItemUseEvent();
  character.send(onItemUseEvent);
  if (!onItemUseEvent.isConsumed()) {
    EntityRef gazeEntity=GazeAuthoritySystem.getGazeEntityForCharacter(character);
    LocationComponent gazeLocation=gazeEntity.getComponent(LocationComponent.class);
    Vector3f direction=gazeLocation.getWorldDirection();
    Vector3f originPos=gazeLocation.getWorldPosition();
    HitResult result=physics.rayTrace(originPos,direction,characterComponent.interactionRange,Sets.newHashSet(character),DEFAULTPHYSICSFILTER);
    if (result.isHit()) {
      result.getEntity().send(new AttackEvent(character,event.getItem()));
    }
  }
}

Fixed version (ground truth):
@ReceiveEvent(components=LocationComponent.class,netFilter=RegisterMode.AUTHORITY) public void onAttackRequest(AttackRequest event,EntityRef character,CharacterComponent characterComponent){
  if (event.getItem().exists()) {
    if (!character.equals(event.getItem().getOwner())) {
      return;
    }
  }
  OnItemUseEvent onItemUseEvent=new OnItemUseEvent();
  character.send(onItemUseEvent);
  if (!onItemUseEvent.isConsumed()) {
    EntityRef gazeEntity=GazeAuthoritySystem.getGazeEntityForCharacter(character);
    LocationComponent gazeLocation=gazeEntity.getComponent(LocationComponent.class);
    Vector3f direction=gazeLocation.getWorldDirection();
    Vector3f originPos=gazeLocation.getWorldPosition();
    if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.RECORDING) {
      directionAndOriginPosRecorderList.getAttackEventDirectionAndOriginPosRecorder().add(direction,originPos);
    }
 else     if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
      Vector3f[] data=directionAndOriginPosRecorderList.getAttackEventDirectionAndOriginPosRecorder().poll();
      direction=data[0];
      originPos=data[1];
    }
    HitResult result=physics.rayTrace(originPos,direction,characterComponent.interactionRange,Sets.newHashSet(character),DEFAULTPHYSICSFILTER);
    if (result.isHit()) {
      result.getEntity().send(new AttackEvent(character,event.getItem()));
    }
  }
}
Program: 297
Project: 297
Buggy source:
/** 
 * returns the class representing the block family based off the registered id.
 * @param uri
 * @return
 */
public Class<? extends BlockFamily> getBlockFamily(String uri){
  if (uri == null || uri.isEmpty()) {
    return SymmetricFamily.class;
  }
  return library.resolve(uri).getType();
}

Fixed version (ground truth):
/** 
 * returns the class representing the block family based off the registered id.
 * @param uri
 * @return
 */
public Class<? extends BlockFamily> getBlockFamily(String uri){
  ClassMetadata<? extends BlockFamily,?> resolved=library.resolve(uri);
  if (uri == null || uri.isEmpty() || resolved == null) {
    logger.error("String_Node_Str",uri);
    return SymmetricFamily.class;
  }
  return resolved.getType();
}
Program: 299
Project: 299
Buggy source:
private void finishReplay(){
  recordedEventStore.popEvents();
  RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
  System.out.println("String_Node_Str" + this.maxTimestampDiff);
  try {
    BufferedWriter writer=new BufferedWriter(new FileWriter(new File("String_Node_Str")));
    writer.write(this.buffer.toString());
    writer.flush();
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void finishReplay(){
  recordedEventStore.popEvents();
  RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
  try {
    BufferedWriter writer=new BufferedWriter(new FileWriter(new File("String_Node_Str")));
    writer.write(this.buffer.toString());
    writer.flush();
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 302
Project: 302
Buggy source:
/** 
 * This constructor initializes the engine by initializing its systems, subsystems and managers. It also verifies that some required systems are up and running after they have been initialized.
 * @param subsystems Typical subsystems lists contain graphics, timer,audio and input subsystems.
 */
public TerasologyEngine(TimeSubsystem timeSubsystem,Collection<EngineSubsystem> subsystems){
  this.rootContext=new ContextImpl();
  rootContext.put(GameEngine.class,this);
  this.timeSubsystem=timeSubsystem;
  RecordAndReplayUtils recordAndReplayUtils=new RecordAndReplayUtils();
  rootContext.put(RecordAndReplayUtils.class,recordAndReplayUtils);
  CoreRegistry.setContext(rootContext);
  this.allSubsystems=Queues.newArrayDeque();
  this.allSubsystems.add(new ConfigurationSubsystem());
  this.allSubsystems.add(timeSubsystem);
  this.allSubsystems.addAll(subsystems);
  this.allSubsystems.add(new ThreadManagerSubsystem());
  this.allSubsystems.add(new MonitoringSubsystem());
  this.allSubsystems.add(new PhysicsSubsystem());
  this.allSubsystems.add(new CommandSubsystem());
  this.allSubsystems.add(new NetworkSubsystem());
  this.allSubsystems.add(new WorldGenerationSubsystem());
  this.allSubsystems.add(new GameSubsystem());
  this.allSubsystems.add(new I18nSubsystem());
  this.allSubsystems.add(new TelemetrySubSystem());
}

Fixed version (ground truth):
/** 
 * This constructor initializes the engine by initializing its systems, subsystems and managers. It also verifies that some required systems are up and running after they have been initialized.
 * @param subsystems Typical subsystems lists contain graphics, timer,audio and input subsystems.
 */
public TerasologyEngine(TimeSubsystem timeSubsystem,Collection<EngineSubsystem> subsystems){
  this.rootContext=new ContextImpl();
  rootContext.put(GameEngine.class,this);
  this.timeSubsystem=timeSubsystem;
  RecordAndReplayUtils recordAndReplayUtils=new RecordAndReplayUtils();
  rootContext.put(RecordAndReplayUtils.class,recordAndReplayUtils);
  CharacterStateEventPositionMap characterStateEventPositionMap=new CharacterStateEventPositionMap();
  rootContext.put(CharacterStateEventPositionMap.class,characterStateEventPositionMap);
  CoreRegistry.setContext(rootContext);
  this.allSubsystems=Queues.newArrayDeque();
  this.allSubsystems.add(new ConfigurationSubsystem());
  this.allSubsystems.add(timeSubsystem);
  this.allSubsystems.addAll(subsystems);
  this.allSubsystems.add(new ThreadManagerSubsystem());
  this.allSubsystems.add(new MonitoringSubsystem());
  this.allSubsystems.add(new PhysicsSubsystem());
  this.allSubsystems.add(new CommandSubsystem());
  this.allSubsystems.add(new NetworkSubsystem());
  this.allSubsystems.add(new WorldGenerationSubsystem());
  this.allSubsystems.add(new GameSubsystem());
  this.allSubsystems.add(new I18nSubsystem());
  this.allSubsystems.add(new TelemetrySubSystem());
}
Program: 304
Project: 304
Buggy source:
@ReceiveEvent(components={CharacterMovementComponent.class,LocationComponent.class,AliveCharacterComponent.class}) public void onPlayerInput(CharacterMoveInputEvent input,EntityRef entity){
  CharacterCollider characterCollider=physics.getCharacterCollider(entity);
  if (characterCollider.isPending()) {
    logger.debug("String_Node_Str");
    return;
  }
  CircularBuffer<CharacterStateEvent> stateBuffer=characterStates.get(entity);
  CharacterStateEvent lastState=stateBuffer.getLast();
  float delta=input.getDelta() + lastState.getTime() - (time.getGameTimeInMs() + MAX_INPUT_OVERFLOW);
  if (delta < 0) {
    CharacterStateEvent newState=stepState(input,lastState,entity);
    stateBuffer.add(newState);
    characterMovementSystemUtility.setToState(entity,newState);
    lastInputEvent.put(entity,input);
  }
 else {
    logger.warn("String_Node_Str",entity,delta);
  }
}

Fixed version (ground truth):
@ReceiveEvent(components={CharacterMovementComponent.class,LocationComponent.class,AliveCharacterComponent.class}) public void onPlayerInput(CharacterMoveInputEvent input,EntityRef entity){
  CharacterCollider characterCollider=physics.getCharacterCollider(entity);
  if (characterCollider.isPending()) {
    logger.debug("String_Node_Str");
    return;
  }
  CircularBuffer<CharacterStateEvent> stateBuffer=characterStates.get(entity);
  CharacterStateEvent lastState=stateBuffer.getLast();
  float delta=input.getDelta() + lastState.getTime() - (time.getGameTimeInMs() + MAX_INPUT_OVERFLOW);
  if (delta < 0) {
    CharacterStateEvent newState=stepState(input,lastState,entity);
    stateBuffer.add(newState);
    if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
      newState.setPosition(characterStateEventPositionMap.get(newState.getSequenceNumber()));
    }
 else     if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.RECORDING) {
      characterStateEventPositionMap.add(newState.getSequenceNumber(),newState.getPosition());
    }
    characterMovementSystemUtility.setToState(entity,newState);
    lastInputEvent.put(entity,input);
  }
 else {
    logger.warn("String_Node_Str",entity,delta);
  }
}
Program: 305
Project: 305
Buggy source:
private void waitForCompletionOfPreviousSave(){
  if (saveTransaction != null && saveTransaction.getResult() == null) {
    if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAY_FINISHED) {
      System.out.println("String_Node_Str");
      recordAndReplayUtils.setShutdownRequested(true);
    }
    saveThreadManager.shutdown(new ShutdownTask(),true);
    saveThreadManager.restart();
  }
  checkSaveTransactionAndClearUpIfItIsDone();
}

Fixed version (ground truth):
private void waitForCompletionOfPreviousSave(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAY_FINISHED) {
    recordAndReplayUtils.setShutdownRequested(true);
  }
  if (saveTransaction != null && saveTransaction.getResult() == null) {
    saveThreadManager.shutdown(new ShutdownTask(),true);
    saveThreadManager.restart();
  }
  checkSaveTransactionAndClearUpIfItIsDone();
}
Program: 308
Project: 308
Buggy source:
/** 
 * Serialize RecordedEvents, EntityIdMap and some RecordAndReplayUtils data.
 */
public void serializeRecordAndReplayData(){
  String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
  serializeRecordedEvents(recordingPath);
  Gson gson=new GsonBuilder().create();
  serializeRefIdMap(gson,recordingPath);
  serializeFileAmount(gson,recordingPath);
}

Fixed version (ground truth):
/** 
 * Serialize RecordedEvents, EntityIdMap and some RecordAndReplayUtils data.
 */
public void serializeRecordAndReplayData(){
  String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
  serializeRecordedEvents(recordingPath);
  Gson gson=new GsonBuilder().create();
  serializeRefIdMap(gson,recordingPath);
  serializeFileAmount(gson,recordingPath);
  serializeCharacterStateEventPositonMap(gson,recordingPath);
}
Program: 309
Project: 309
Buggy source:
/** 
 * Deserialize RecordedEvents, EntityIdMap and some RecordAndReplayUtils data.
 */
public void deserializeRecordAndReplayData(){
  String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
  deserializeRecordedEvents(recordingPath);
  Gson gson=new GsonBuilder().create();
  deserializeRefIdMap(gson,recordingPath);
  deserializeFileAmount(gson,recordingPath);
}

Fixed version (ground truth):
/** 
 * Deserialize RecordedEvents, EntityIdMap and some RecordAndReplayUtils data.
 */
public void deserializeRecordAndReplayData(){
  String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
  deserializeRecordedEvents(recordingPath);
  Gson gson=new GsonBuilder().create();
  deserializeRefIdMap(gson,recordingPath);
  deserializeFileAmount(gson,recordingPath);
  deserializeCharacterStateEventPositonMap(gson,recordingPath);
}
Program: 310
Project: 310
Buggy source:
public RecordAndReplaySerializer(EntityManager manager,RecordedEventStore store,EntityIdMap idMap,RecordAndReplayUtils recordAndReplayUtils){
  this.entityManager=manager;
  this.recordedEventStore=store;
  this.entityIdMap=idMap;
  this.recordAndReplayUtils=recordAndReplayUtils;
}

Fixed version (ground truth):
public RecordAndReplaySerializer(EntityManager manager,RecordedEventStore store,EntityIdMap idMap,RecordAndReplayUtils recordAndReplayUtils,CharacterStateEventPositionMap characterStateEventPositionMap){
  this.entityManager=manager;
  this.recordedEventStore=store;
  this.entityIdMap=idMap;
  this.recordAndReplayUtils=recordAndReplayUtils;
  this.characterStateEventPositionMap=characterStateEventPositionMap;
}
Program: 311
Project: 311
Buggy source:
private void waitForCompletionOfPreviousSave(){
  if (saveTransaction != null && saveTransaction.getResult() == null) {
    saveThreadManager.shutdown(new ShutdownTask(),true);
    saveThreadManager.restart();
  }
  checkSaveTransactionAndClearUpIfItIsDone();
}

Fixed version (ground truth):
private void waitForCompletionOfPreviousSave(){
  if (saveTransaction != null && saveTransaction.getResult() == null) {
    if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAY_FINISHED) {
      System.out.println("String_Node_Str");
      recordAndReplayUtils.setShutdownRequested(true);
    }
    saveThreadManager.shutdown(new ShutdownTask(),true);
    saveThreadManager.restart();
  }
  checkSaveTransactionAndClearUpIfItIsDone();
}
Program: 312
Project: 312
Buggy source:
@Override public void finishSavingAndShutdown(){
  recordAndReplayUtils.setShutdownRequested(true);
  saveThreadManager.shutdown(new ShutdownTask(),true);
  checkSaveTransactionAndClearUpIfItIsDone();
}

Fixed version (ground truth):
@Override public void finishSavingAndShutdown(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.RECORDING) {
    recordAndReplayUtils.setShutdownRequested(true);
  }
  saveThreadManager.shutdown(new ShutdownTask(),true);
  checkSaveTransactionAndClearUpIfItIsDone();
}
Program: 313
Project: 313
Buggy source:
private boolean isReplay(){
  boolean isReplay=false;
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAY_FINISHED || RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    isReplay=true;
    if (recordAndReplayUtils.isShutdownRequested()) {
      RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.NOT_ACTIVATED);
    }
  }
  return isReplay;
}

Fixed version (ground truth):
private boolean isReplay(){
  boolean isReplay=false;
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAY_FINISHED || RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    isReplay=true;
    if (recordAndReplayUtils.isShutdownRequested()) {
      RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.NOT_ACTIVATED);
      recordAndReplayUtils.reset();
    }
  }
  return isReplay;
}
Program: 314
Project: 314
Buggy source:
/** 
 * Processes recorded and pending events. If recordedEvents is not loaded, load it from RecordedEventStore. Processes recorded events for a certain amount of time and only if the timestamp is right.
 */
@Override public void process(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING && !this.areRecordedEventsLoaded) {
    fillRecordedEvents();
    this.areRecordedEventsLoaded=true;
    logger.info("String_Node_Str");
    replayEventsLoadTime=System.currentTimeMillis();
  }
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    processRecordedEvents(1);
    if (this.recordedEvents.isEmpty()) {
      if (recordAndReplayUtils.getFileCount() <= recordAndReplayUtils.getFileAmount()) {
        String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
        recordAndReplaySerializer.deserializeRecordedEvents(recordingPath);
        fillRecordedEvents();
      }
 else {
        recordAndReplayUtils.reset();
        recordedEventStore.popEvents();
        RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
      }
    }
  }
  PendingEvent event=pendingEvents.poll();
  while (event != null) {
    if (event.getComponent() != null) {
      originalSend(event.getEntity(),event.getEvent(),event.getComponent());
    }
 else {
      originalSend(event.getEntity(),event.getEvent());
    }
    event=pendingEvents.poll();
  }
}

Fixed version (ground truth):
/** 
 * Processes recorded and pending events. If recordedEvents is not loaded, load it from RecordedEventStore. Processes recorded events for a certain amount of time and only if the timestamp is right.
 */
@Override public void process(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING && !this.areRecordedEventsLoaded) {
    fillRecordedEvents();
    this.areRecordedEventsLoaded=true;
    logger.info("String_Node_Str");
    replayEventsLoadTime=System.currentTimeMillis();
  }
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    processRecordedEvents(1);
    if (this.recordedEvents.isEmpty()) {
      if (recordAndReplayUtils.getFileCount() <= recordAndReplayUtils.getFileAmount()) {
        String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
        recordAndReplaySerializer.deserializeRecordedEvents(recordingPath);
        fillRecordedEvents();
        this.buffer.append("String_Node_Str");
      }
 else {
        recordedEventStore.popEvents();
        RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
      }
    }
  }
  PendingEvent event=pendingEvents.poll();
  while (event != null) {
    if (event.getComponent() != null) {
      originalSend(event.getEntity(),event.getEvent(),event.getComponent());
    }
 else {
      originalSend(event.getEntity(),event.getEvent());
    }
    event=pendingEvents.poll();
  }
}
Program: 315
Project: 315
Buggy source:
/** 
 * Try to process recorded events for 'maxDuration' miliseconds. Events are only processed if the time is right.
 * @param maxDuration the amount of time in which this method will try to process recorded events in one go.
 */
private void processRecordedEvents(long maxDuration){
  long beginTime=System.currentTimeMillis();
  for (RecordedEvent re=recordedEvents.peek(); re != null; re=recordedEvents.peek()) {
    long passedTime=System.currentTimeMillis() - this.replayEventsLoadTime;
    while (passedTime < re.getTimestamp()) {
      passedTime=System.currentTimeMillis() - this.replayEventsLoadTime;
      if ((System.currentTimeMillis() - beginTime) >= maxDuration) {
        return;
      }
    }
    recordedEvents.poll();
    EntityRef entity=getEntityRef(re);
    if (re.getComponent() != null) {
      originalSend(entity,re.getEvent(),re.getComponent());
    }
 else {
      originalSend(entity,re.getEvent());
    }
    if ((System.currentTimeMillis() - beginTime) >= maxDuration) {
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * Try to process recorded events for 'maxDuration' miliseconds. Events are only processed if the time is right.
 * @param maxDuration the amount of time in which this method will try to process recorded events in one go.
 */
private void processRecordedEvents(long maxDuration){
  long beginTime=System.currentTimeMillis();
  for (RecordedEvent re=recordedEvents.peek(); re != null; re=recordedEvents.peek()) {
    long passedTime=System.currentTimeMillis() - this.replayEventsLoadTime;
    while (passedTime < re.getTimestamp()) {
      passedTime=System.currentTimeMillis() - this.replayEventsLoadTime;
      if ((System.currentTimeMillis() - beginTime) >= maxDuration) {
        return;
      }
    }
    recordedEvents.poll();
    EntityRef entity=getEntityRef(re);
    this.buffer.append("String_Node_Str" + re.getTimestamp() + "String_Node_Str"+ passedTime);
    this.buffer.append("String_Node_Str" + (passedTime - re.getTimestamp()) + "String_Node_Str"+ re.getEvent().toString()+ "String_Node_Str");
    if (this.maxTimestampDiff < (passedTime - re.getTimestamp()))     this.maxTimestampDiff=passedTime - re.getTimestamp();
    if (re.getComponent() != null) {
      originalSend(entity,re.getEvent(),re.getComponent());
    }
 else {
      originalSend(entity,re.getEvent());
    }
    if ((System.currentTimeMillis() - beginTime) >= maxDuration) {
      return;
    }
  }
}
Program: 316
Project: 316
Buggy source:
public EventSystemReplayImpl(EventLibrary eventLibrary,NetworkSystem networkSystem,EngineEntityManager entityManager,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils,List<Class<?>> selectedClassesToReplay){
  this.mainThread=Thread.currentThread();
  this.eventLibrary=eventLibrary;
  this.networkSystem=networkSystem;
  this.entityManager=entityManager;
  this.recordedEventStore=recordedEventStore;
  this.entityIdMap=entityIdMap;
  this.recordAndReplaySerializer=recordAndReplaySerializer;
  this.recordAndReplayUtils=recordAndReplayUtils;
  this.selectedClassesToReplay=selectedClassesToReplay;
}

Fixed version (ground truth):
public EventSystemReplayImpl(EventLibrary eventLibrary,NetworkSystem networkSystem,EngineEntityManager entityManager,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils,List<Class<?>> selectedClassesToReplay){
  this.mainThread=Thread.currentThread();
  this.eventLibrary=eventLibrary;
  this.networkSystem=networkSystem;
  this.entityManager=entityManager;
  this.recordedEventStore=recordedEventStore;
  this.entityIdMap=entityIdMap;
  this.recordAndReplaySerializer=recordAndReplaySerializer;
  this.recordAndReplayUtils=recordAndReplayUtils;
  this.selectedClassesToReplay=selectedClassesToReplay;
  this.buffer=new StringBuffer();
}
Program: 317
Project: 317
Buggy source:
public double getTimestamp(){
  return timestamp;
}

Fixed version (ground truth):
public long getTimestamp(){
  return timestamp;
}
Program: 319
Project: 319
Buggy source:
@Test public void testProcessingRecordedEvent(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  eventSystem.process();
  eventSystem.process();
  assertEquals(3,handler.receivedAttackButtonList.size());
}

Fixed version (ground truth):
@Test public void testProcessingRecordedEvent(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  long startTime=System.currentTimeMillis();
  while ((System.currentTimeMillis() - startTime) < 10) {
    eventSystem.process();
  }
  assertEquals(3,handler.receivedAttackButtonList.size());
}
Program: 320
Project: 320
Buggy source:
@Test public void testBlockingEventDuringReplay(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  eventSystem.send(entity,new AttackButton());
  eventSystem.process();
  assertEquals(3,handler.receivedAttackButtonList.size());
}

Fixed version (ground truth):
@Test public void testBlockingEventDuringReplay(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  eventSystem.send(entity,new AttackButton());
  long startTime=System.currentTimeMillis();
  while ((System.currentTimeMillis() - startTime) < 10) {
    eventSystem.process();
  }
  assertEquals(3,handler.receivedAttackButtonList.size());
}
Program: 321
Project: 321
Buggy source:
@Test public void testSendingEventAfterReplay(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  eventSystem.process();
  eventSystem.process();
  eventSystem.send(entity,new AttackButton());
  assertEquals(4,handler.receivedAttackButtonList.size());
}

Fixed version (ground truth):
@Test public void testSendingEventAfterReplay(){
  assertEquals(0,handler.receivedAttackButtonList.size());
  long startTime=System.currentTimeMillis();
  while ((System.currentTimeMillis() - startTime) < 10) {
    eventSystem.process();
  }
  eventSystem.send(entity,new AttackButton());
  assertEquals(4,handler.receivedAttackButtonList.size());
}
Program: 322
Project: 322
Buggy source:
@Test public void testSendingAllowedEventDuringReplay(){
  eventSystem.send(entity,new TestEvent());
  eventSystem.process();
  eventSystem.process();
  assertEquals(3,handler.receivedAttackButtonList.size());
  assertEquals(1,handler.receivedTestEventList.size());
}

Fixed version (ground truth):
@Test public void testSendingAllowedEventDuringReplay(){
  eventSystem.send(entity,new TestEvent());
  long startTime=System.currentTimeMillis();
  while ((System.currentTimeMillis() - startTime) < 10) {
    eventSystem.process();
  }
  assertEquals(3,handler.receivedAttackButtonList.size());
  assertEquals(1,handler.receivedTestEventList.size());
}
Program: 324
Project: 324
Buggy source:
@Test public void testReplayStatus(){
  assertEquals(RecordAndReplayStatus.REPLAYING,RecordAndReplayStatus.getCurrentStatus());
  eventSystem.process();
  eventSystem.process();
  eventSystem.process();
  assertEquals(RecordAndReplayStatus.REPLAY_FINISHED,RecordAndReplayStatus.getCurrentStatus());
}

Fixed version (ground truth):
@Test public void testReplayStatus(){
  assertEquals(RecordAndReplayStatus.REPLAYING,RecordAndReplayStatus.getCurrentStatus());
  long startTime=System.currentTimeMillis();
  while ((System.currentTimeMillis() - startTime) < 10) {
    eventSystem.process();
  }
  assertEquals(RecordAndReplayStatus.REPLAY_FINISHED,RecordAndReplayStatus.getCurrentStatus());
}
Program: 325
Project: 325
Buggy source:
/** 
 * @param entityId Id of the EntityRef which the event was sent against.
 * @param event The event to be recorded.
 * @param component The component that was sent with the event
 * @param timestamp The timestamp in which the event was sent.
 * @param position The position of the RecordedEvent.
 */
RecordedEvent(long entityId,Event event,Component component,double timestamp,long position){
  this.entityId=entityId;
  this.event=event;
  this.component=component;
  this.timestamp=timestamp;
  this.position=position;
}

Fixed version (ground truth):
/** 
 * @param entityId Id of the EntityRef which the event was sent against.
 * @param event The event to be recorded.
 * @param component The component that was sent with the event
 * @param timestamp The timestamp in which the event was sent.
 * @param position The position of the RecordedEvent.
 */
RecordedEvent(long entityId,Event event,Component component,long timestamp,long position){
  this.entityId=entityId;
  this.event=event;
  this.component=component;
  this.timestamp=timestamp;
  this.position=position;
}
Program: 326
Project: 326
Buggy source:
private void inputEventSetup(InputEvent event,JsonObject jsonObject){
  float delta=jsonObject.get("String_Node_Str").getAsFloat();
  boolean consumed=jsonObject.get("String_Node_Str").getAsBoolean();
  EntityRef target=this.entityManager.getEntity(jsonObject.get("String_Node_Str").getAsLong());
  JsonObject aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3f hitNormal=new Vector3f(aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat());
  aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3f hitPosition=new Vector3f(aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat());
  aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3i targetBlockPosition=new Vector3i(aux.get("String_Node_Str").getAsInt(),aux.get("String_Node_Str").getAsInt(),aux.get("String_Node_Str").getAsInt());
  event.setTargetInfo(target,targetBlockPosition,hitPosition,hitNormal);
}

Fixed version (ground truth):
private void inputEventSetup(InputEvent event,JsonObject jsonObject){
  float delta=jsonObject.get("String_Node_Str").getAsFloat();
  boolean consumed=jsonObject.get("String_Node_Str").getAsBoolean();
  EntityRef target=new RecordedEntityRef(jsonObject.get("String_Node_Str").getAsLong(),(LowLevelEntityManager)this.entityManager);
  JsonObject aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3f hitNormal=new Vector3f(aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat());
  aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3f hitPosition=new Vector3f(aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat(),aux.get("String_Node_Str").getAsFloat());
  aux=jsonObject.get("String_Node_Str").getAsJsonObject();
  Vector3i targetBlockPosition=new Vector3i(aux.get("String_Node_Str").getAsInt(),aux.get("String_Node_Str").getAsInt(),aux.get("String_Node_Str").getAsInt());
  event.setTargetInfo(target,targetBlockPosition,hitPosition,hitNormal);
}
Program: 328
Project: 328
Buggy source:
private static EventSystem createEventSystem(NetworkSystem networkSystem,PojoEntityManager entityManager,EntitySystemLibrary library,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils){
  EventSystem eventSystem;
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.PREPARING_REPLAY) {
    eventSystem=new EventSystemReplayImpl(library.getEventLibrary(),networkSystem,entityManager,recordedEventStore,entityIdMap,recordAndReplaySerializer,recordAndReplayUtils);
  }
 else {
    List<Class<?>> selectedClassesToRecord=createSelectedClassesToRecordList();
    EventCatcher eventCatcher=new EventCatcher(selectedClassesToRecord,recordedEventStore);
    eventSystem=new EventSystemImpl(library.getEventLibrary(),networkSystem,eventCatcher);
  }
  return eventSystem;
}

Fixed version (ground truth):
private static EventSystem createEventSystem(NetworkSystem networkSystem,PojoEntityManager entityManager,EntitySystemLibrary library,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils){
  EventSystem eventSystem;
  List<Class<?>> selectedClassesToRecord=createSelectedClassesToRecordList();
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.PREPARING_REPLAY) {
    eventSystem=new EventSystemReplayImpl(library.getEventLibrary(),networkSystem,entityManager,recordedEventStore,entityIdMap,recordAndReplaySerializer,recordAndReplayUtils,selectedClassesToRecord);
  }
 else {
    EventCatcher eventCatcher=new EventCatcher(selectedClassesToRecord,recordedEventStore);
    eventSystem=new EventSystemImpl(library.getEventLibrary(),networkSystem,eventCatcher);
  }
  return eventSystem;
}
Program: 329
Project: 329
Buggy source:
/** 
 * Check if the event is selected to be replayed. If they are, they are only processed through replay and sending them normally won't have any effect. Example: Since MouseWheelEvent is selected to replay, during the replay process if the player moves the mouse wheel, the MouseWheelEvents generated won't be processed, but the ones on the recorded events list will.
 * @param event event to be checked
 * @return if the event is selected to replay
 */
private boolean isSelectedToReplayEvent(Event event){
  return event instanceof PlaySoundEvent || event instanceof BindableButton || event instanceof KeyEvent|| event instanceof BindAxisEvent|| event instanceof CharacterMoveInputEvent|| event instanceof MouseButtonEvent|| event instanceof MouseWheelEvent|| event instanceof MouseAxisEvent;
}

Fixed version (ground truth):
/** 
 * Check if the event is selected to be replayed. If they are, they are only processed through replay and sending them normally won't have any effect. Example: Since MouseWheelEvent is selected to replay, during the replay process if the player moves the mouse wheel, the MouseWheelEvents generated won't be processed, but the ones on the recorded events list will.
 * @param event event to be checked
 * @return if the event is selected to replay
 */
private boolean isSelectedToReplayEvent(Event event){
  boolean selectedToReplay=false;
  for (  Class<?> supportedEventClass : this.selectedClassesToReplay) {
    if (supportedEventClass.isInstance(event)) {
      selectedToReplay=true;
      break;
    }
  }
  return selectedToReplay;
}
Program: 330
Project: 330
Buggy source:
public EventSystemReplayImpl(EventLibrary eventLibrary,NetworkSystem networkSystem,EngineEntityManager entityManager,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils){
  this.mainThread=Thread.currentThread();
  this.eventLibrary=eventLibrary;
  this.networkSystem=networkSystem;
  this.entityManager=entityManager;
  this.recordedEventStore=recordedEventStore;
  this.entityIdMap=entityIdMap;
  this.recordAndReplaySerializer=recordAndReplaySerializer;
  this.recordAndReplayUtils=recordAndReplayUtils;
}

Fixed version (ground truth):
public EventSystemReplayImpl(EventLibrary eventLibrary,NetworkSystem networkSystem,EngineEntityManager entityManager,RecordedEventStore recordedEventStore,EntityIdMap entityIdMap,RecordAndReplaySerializer recordAndReplaySerializer,RecordAndReplayUtils recordAndReplayUtils,List<Class<?>> selectedClassesToReplay){
  this.mainThread=Thread.currentThread();
  this.eventLibrary=eventLibrary;
  this.networkSystem=networkSystem;
  this.entityManager=entityManager;
  this.recordedEventStore=recordedEventStore;
  this.entityIdMap=entityIdMap;
  this.recordAndReplaySerializer=recordAndReplaySerializer;
  this.recordAndReplayUtils=recordAndReplayUtils;
  this.selectedClassesToReplay=selectedClassesToReplay;
}
Program: 331
Project: 331
Buggy source:
@Test public void testSendingAllowedEventDuringReplay(){
  eventSystem.send(entity,new TestEvent());
  eventSystem.process();
  assertEquals(3,handler.receivedAttackButtonList.size());
  assertEquals(1,handler.receivedTestEventList.size());
}

Fixed version (ground truth):
@Test public void testSendingAllowedEventDuringReplay(){
  eventSystem.send(entity,new TestEvent());
  eventSystem.process();
  eventSystem.process();
  assertEquals(3,handler.receivedAttackButtonList.size());
  assertEquals(1,handler.receivedTestEventList.size());
}
Program: 333
Project: 333
Buggy source:
@Test public void testReplayStatus(){
  assertEquals(RecordAndReplayStatus.REPLAYING,RecordAndReplayStatus.getCurrentStatus());
  eventSystem.process();
  eventSystem.process();
  assertEquals(RecordAndReplayStatus.REPLAY_FINISHED,RecordAndReplayStatus.getCurrentStatus());
}

Fixed version (ground truth):
@Test public void testReplayStatus(){
  assertEquals(RecordAndReplayStatus.REPLAYING,RecordAndReplayStatus.getCurrentStatus());
  eventSystem.process();
  eventSystem.process();
  eventSystem.process();
  assertEquals(RecordAndReplayStatus.REPLAY_FINISHED,RecordAndReplayStatus.getCurrentStatus());
}
Program: 334
Project: 334
Buggy source:
/** 
 * Processes recorded and pending events. If recordedEvents is not loaded, load it from RecordedEventStore. Processes recorded events for a certain amount of time and only if the timestamp is right.
 */
@Override public void process(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING && !this.areRecordedEventsLoaded) {
    fillRecordedEvents();
    this.areRecordedEventsLoaded=true;
    logger.info("String_Node_Str");
    replayEventsLoadTime=System.currentTimeMillis();
  }
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    processRecordedEvents(10);
    if (this.recordedEvents.isEmpty()) {
      if (recordAndReplayUtils.getFileCount() <= recordAndReplayUtils.getFileAmount()) {
        String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
        recordAndReplaySerializer.deserializeRecordedEvents(recordingPath);
        fillRecordedEvents();
      }
 else {
        recordAndReplayUtils.reset();
        recordedEventStore.popEvents();
        RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
      }
    }
  }
  PendingEvent event=pendingEvents.poll();
  while (event != null) {
    if (event.getComponent() != null) {
      originalSend(event.getEntity(),event.getEvent(),event.getComponent());
    }
 else {
      originalSend(event.getEntity(),event.getEvent());
    }
    event=pendingEvents.poll();
  }
}

Fixed version (ground truth):
/** 
 * Processes recorded and pending events. If recordedEvents is not loaded, load it from RecordedEventStore. Processes recorded events for a certain amount of time and only if the timestamp is right.
 */
@Override public void process(){
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING && !this.areRecordedEventsLoaded) {
    fillRecordedEvents();
    this.areRecordedEventsLoaded=true;
    logger.info("String_Node_Str");
    replayEventsLoadTime=System.currentTimeMillis();
  }
  if (RecordAndReplayStatus.getCurrentStatus() == RecordAndReplayStatus.REPLAYING) {
    processRecordedEvents(1);
    if (this.recordedEvents.isEmpty()) {
      if (recordAndReplayUtils.getFileCount() <= recordAndReplayUtils.getFileAmount()) {
        String recordingPath=PathManager.getInstance().getRecordingPath(recordAndReplayUtils.getGameTitle()).toString();
        recordAndReplaySerializer.deserializeRecordedEvents(recordingPath);
        fillRecordedEvents();
      }
 else {
        recordAndReplayUtils.reset();
        recordedEventStore.popEvents();
        RecordAndReplayStatus.setCurrentStatus(RecordAndReplayStatus.REPLAY_FINISHED);
      }
    }
  }
  PendingEvent event=pendingEvents.poll();
  while (event != null) {
    if (event.getComponent() != null) {
      originalSend(event.getEntity(),event.getEvent(),event.getComponent());
    }
 else {
      originalSend(event.getEntity(),event.getEvent());
    }
    event=pendingEvents.poll();
  }
}
Program: 335
Project: 335
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + uri.toString() + "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  String familyType="String_Node_Str";
  RegisterBlockFamily registerInfo=this.getClass().getAnnotation(RegisterBlockFamily.class);
  if (registerInfo != null) {
    familyType=registerInfo.value();
  }
  return "String_Node_Str" + familyType + "String_Node_Str"+ uri.toString()+ "String_Node_Str";
}
Program: 336
Project: 336
Buggy source:
@Override public Block getBlockForPlacement(Vector3i location,Side attachmentSide,Side direction){
  if (block == null) {
    if (attachmentSide.isHorizontal()) {
      return blocks.get(attachmentSide);
    }
    if (direction != null) {
      return blocks.get(direction);
    }
 else {
      return blocks.get(Side.FRONT);
    }
  }
  return block;
}

Fixed version (ground truth):
@Override public Block getBlockForPlacement(Vector3i location,Side attachmentSide,Side direction){
  if (archetypeBlock == null) {
    if (attachmentSide.isHorizontal()) {
      return blocks.get(attachmentSide);
    }
    if (direction != null) {
      return blocks.get(direction);
    }
 else {
      return blocks.get(Side.FRONT);
    }
  }
  return archetypeBlock;
}
Program: 337
Project: 337
Buggy source:
@Override public Block getArchetypeBlock(){
  if (block == null) {
    return blocks.get(this.getArchetypeSide());
  }
  return block;
}

Fixed version (ground truth):
@Override public Block getArchetypeBlock(){
  if (archetypeBlock == null) {
    return blocks.get(this.getArchetypeSide());
  }
  return archetypeBlock;
}
Program: 338
Project: 338
Buggy source:
@Override public Iterable<Block> getBlocks(){
  if (block == null) {
    return blocks.values();
  }
  return Arrays.asList(block);
}

Fixed version (ground truth):
@Override public Iterable<Block> getBlocks(){
  if (archetypeBlock == null) {
    return blocks.values();
  }
  return Arrays.asList(archetypeBlock);
}
Program: 339
Project: 339
Buggy source:
@Override public Block getBlockFor(BlockUri blockUri){
  if (block == null && getURI().equals(blockUri.getFamilyUri())) {
    try {
      Side side=Side.valueOf(blockUri.getIdentifier().toString().toUpperCase(Locale.ENGLISH));
      return blocks.get(side);
    }
 catch (    IllegalArgumentException e) {
      logger.error("String_Node_Str",blockUri,e);
      return null;
    }
  }
  return block;
}

Fixed version (ground truth):
@Override public Block getBlockFor(BlockUri blockUri){
  if (archetypeBlock == null && getURI().equals(blockUri.getFamilyUri())) {
    try {
      Side side=Side.valueOf(blockUri.getIdentifier().toString().toUpperCase(Locale.ENGLISH));
      return blocks.get(side);
    }
 catch (    IllegalArgumentException e) {
      logger.error("String_Node_Str",blockUri,e);
      return null;
    }
  }
  return archetypeBlock;
}
Program: 340
Project: 340
Buggy source:
/** 
 * Setup a headless ( = no graphics ) environment
 * @param modules a set of module names that should be loaded (latest version)
 */
public HeadlessEnvironment(Name... modules){
  super(modules);
}

Fixed version (ground truth):
/** 
 * Setup a headless ( = no graphics ) environment
 * @param modules a set of module names that should be loaded (latest version)
 */
HeadlessEnvironment(Name... modules){
  super(modules);
}
Program: 342
Project: 342
Buggy source:
@Override protected void setupStorageManager() throws IOException {
  ModuleManager moduleManager=context.get(ModuleManager.class);
  EngineEntityManager engineEntityManager=context.get(EngineEntityManager.class);
  BlockManager blockManager=context.get(BlockManager.class);
  BiomeManager biomeManager=context.get(BiomeManager.class);
  RecordAndReplaySerializer recordAndReplaySerializer=context.get(RecordAndReplaySerializer.class);
  Path savePath=PathManager.getInstance().getSavePath("String_Node_Str");
  RecordAndReplayUtils recordAndReplayUtils=context.get(RecordAndReplayUtils.class);
  context.put(StorageManager.class,new ReadWriteStorageManager(savePath,moduleManager.getEnvironment(),engineEntityManager,blockManager,biomeManager,recordAndReplaySerializer,recordAndReplayUtils));
}

Fixed version (ground truth):
@Override protected void setupStorageManager() throws IOException {
  ModuleManager moduleManager=context.get(ModuleManager.class);
  EngineEntityManager engineEntityManager=context.get(EngineEntityManager.class);
  BlockManager blockManager=context.get(BlockManager.class);
  BiomeManager biomeManager=context.get(BiomeManager.class);
  RecordAndReplaySerializer recordAndReplaySerializer=context.get(RecordAndReplaySerializer.class);
  Path savePath=PathManager.getInstance().getSavePath("String_Node_Str");
  RecordAndReplayUtils recordAndReplayUtils=new RecordAndReplayUtils();
  context.put(StorageManager.class,new ReadWriteStorageManager(savePath,moduleManager.getEnvironment(),engineEntityManager,blockManager,biomeManager,recordAndReplaySerializer,recordAndReplayUtils));
}
Program: 344
Project: 344
Buggy source:
@BeforeClass public static void setupEnvironment() throws Exception {
  final JavaArchive homeArchive=ShrinkWrap.create(JavaArchive.class);
  final FileSystem vfs=ShrinkWrapFileSystems.newFileSystem(homeArchive);
  PathManager.getInstance().useOverrideHomePath(vfs.getPath("String_Node_Str"));
  env=new HeadlessEnvironment(new Name("String_Node_Str"));
  context=env.getContext();
  assetManager=context.get(AssetManager.class);
  blockManager=context.get(BlockManager.class);
  config=context.get(Config.class);
  audioManager=context.get(AudioManager.class);
  collisionGroupManager=context.get(CollisionGroupManager.class);
  moduleManager=context.get(ModuleManager.class);
}

Fixed version (ground truth):
@BeforeClass public static void setupEnvironment() throws Exception {
  final JavaArchive homeArchive=ShrinkWrap.create(JavaArchive.class);
  final FileSystem vfs=ShrinkWrapFileSystems.newFileSystem(homeArchive);
  PathManager.getInstance().useOverrideHomePath(vfs.getPath("String_Node_Str"));
  env=new HeadlessEnvironment(new Name("String_Node_Str"));
  context=env.getContext();
  moduleManager=context.get(ModuleManager.class);
}
Program: 345
Project: 345
Buggy source:
public void renderUserInterface(){
  PerformanceMonitor.startActivity("String_Node_Str");
  nuiManager.render();
  PerformanceMonitor.endActivity();
}

Fixed version (ground truth):
private void renderUserInterface(){
  PerformanceMonitor.startActivity("String_Node_Str");
  nuiManager.render();
  PerformanceMonitor.endActivity();
}
Program: 346
Project: 346
Buggy source:
public void unpause(){
  pauseGame=false;
}

Fixed version (ground truth):
private void unpause(){
  pauseGame=false;
}
Program: 347
Project: 347
Buggy source:
@Override public void init(GameEngine gameEngine){
  context=gameEngine.createChildContext();
  CoreRegistry.setContext(context);
  EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
  entityManager=context.get(EngineEntityManager.class);
  eventSystem=context.get(EventSystem.class);
  context.put(Console.class,new ConsoleImpl(context));
  NUIManager nuiManager=new NUIManagerInternal(context.get(CanvasRenderer.class),context);
  context.put(NUIManager.class,nuiManager);
  componentSystemManager=new ComponentSystemManager(context);
  context.put(ComponentSystemManager.class,componentSystemManager);
  componentSystemManager.register(new ConsoleSystem(),"String_Node_Str");
  componentSystemManager.register(new CoreCommands(),"String_Node_Str");
  componentSystemManager.register(context.get(InputSystem.class),"String_Node_Str");
  EntityRef localPlayerEntity=entityManager.create(new ClientComponent());
  LocalPlayer localPlayer=new LocalPlayer(context.get(EntityIdMap.class));
  context.put(LocalPlayer.class,localPlayer);
  localPlayer.setClientEntity(localPlayerEntity);
  componentSystemManager.initialise();
  GameManifest gameManifest=null;
  List<GameInfo> savedGames=GameProvider.getSavedGames();
  if (savedGames.size() > 0) {
    gameManifest=savedGames.get(0).getManifest();
  }
 else {
    gameManifest=createGameManifest();
  }
  gameEngine.changeState(new StateLoading(gameManifest,NetworkMode.LISTEN_SERVER));
}

Fixed version (ground truth):
@Override public void init(GameEngine gameEngine){
  context=gameEngine.createChildContext();
  CoreRegistry.setContext(context);
  EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
  entityManager=context.get(EngineEntityManager.class);
  eventSystem=context.get(EventSystem.class);
  context.put(Console.class,new ConsoleImpl(context));
  NUIManager nuiManager=new NUIManagerInternal(context.get(CanvasRenderer.class),context);
  context.put(NUIManager.class,nuiManager);
  componentSystemManager=new ComponentSystemManager(context);
  context.put(ComponentSystemManager.class,componentSystemManager);
  componentSystemManager.register(new ConsoleSystem(),"String_Node_Str");
  componentSystemManager.register(new CoreCommands(),"String_Node_Str");
  componentSystemManager.register(context.get(InputSystem.class),"String_Node_Str");
  EntityRef localPlayerEntity=entityManager.create(new ClientComponent());
  LocalPlayer localPlayer=new LocalPlayer(context.get(EntityIdMap.class));
  context.put(LocalPlayer.class,localPlayer);
  localPlayer.setClientEntity(localPlayerEntity);
  componentSystemManager.initialise();
  GameManifest gameManifest;
  List<GameInfo> savedGames=GameProvider.getSavedGames();
  if (savedGames.size() > 0) {
    gameManifest=savedGames.get(0).getManifest();
  }
 else {
    gameManifest=createGameManifest();
  }
  gameEngine.changeState(new StateLoading(gameManifest,NetworkMode.LISTEN_SERVER));
}
Program: 348
Project: 348
Buggy source:
/** 
 * Events are added to the event library if they have a network annotation
 * @param eventType
 * @return Whether the event should be added to the event library
 */
private boolean shouldAddToLibrary(Class<? extends Event> eventType){
  return eventType.getAnnotation(ServerEvent.class) != null || eventType.getAnnotation(OwnerEvent.class) != null || eventType.getAnnotation(BroadcastEvent.class) != null;
}

Fixed version (ground truth):
/** 
 * Events are added to the event library if they have a network annotation
 * @param eventType the type of the event to be checked
 * @return Whether the event should be added to the event library
 */
private boolean shouldAddToLibrary(Class<? extends Event> eventType){
  return eventType.getAnnotation(ServerEvent.class) != null || eventType.getAnnotation(OwnerEvent.class) != null || eventType.getAnnotation(BroadcastEvent.class) != null;
}