nus-yam/ex-repair huggingface dataset:
Program: 56171
Project: 56171
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  final int SCALE=4;
  int value=partitionsGrid.getPartitionIdAt(x,y);
  return Color.getABGR(((float)(value % SCALE)) / SCALE,((float)((value / SCALE) % SCALE)) / SCALE,((float)((value / SCALE / SCALE) % SCALE)) / SCALE,1);
}
Program: 56172
Project: 56172
Buggy source:
public LandscapeGrid(short width,short height){
  this.width=width;
  this.height=height;
  int tiles=width * height;
  this.heightGrid=new byte[tiles];
  this.landscapeGrid=new byte[tiles];
  this.resourceAmount=new byte[tiles];
  this.resourceType=new byte[tiles];
  this.temporaryFlatened=new byte[tiles];
  this.blockedPartitions=new short[tiles];
  initDebugColors();
  this.flattenedResetter=new FlattenedResetter(this);
  setBackgroundListener(null);
}

Fixed version (ground truth):
public LandscapeGrid(short width,short height){
  this.width=width;
  this.height=height;
  final int tiles=width * height;
  this.heightGrid=new byte[tiles];
  this.landscapeGrid=new byte[tiles];
  this.resourceAmount=new byte[tiles];
  this.resourceType=new byte[tiles];
  this.temporaryFlatened=new byte[tiles];
  this.blockedPartitions=new short[tiles];
  initDebugColors();
  this.flattenedResetter=new FlattenedResetter(this);
  setBackgroundListener(null);
}
Program: 56173
Project: 56173
Buggy source:
public final void setDebugColor(int x,int y,int argb){
  if (CommonConstants.ENABLE_DEBUG_COLORS) {
    debugColors[x + y * width]=argb;
  }
}

Fixed version (ground truth):
@Override public final void setDebugColor(int x,int y,int argb){
  if (CommonConstants.ENABLE_DEBUG_COLORS) {
    debugColors[x + y * width]=argb;
  }
}
Program: 56174
Project: 56174
Buggy source:
@Override public boolean contains(int x,int y){
  return grid.partitionRepresentatives[grid.partitions[x + y * width]] == partition;
}

Fixed version (ground truth):
@Override public boolean contains(int x,int y){
  return partitionRepresentatives[partitions[x + y * width]] == partition;
}
Program: 56175
Project: 56175
Buggy source:
/** 
 * Checks if the given partitions is divided and the both given positions are on separated parts of the partition.
 * @param partition
 * @param pos1
 * @param pos2
 */
private void checkIfDividePartition(Short partition,ShortPoint2D pos1,ShortPoint2D pos2){
  if (partition != NO_PLAYER_PARTITION_ID && !PartitionsDividedTester.isPartitionNotDivided(this,pos1,pos2,partition)) {
    dividePartition(partition,pos1,pos2);
  }
}

Fixed version (ground truth):
/** 
 * Checks if the given partitions is divided and the both given positions are on separated parts of the partition.
 * @param partition
 * @param pos1
 * @param pos2
 */
private void checkIfDividePartition(Short partition,ShortPoint2D pos1,ShortPoint2D pos2){
  if (partition != NO_PLAYER_PARTITION_ID && PartitionsDividedTester.isPartitionDivided(partitionRepresentatives,partitions,width,pos1,pos2,partition)) {
    dividePartition(partition,pos1,pos2);
  }
}
Program: 56176
Project: 56176
Buggy source:
@Override protected MaterialRequestObject getRequestForPrio(int prio){
  DoubleLinkedList<MaterialRequestObject> queue=queues[prio];
  int numberOfElements=queue.size();
  for (int handledElements=0; handledElements < numberOfElements; handledElements++) {
    MaterialRequestObject result=queue.getFront();
    int inDelivery=result.inDelivery;
    int stillNeeded=result.getStillNeeded();
    if (stillNeeded <= 0) {
      result.requestQueue=null;
      queue.popFront();
      numberOfElements--;
    }
 else     if (stillNeeded <= inDelivery || inDelivery >= result.getInDeliveryable()) {
      queue.pushEnd(queue.popFront());
    }
 else {
      if (result.isRoundRobinRequest()) {
        queue.pushEnd(queue.popFront());
      }
      return result;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override protected MaterialRequestObject getRequestForPrio(int prio){
  DoubleLinkedList<MaterialRequestObject> queue=queues[prio];
  int numberOfElements=queue.size();
  for (int handledElements=0; handledElements < numberOfElements; handledElements++) {
    MaterialRequestObject request=queue.getFront();
    int inDelivery=request.inDelivery;
    int stillNeeded=request.getStillNeeded();
    if (stillNeeded <= 0) {
      request.requestQueue=null;
      queue.popFront();
      numberOfElements--;
    }
 else     if (stillNeeded <= inDelivery || inDelivery >= request.getInDeliveryable()) {
      queue.pushEnd(queue.popFront());
    }
 else {
      if (request.isRoundRobinRequest()) {
        queue.pushEnd(queue.popFront());
      }
      return request;
    }
  }
  return null;
}
Program: 56177
Project: 56177
Buggy source:
@Override public void kill(){
  System.out.println("String_Node_Str");
  Timer100Milli.remove(this);
  this.state=STATE_DESTROYED;
  grid.removeBuildingAt(pos);
  grid.getMapObjectsManager().addSelfDeletingMapObject(pos,EMapObjectType.BUILDING_DECONSTRUCTION_SMOKE,BUILDING_DESTRUCTION_SMOKE_DURATION,player);
  placeAdditionalMapObjects(grid,pos,false);
  placeFlag(false);
  allBuildings.remove(this);
  placeReusableMaterials();
  releaseRequestStacks();
  killedEvent();
}

Fixed version (ground truth):
@Override public void kill(){
  System.out.println("String_Node_Str");
  Timer100Milli.remove(this);
  grid.removeBuildingAt(pos);
  grid.getMapObjectsManager().addSelfDeletingMapObject(pos,EMapObjectType.BUILDING_DECONSTRUCTION_SMOKE,BUILDING_DESTRUCTION_SMOKE_DURATION,player);
  placeAdditionalMapObjects(grid,pos,false);
  placeFlag(false);
  allBuildings.remove(this);
  placeReusableMaterials();
  releaseRequestStacks();
  this.state=STATE_DESTROYED;
  killedEvent();
}
Program: 56178
Project: 56178
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getTowerCountAt(x,y) + 1;
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y);
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56179
Project: 56179
Buggy source:
private void goToDiggablePosition(){
  ShortPoint2D diggablePos=getDiggablePosition();
  if (diggablePos != null) {
    if (super.goToPos(diggablePos)) {
      state=EDiggerState.GOING_TO_POS;
      super.getStrategyGrid().setMarked(diggablePos,true);
    }
 else {
      reportAsJobless();
    }
  }
 else {
    reportAsJobless();
  }
}

Fixed version (ground truth):
private void goToDiggablePosition(){
  super.getStrategyGrid().setMarked(super.getPos(),false);
  ShortPoint2D diggablePos=getDiggablePosition();
  if (diggablePos != null) {
    if (super.goToPos(diggablePos)) {
      state=EDiggerState.GOING_TO_POS;
      super.getStrategyGrid().setMarked(diggablePos,true);
    }
 else {
      reportAsJobless();
    }
  }
 else {
    reportAsJobless();
  }
}
Program: 56180
Project: 56180
Buggy source:
private void executeDigg(){
  ShortPoint2D pos=super.getPos();
  super.getStrategyGrid().changeHeightTowards(pos.x,pos.y,requester.getAverageHeight());
  super.getStrategyGrid().setMarked(super.getPos(),false);
}

Fixed version (ground truth):
private void executeDigg(){
  ShortPoint2D pos=super.getPos();
  super.getStrategyGrid().changeHeightTowards(pos.x,pos.y,requester.getAverageHeight());
}
Program: 56181
Project: 56181
Buggy source:
@Override public void receiveHit(float strength,ShortPoint2D attackerPos,byte attackingPlayer){
  NewMovable attacker=getGrid().getMovable(attackerPos);
  if (attacker != null && attacker.getPlayer() == getPlayer()) {
    return;
  }
  if (doorHealth > 0) {
    doorHealth-=strength / Constants.DOOR_HIT_RESISTENCY_FACTOR;
    if (doorHealth <= 0) {
      doorHealth=0;
      inFight=true;
      OccupyingBuilding.this.getGrid().getMapObjectsManager().addSelfDeletingMapObject(getPos(),EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,getPlayer());
      pollNewDefender();
    }
  }
 else   if (currDefender != null) {
    IAttackableMovable movable=currDefender.getSoldier().getMovable();
    movable.receiveHit(strength,attackerPos,attackingPlayer);
    if (movable.getHealth() <= 0) {
      if (occupiers.isEmpty()) {
        currDefender=null;
        changePlayerTo(attackerPos);
      }
 else {
        emptyPlaces.add(currDefender.place);
        searchedSoldiers.add(getSearchType(currDefender.getSoldier().getMovableType()));
        pollNewDefender();
      }
    }
  }
  OccupyingBuilding.this.getPlayer().showMessage(SimpleMessage.attacked(attackingPlayer,attackerPos));
}

Fixed version (ground truth):
@Override public void receiveHit(float strength,ShortPoint2D attackerPos,byte attackingPlayer){
  NewMovable attacker=getGrid().getMovable(attackerPos);
  if (attacker != null && attacker.getPlayer() == getPlayer()) {
    return;
  }
  if (doorHealth > 0) {
    doorHealth-=strength / Constants.DOOR_HIT_RESISTENCY_FACTOR;
    if (doorHealth <= 0) {
      doorHealth=0;
      inFight=true;
      OccupyingBuilding.this.getGrid().getMapObjectsManager().addSelfDeletingMapObject(getPos(),EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,getPlayer());
      pollNewDefender(attackerPos);
    }
  }
 else   if (currDefender != null) {
    IAttackableMovable movable=currDefender.getSoldier().getMovable();
    movable.receiveHit(strength,attackerPos,attackingPlayer);
    if (movable.getHealth() <= 0) {
      emptyPlaces.add(currDefender.place);
      searchedSoldiers.add(getSearchType(currDefender.getSoldier().getMovableType()));
      pollNewDefender(attackerPos);
    }
  }
  OccupyingBuilding.this.getPlayer().showMessage(SimpleMessage.attacked(attackingPlayer,attackerPos));
}
Program: 56182
Project: 56182
Buggy source:
private void pollNewDefender(){
  if (occupiers.isEmpty()) {
    currDefender=null;
  }
 else {
    currDefender=removeSoldier();
    currDefender.getSoldier().setDefendingAt(getPos());
  }
}

Fixed version (ground truth):
private void pollNewDefender(ShortPoint2D attackerPos){
  if (occupiers.isEmpty()) {
    currDefender=null;
    changePlayerTo(attackerPos);
  }
 else {
    currDefender=removeSoldier();
    currDefender.getSoldier().setDefendingAt(getPos());
  }
}
Program: 56183
Project: 56183
Buggy source:
public void movePositionTo(ShortPoint2D position,MaterialsManager newManager){
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    requestQueues[i].moveObjectsOfPositionTo(position,newManager.requestQueues[i]);
  }
}

Fixed version (ground truth):
public void movePositionTo(ShortPoint2D position,MaterialsManager newManager){
  for (int i=0; i < EMaterialType.NUMBER_OF_MATERIALS; i++) {
    requestQueues[i].moveObjectsOfPositionTo(position,newManager.requestQueues[i]);
  }
}
Program: 56184
Project: 56184
Buggy source:
public void mergeInto(MaterialsManager newManager){
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    requestQueues[i].mergeInto(newManager.requestQueues[i]);
  }
}

Fixed version (ground truth):
public void mergeInto(MaterialsManager newManager){
  for (int i=0; i < EMaterialType.NUMBER_OF_MATERIALS; i++) {
    requestQueues[i].mergeInto(newManager.requestQueues[i]);
  }
}
Program: 56185
Project: 56185
Buggy source:
void setOccupyableBuilding(IOccupyableBuilding building);

Fixed version (ground truth):
boolean setOccupyableBuilding(IOccupyableBuilding building);
Program: 56186
Project: 56186
Buggy source:
public final boolean setOccupyableBuilding(IOccupyableBuilding building){
  if (canOccupyBuilding()) {
    ((SoldierStrategy)strategy).setOccupyableBuilding(building);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public final boolean setOccupyableBuilding(IOccupyableBuilding building){
  if (canOccupyBuilding()) {
    return ((SoldierStrategy)strategy).setOccupyableBuilding(building);
  }
 else {
    return false;
  }
}
Program: 56187
Project: 56187
Buggy source:
@Override public void setOccupyableBuilding(IOccupyableBuilding building){
  this.building=building;
  changeStateTo(ESoldierState.INIT_GOTO_TOWER);
  super.abortPath();
  this.oldPathTarget=null;
}

Fixed version (ground truth):
@Override public boolean setOccupyableBuilding(IOccupyableBuilding building){
  if (state != ESoldierState.GOING_TO_TOWER && state != ESoldierState.INIT_GOTO_TOWER) {
    this.building=building;
    changeStateTo(ESoldierState.INIT_GOTO_TOWER);
    super.abortPath();
    this.oldPathTarget=null;
    return true;
  }
 else {
    return false;
  }
}
Program: 56189
Project: 56189
Buggy source:
@Override public void postionClicked(short x,short y){
  System.out.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ partitionsGrid.getPlayerIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getPartitionIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getRealPartitionIdAt(x,y));
}

Fixed version (ground truth):
@Override public void postionClicked(short x,short y){
  System.out.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ partitionsGrid.getPlayerIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getPartitionIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getRealPartitionIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getTowerCountAt(x,y));
}
Program: 56190
Project: 56190
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y);
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56191
Project: 56191
Buggy source:
public void removePositionTo(final int x,final int y,final Partition newPartitionObject){
  if (this == newPartitionObject) {
    System.out.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str");
  }
  this.decrement(x,y);
  newPartitionObject.increment(x,y);
  super.removePositionTo(x,y,newPartitionObject,newPartitionObject.playerId == this.playerId);
  if (isEmpty())   super.stopManager();
}

Fixed version (ground truth):
public void removePositionTo(final int x,final int y,final Partition newPartitionObject){
  if (this == newPartitionObject) {
    System.err.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str");
  }
  this.decrement(x,y);
  newPartitionObject.increment(x,y);
  super.removePositionTo(x,y,newPartitionObject,newPartitionObject.playerId == this.playerId);
  if (isEmpty())   super.stopManager();
}
Program: 56192
Project: 56192
Buggy source:
public void setPartitionAt(int x,int y,short newPartition){
  if (getPartitionIdAt(x,y) != partitionRepresentatives[newPartition]) {
    if (x == 106 && y == 212) {
      System.out.println();
    }
    changePartitionUncheckedAt(x,y,newPartition);
  }
}

Fixed version (ground truth):
public void setPartitionAt(int x,int y,short newPartition){
  if (getPartitionIdAt(x,y) != partitionRepresentatives[newPartition]) {
    if (x == 106 && y == 212) {
      System.out.println();
    }
    byte playerId=changePartitionUncheckedAt(x,y,newPartition);
    notifyPlayerChangedListener(x,y,playerId);
  }
}
Program: 56193
Project: 56193
Buggy source:
/** 
 * Changes the partition at the given position to the given new partition. <br> NOTE: There will be no checks if the new partition exists or if this change divides an other partition or should lead to a merge.
 * @param x x coordinate of the position.
 * @param y y coordinate of the position.
 * @param newPartition The new partition that will be set at the given partition.
 */
void changePartitionUncheckedAt(int x,int y,short newPartition){
  int idx=x + y * width;
  Partition oldPartitionObject=partitionObjects[partitions[idx]];
  Partition newPartitionObject=partitionObjects[newPartition];
  oldPartitionObject.removePositionTo(x,y,newPartitionObject);
synchronized (partitionsWriteLock) {
    partitions[idx]=newPartition;
  }
  if (oldPartitionObject.playerId != newPartitionObject.playerId) {
    playerChangedListener.playerChangedAt(x,y,newPartitionObject.playerId);
  }
}

Fixed version (ground truth):
/** 
 * Changes the partition at the given position to the given new partition. <br> NOTE: There will be no checks if the new partition exists or if this change divides an other partition or should lead to a merge.
 * @param x x coordinate of the position.
 * @param y y coordinate of the position.
 * @param newPartition The new partition that will be set at the given partition.
 * @return the player id of the new partition.
 */
byte changePartitionUncheckedAt(int x,int y,short newPartition){
  int idx=x + y * width;
  Partition oldPartitionObject=partitionObjects[partitions[idx]];
  Partition newPartitionObject=partitionObjects[newPartition];
  oldPartitionObject.removePositionTo(x,y,newPartitionObject);
synchronized (partitionsWriteLock) {
    partitions[idx]=newPartition;
  }
  return newPartitionObject.playerId;
}
Program: 56194
Project: 56194
Buggy source:
public void changePlayerAt(ShortPoint2D position,byte playerId){
  int idx=position.x + position.y * width;
  if (towers[idx] <= 0) {
    short newPartition=createNewPartition(playerId);
    changePartitionUncheckedAt(position.x,position.y,newPartition);
    PartitionsListingBorderVisitor borderVisitor=new PartitionsListingBorderVisitor(this,blockingProvider);
    for (    EDirection currDir : EDirection.values) {
      borderVisitor.visit(currDir.gridDeltaX + position.x,currDir.gridDeltaY + position.y);
    }
    checkMergesAndDividesOnPartitionsList(playerId,newPartition,borderVisitor.getPartitionsList());
  }
}

Fixed version (ground truth):
public void changePlayerAt(ShortPoint2D position,byte playerId){
  int idx=position.x + position.y * width;
  if (towers[idx] <= 0) {
    short newPartition=createNewPartition(playerId);
    changePartitionUncheckedAt(position.x,position.y,newPartition);
    notifyPlayerChangedListener(position.x,position.y,playerId);
    PartitionsListingBorderVisitor borderVisitor=new PartitionsListingBorderVisitor(this,blockingProvider);
    for (    EDirection currDir : EDirection.values) {
      borderVisitor.visit(currDir.gridDeltaX + position.x,currDir.gridDeltaY + position.y);
    }
    checkMergesAndDividesOnPartitionsList(playerId,newPartition,borderVisitor.getPartitionsList());
  }
}
Program: 56195
Project: 56195
Buggy source:
/** 
 * Occupies the given area for the given playerId.
 * @param playerId
 * @param filteredInfluencingArea
 * @param borders
 */
private void occupyArea(final byte playerId,Iterable<ShortPoint2D> influencingArea,SRectangle borders){
  IPredicate<ShortPoint2D> predicate=new IPredicate<ShortPoint2D>(){
    @Override public boolean evaluate(    ShortPoint2D pos){
      int index=pos.x + pos.y * width;
      return towers[index] <= 0 && partitionObjects[partitions[index]].playerId != playerId;
    }
  }
;
  IteratorFilter<ShortPoint2D> filtered=new IteratorFilter<ShortPoint2D>(influencingArea,predicate);
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(filtered,blockingProvider,borders.xMin,borders.yMin,borders.xMax,borders.yMax);
  partitioner.calculatePartitions();
  short[] newPartitionsMap=acquirePartitionedArea(playerId,partitioner);
  checkForMergesAndDivides(playerId,partitioner,newPartitionsMap);
  changeTowerCounter(playerId,influencingArea,+1);
}

Fixed version (ground truth):
/** 
 * Occupies the given area for the given playerId.
 * @param playerId
 * @param filteredInfluencingArea
 * @param borders
 */
private void occupyArea(final byte playerId,Iterable<ShortPoint2D> influencingArea,SRectangle borders){
  IPredicate<ShortPoint2D> predicate=new IPredicate<ShortPoint2D>(){
    @Override public boolean evaluate(    ShortPoint2D pos){
      int index=pos.x + pos.y * width;
      return towers[index] <= 0 && partitionObjects[partitions[index]].playerId != playerId;
    }
  }
;
  Iterable<ShortPoint2D> filtered=new IteratorFilter<ShortPoint2D>(influencingArea,predicate).toList();
  PartitionCalculatorAlgorithm partitioner=new PartitionCalculatorAlgorithm(filtered,blockingProvider,borders.xMin,borders.yMin,borders.xMax,borders.yMax);
  partitioner.calculatePartitions();
  short[] newPartitionsMap=acquirePartitionedArea(playerId,partitioner);
  checkForMergesAndDivides(playerId,partitioner,newPartitionsMap);
  changeTowerCounter(playerId,influencingArea,+1);
  for (  ShortPoint2D curr : filtered) {
    notifyPlayerChangedListener(curr.x,curr.y,playerId);
  }
}
Program: 56197
Project: 56197
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y);
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}
Program: 56199
Project: 56199
Buggy source:
@Override public void postionClicked(short x,short y){
  System.out.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ partitionsGrid.getRealPartitionIdAt(x,y));
}

Fixed version (ground truth):
@Override public void postionClicked(short x,short y){
  System.out.println("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ partitionsGrid.getPlayerIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getPartitionIdAt(x,y)+ "String_Node_Str"+ partitionsGrid.getRealPartitionIdAt(x,y));
}
Program: 56200
Project: 56200
Buggy source:
@Override public final int getDebugColorAt(int x,int y){
  return flagsGrid.isMarked(x,y) ? Color.ORANGE.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.INFORMABLE_MAP_OBJECT) != null ? Color.GREEN.getARGB() : (objectsGrid.getMapObjectAt(x,y,EMapObjectType.ATTACKABLE_TOWER) != null ? Color.RED.getARGB() : (flagsGrid.isBlocked(x,y) ? Color.BLACK.getARGB() : (flagsGrid.isProtected(x,y) ? Color.BLUE.getARGB() : 0))));
}

Fixed version (ground truth):
@Override public final int getDebugColorAt(int x,int y){
  int value=partitionsGrid.getPartitionIdAt(x,y);
  return Color.getABGR((value % 3) * 0.33f,((value / 3) % 3) * 0.33f,((value / 9) % 3) * 0.33f,1);
}
Program: 56201
Project: 56201
Buggy source:
public LinkedList<Tuple<Short,ShortPoint2D>> getPartitionsList(){
  if (partitionsList.size() >= 2 && partitionsList.getFirst().e1.equals(partitionsList.getLast().e1)) {
    partitionsList.removeFirst();
  }
  return partitionsList;
}

Fixed version (ground truth):
public LinkedList<Tuple<Short,ShortPoint2D>> getPartitionsList(){
  LinkedList<Tuple<Short,ShortPoint2D>> resultList=new LinkedList<Tuple<Short,ShortPoint2D>>();
  resultList.addAll(partitionsList);
  if (resultList.size() >= 2 && resultList.getFirst().e1.equals(resultList.getLast().e1)) {
    resultList.removeFirst();
  }
  return resultList;
}
Program: 56202
Project: 56202
Buggy source:
/** 
 * Reads a new file header from the stream.
 * @param stream The stream to read from.
 * @return
 */
public static MapFileHeader readFromStream(InputStream stream) throws IOException {
  try {
    DataInputStream in=new DataInputStream(stream);
    for (    byte b : START_BYTES) {
      if (in.readByte() != b) {
        throw new IOException("String_Node_Str");
      }
    }
    int version=in.readShort();
    if (version < MIN_VERSION) {
      throw new IOException("String_Node_Str");
    }
    String typeStr=in.readUTF();
    MapType type=MapType.valueOf(typeStr);
    String mapName=in.readUTF();
    String mapId=(version == 2) ? in.readUTF() : mapName;
    String baseMapId=(version == 2) ? in.readUTF() : null;
    String description=in.readUTF();
    short width=in.readShort();
    short height=in.readShort();
    short minplayer=in.readShort();
    short maxplayer=in.readShort();
    short[] bgimage=new short[PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE];
    for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
      bgimage[i]=in.readShort();
    }
    ;
    Date date=null;
    if (type == MapType.SAVED_SINGLE) {
      long datetime=in.readLong();
      date=new Date(datetime);
    }
    return new MapFileHeader(type,mapName,mapId,baseMapId,description,width,height,minplayer,maxplayer,date,bgimage);
  }
 catch (  Throwable t) {
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else {
      throw new IOException(t);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reads a new file header from the stream.
 * @param stream The stream to read from.
 * @return
 */
public static MapFileHeader readFromStream(InputStream stream) throws IOException {
  try {
    DataInputStream in=new DataInputStream(stream);
    for (    byte b : START_BYTES) {
      if (in.readByte() != b) {
        throw new IOException("String_Node_Str");
      }
    }
    int version=in.readShort();
    if (version < MIN_VERSION) {
      throw new IOException("String_Node_Str");
    }
    String typeStr=in.readUTF();
    MapType type=MapType.valueOf(typeStr);
    String mapName=in.readUTF();
    String mapId=(version == 2) ? in.readUTF() : mapName;
    String baseMapId=(version == 2) ? in.readUTF() : null;
    String description=in.readUTF();
    short width=in.readShort();
    short height=in.readShort();
    short minplayer=in.readShort();
    short maxplayer=in.readShort();
    short[] bgimage=new short[PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE];
    for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
      bgimage[i]=in.readShort();
    }
    Date date=null;
    if (type == MapType.SAVED_SINGLE) {
      long datetime=in.readLong();
      date=new Date(datetime);
    }
    return new MapFileHeader(type,mapName,mapId,baseMapId,description,width,height,minplayer,maxplayer,date,bgimage);
  }
 catch (  Throwable t) {
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else {
      throw new IOException(t);
    }
  }
}
Program: 56203
Project: 56203
Buggy source:
public void writeTo(OutputStream stream) throws IOException {
  DataOutputStream out=new DataOutputStream(stream);
  out.write(START_BYTES);
  out.writeShort(VERSION);
  out.writeUTF(type.toString());
  out.writeUTF(name);
  out.writeUTF(mapId);
  out.writeUTF(baseMapId);
  out.writeUTF(description);
  out.writeShort(width);
  out.writeShort(height);
  out.writeShort(minPlayer);
  out.writeShort(maxPlayer);
  for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
    out.writeShort(bgimage[i]);
  }
  ;
  if (type == MapType.SAVED_SINGLE) {
    out.writeLong(date.getTime());
  }
}

Fixed version (ground truth):
public void writeTo(OutputStream stream) throws IOException {
  DataOutputStream out=new DataOutputStream(stream);
  out.write(START_BYTES);
  out.writeShort(VERSION);
  out.writeUTF(type.toString());
  out.writeUTF(name);
  out.writeUTF(mapId);
  out.writeUTF(baseMapId == null ? "String_Node_Str" : baseMapId);
  out.writeUTF(description);
  out.writeShort(width);
  out.writeShort(height);
  out.writeShort(minPlayer);
  out.writeShort(maxPlayer);
  for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
    out.writeShort(bgimage[i]);
  }
  ;
  if (type == MapType.SAVED_SINGLE) {
    out.writeLong(date.getTime());
  }
}
Program: 56204
Project: 56204
Buggy source:
/** 
 * Saves a random map to the given file.
 * @param header The header to save
 * @param definition The random map rule text.
 * @throws IOException
 */
public synchronized void saveRandomMap(MapFileHeader header,String definition) throws IOException {
  OutputStream out=getOutputStream(header);
  MapSaver.saveRandomMap(header,definition,out);
  loadFileList();
}

Fixed version (ground truth):
/** 
 * Saves a random map to the given file.
 * @param header The header to save
 * @param definition The random map rule text.
 * @throws IOException
 */
public synchronized void saveRandomMap(MapFileHeader header,String definition) throws IOException {
  OutputStream out=getOutputStream(header,mapsDir);
  MapSaver.saveRandomMap(header,definition,out);
  loadFileList();
}
Program: 56205
Project: 56205
Buggy source:
/** 
 * Gets an output stream that can be used to store the map. The stream is to a file with a nice name and does not override any other file.
 * @param header The header to create the file name from. It is not written to the stream.
 * @return A output stream to a fresh generated file.
 * @throws IOException
 */
private OutputStream getOutputStream(MapFileHeader header) throws IOException {
  String name=header.getName().toLowerCase().replaceAll("String_Node_Str","String_Node_Str");
  if (name.isEmpty()) {
    name="String_Node_Str";
  }
  Date date=header.getDate();
  if (date != null) {
    SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
    name+=format.format(date);
  }
  File file=new File(saveDir,name + MAP_EXTENSION);
  int i=1;
  while (file.exists()) {
    file=new File(saveDir,name + "String_Node_Str" + i+ MAP_EXTENSION);
    i++;
  }
  try {
    return new BufferedOutputStream(new FileOutputStream(file));
  }
 catch (  FileNotFoundException e) {
    throw new IOException(e);
  }
}

Fixed version (ground truth):
/** 
 * Gets an output stream that can be used to store the map. The stream is to a file with a nice name and does not override any other file.
 * @param header The header to create the file name from. It is not written to the stream.
 * @param baseDir The base directory where map should be saved.
 * @return A output stream to a fresh generated file.
 * @throws IOException
 */
private OutputStream getOutputStream(MapFileHeader header,File baseDir) throws IOException {
  String name=header.getName().toLowerCase().replaceAll("String_Node_Str","String_Node_Str");
  if (name.isEmpty()) {
    name="String_Node_Str";
  }
  Date date=header.getDate();
  if (date != null) {
    SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
    name+=format.format(date);
  }
  File file=new File(baseDir,name + MAP_EXTENSION);
  int i=1;
  while (file.exists()) {
    file=new File(baseDir,name + "String_Node_Str" + i+ MAP_EXTENSION);
    i++;
  }
  try {
    return new BufferedOutputStream(new FileOutputStream(file));
  }
 catch (  FileNotFoundException e) {
    throw new IOException(e);
  }
}
Program: 56206
Project: 56206
Buggy source:
/** 
 * Saves a map to disk. The map logic should be paused while calling this method.
 * @param state
 * @param grid
 * @throws IOException
 */
public synchronized void saveMap(UIState state,MainGrid grid) throws IOException {
  MapFileHeader header=grid.generateSaveHeader();
  OutputStream out=getOutputStream(header);
  header.writeTo(out);
  state.writeTo(out);
  GameSerializer gameSerializer=new GameSerializer();
  gameSerializer.save(grid,out);
  loadFileList();
}

Fixed version (ground truth):
/** 
 * Saves a map to disk. The map logic should be paused while calling this method.
 * @param state
 * @param grid
 * @throws IOException
 */
public synchronized void saveMap(UIState state,MainGrid grid) throws IOException {
  MapFileHeader header=grid.generateSaveHeader();
  OutputStream out=getOutputStream(header,saveDir);
  header.writeTo(out);
  state.writeTo(out);
  GameSerializer gameSerializer=new GameSerializer();
  gameSerializer.save(grid,out);
  loadFileList();
}
Program: 56207
Project: 56207
Buggy source:
/** 
 * Creates a new   {@link JSettlersGame} object with an {@link OfflineTaskScheduler}.
 * @param mapCreator
 * @param randomSeed
 * @param playerNumber
 */
public JSettlersGame(IGameCreator mapCreator,long randomSeed,byte playerNumber){
  this(mapCreator,randomSeed,new OfflineTaskScheduler(),playerNumber,false);
}

Fixed version (ground truth):
/** 
 * @param mapCreator
 * @param randomSeed
 * @param playerNumber
 */
public JSettlersGame(IGameCreator mapCreator,long randomSeed,byte playerNumber,File loadableReplayFile){
  this(mapCreator,randomSeed,new OfflineTaskScheduler(),playerNumber,false,loadableReplayFile);
}
Program: 56209
Project: 56209
Buggy source:
protected void save(){
  try {
    MapFileHeader imagedHeader=generateMapHeader();
    data.doPreSaveActions();
    MapList.getDefaultList().saveMap(imagedHeader,data);
  }
 catch (  Throwable e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(saveButton,e.getMessage());
  }
}

Fixed version (ground truth):
protected void save(){
  try {
    MapFileHeader imagedHeader=generateMapHeader();
    data.doPreSaveActions();
    MapList.getDefaultList().saveNewMap(imagedHeader,data);
  }
 catch (  Throwable e) {
    e.printStackTrace();
    JOptionPane.showMessageDialog(saveButton,e.getMessage());
  }
}
Program: 56210
Project: 56210
Buggy source:
/** 
 * Sets the stream to be used to log the actions of the users.
 * @param replayFileStream
 */
void setReplayLogfile(OutputStream replayFileStream);

Fixed version (ground truth):
/** 
 * Sets the stream to be used to log the actions of the users.
 * @param replayFileStream
 */
void setReplayLogfile(DataOutputStream replayFileStream);
Program: 56211
Project: 56211
Buggy source:
@Override public void setReplayLogfile(OutputStream replayFileStream){
  if (replayFileStream != null) {
    replayLogStream=new DataOutputStream(replayFileStream);
  }
 else {
    closeReplayLogStreamIfNeeded();
  }
}

Fixed version (ground truth):
@Override public void setReplayLogfile(DataOutputStream replayFileStream){
  if (replayFileStream != null) {
    replayLogStream=replayFileStream;
  }
 else {
    closeReplayLogStreamIfNeeded();
  }
}
Program: 56212
Project: 56212
Buggy source:
/** 
 * Normalizes the partitions and compacts them.
 */
private void normalizePartitions(){
  short[] compacted=new short[partitions.length + 1];
  compacted[NO_PARTITION]=NO_PARTITION;
  compacted[BLOCKED_PARTITION]=BLOCKED_PARTITION;
  short compactedCount=NUMBER_OF_RESERVED_PARTITIONS;
  for (short i=NUMBER_OF_RESERVED_PARTITIONS; i < nextFreePartition; i++) {
    short representative=i;
    short nextRep;
    while (representative != (nextRep=partitions[representative])) {
      representative=nextRep;
    }
    if (compacted[representative] == 0) {
      compacted[representative]=compactedCount++;
      partitionBorderPositions[compactedCount]=partitionBorderPositions[representative];
    }
    partitions[i]=representative;
    compacted[i]=compacted[representative];
  }
  partitions=compacted;
  neededPartitions=compactedCount;
}

Fixed version (ground truth):
/** 
 * Normalizes the partitions and compacts them.
 */
private void normalizePartitions(){
  short[] compacted=new short[nextFreePartition];
  compacted[NO_PARTITION]=NO_PARTITION;
  compacted[BLOCKED_PARTITION]=BLOCKED_PARTITION;
  short compactedCount=NUMBER_OF_RESERVED_PARTITIONS;
  for (short i=NUMBER_OF_RESERVED_PARTITIONS; i < nextFreePartition; i++) {
    short representative=i;
    short nextRep;
    while (representative != (nextRep=partitions[representative])) {
      representative=nextRep;
    }
    if (compacted[representative] == 0) {
      short newPartitionId=compactedCount++;
      compacted[representative]=newPartitionId;
      partitionBorderPositions[newPartitionId]=partitionBorderPositions[representative];
    }
    partitions[i]=representative;
    compacted[i]=compacted[representative];
  }
  partitions=compacted;
  neededPartitions=compactedCount;
}
Program: 56213
Project: 56213
Buggy source:
private MapFileHeader generateMapHeader(){
  short[] image=new PreviewImageCreator(header.getWidth(),header.getHeight(),MapFileHeader.PREVIEW_IMAGE_SIZE,data.getPreviewImageDataSupplier()).getPreviewImage();
  MapFileHeader imagedHeader=new MapFileHeader(header.getType(),header.getName(),header.getDescription(),header.getWidth(),header.getHeight(),header.getMinPlayer(),header.getMaxPlayer(),new Date(),image);
  return imagedHeader;
}

Fixed version (ground truth):
private MapFileHeader generateMapHeader(){
  short[] image=new PreviewImageCreator(header.getWidth(),header.getHeight(),MapFileHeader.PREVIEW_IMAGE_SIZE,data.getPreviewImageDataSupplier()).getPreviewImage();
  MapFileHeader imagedHeader=new MapFileHeader(header.getType(),header.getName(),header.getBaseMapId(),header.getDescription(),header.getWidth(),header.getHeight(),header.getMinPlayer(),header.getMaxPlayer(),new Date(),image);
  return imagedHeader;
}
Program: 56214
Project: 56214
Buggy source:
public MapFileHeader getHeader(){
  String name=nameField.getText();
  String description=descriptionField.getText();
  short width=this.width.getNumber().shortValue();
  short height=this.height.getNumber().shortValue();
  short minPlayer=this.minPlayer.getNumber().shortValue();
  short maxPlayer=this.maxPlayer.getNumber().shortValue();
  return new MapFileHeader(MapType.NORMAL,name,description,width,height,minPlayer,maxPlayer,new Date(),new short[MapFileHeader.PREVIEW_IMAGE_SIZE * MapFileHeader.PREVIEW_IMAGE_SIZE]);
}

Fixed version (ground truth):
public MapFileHeader getHeader(){
  String name=nameField.getText();
  String description=descriptionField.getText();
  short width=this.width.getNumber().shortValue();
  short height=this.height.getNumber().shortValue();
  short minPlayer=this.minPlayer.getNumber().shortValue();
  short maxPlayer=this.maxPlayer.getNumber().shortValue();
  return new MapFileHeader(MapType.NORMAL,name,null,description,width,height,minPlayer,maxPlayer,new Date(),new short[MapFileHeader.PREVIEW_IMAGE_SIZE * MapFileHeader.PREVIEW_IMAGE_SIZE]);
}
Program: 56215
Project: 56215
Buggy source:
public MapFileHeader generateSaveHeader(){
  PreviewImageCreator previewImageCreator=new PreviewImageCreator(width,height,MapFileHeader.PREVIEW_IMAGE_SIZE,landscapeGrid.getPreviewImageDataSupplier());
  short[] bgImage=previewImageCreator.getPreviewImage();
  return new MapFileHeader(MapType.SAVED_SINGLE,"String_Node_Str","String_Node_Str",width,height,(short)1,(short)1,new Date(),bgImage);
}

Fixed version (ground truth):
public MapFileHeader generateSaveHeader(){
  PreviewImageCreator previewImageCreator=new PreviewImageCreator(width,height,MapFileHeader.PREVIEW_IMAGE_SIZE,landscapeGrid.getPreviewImageDataSupplier());
  short[] bgImage=previewImageCreator.getPreviewImage();
  return new MapFileHeader(MapType.SAVED_SINGLE,mapName,mapId,"String_Node_Str",width,height,(short)1,(short)1,new Date(),bgImage);
}
Program: 56216
Project: 56216
Buggy source:
private MainGrid(IMapData mapGrid,byte players,byte fowPlayer){
  this((short)mapGrid.getWidth(),(short)mapGrid.getHeight(),players,fowPlayer);
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      ELandscapeType landscape=mapGrid.getLandscape(x,y);
      setLandscapeTypeAt(x,y,landscape);
      landscapeGrid.setHeightAt(x,y,mapGrid.getLandscapeHeight(x,y));
      landscapeGrid.setResourceAt(x,y,mapGrid.getResourceType(x,y),mapGrid.getResourceAmount(x,y));
      landscapeGrid.setBlockedPartition(x,y,mapGrid.getBlockedPartition(x,y));
    }
  }
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      MapObject object=mapGrid.getMapObject(x,y);
      if (object != null && isOccupyableBuilding(object)) {
        addMapObject(x,y,object);
      }
      if ((x + y / 2) % 4 == 0 && y % 4 == 0 && isInsideWater(x,y)) {
        mapObjectsManager.addWaves(x,y);
        if (landscapeGrid.getResourceAmountAt(x,y) > 50) {
          mapObjectsManager.addFish(x,y);
        }
      }
    }
  }
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      MapObject object=mapGrid.getMapObject(x,y);
      if (object != null && !isOccupyableBuilding(object)) {
        addMapObject(x,y,object);
      }
    }
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public MainGrid(String mapId,String mapName,IMapData mapGrid,byte players,byte fowPlayer){
  this(mapId,mapName,(short)mapGrid.getWidth(),(short)mapGrid.getHeight(),players,fowPlayer);
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      ELandscapeType landscape=mapGrid.getLandscape(x,y);
      setLandscapeTypeAt(x,y,landscape);
      landscapeGrid.setHeightAt(x,y,mapGrid.getLandscapeHeight(x,y));
      landscapeGrid.setResourceAt(x,y,mapGrid.getResourceType(x,y),mapGrid.getResourceAmount(x,y));
      landscapeGrid.setBlockedPartition(x,y,mapGrid.getBlockedPartition(x,y));
    }
  }
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      MapObject object=mapGrid.getMapObject(x,y);
      if (object != null && isOccupyableBuilding(object)) {
        addMapObject(x,y,object);
      }
      if ((x + y / 2) % 4 == 0 && y % 4 == 0 && isInsideWater(x,y)) {
        mapObjectsManager.addWaves(x,y);
        if (landscapeGrid.getResourceAmountAt(x,y) > 50) {
          mapObjectsManager.addFish(x,y);
        }
      }
    }
  }
  for (short y=0; y < height; y++) {
    for (short x=0; x < width; x++) {
      MapObject object=mapGrid.getMapObject(x,y);
      if (object != null && !isOccupyableBuilding(object)) {
        addMapObject(x,y,object);
      }
    }
  }
  System.out.println("String_Node_Str");
}
Program: 56217
Project: 56217
Buggy source:
/** 
 * Reads a new file header from the stream.
 * @param stream The stream to read from.
 * @return
 */
public static MapFileHeader readFromStream(InputStream stream) throws IOException {
  try {
    DataInputStream in=new DataInputStream(stream);
    for (    byte b : START_BYTES) {
      if (in.readByte() != b) {
        throw new IOException("String_Node_Str");
      }
    }
    int version=in.readShort();
    if (version != ALLOWED_VERSION) {
      throw new IOException("String_Node_Str");
    }
    String typeStr=in.readUTF();
    MapType type=MapType.valueOf(typeStr);
    String name=in.readUTF();
    String description=in.readUTF();
    short width=in.readShort();
    short height=in.readShort();
    short minplayer=in.readShort();
    short maxplayer=in.readShort();
    short[] bgimage=new short[PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE];
    for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
      bgimage[i]=in.readShort();
    }
    ;
    Date date=null;
    if (type == MapType.SAVED_SINGLE) {
      long datetime=in.readLong();
      date=new Date(datetime);
    }
    return new MapFileHeader(type,name,description,width,height,minplayer,maxplayer,date,bgimage);
  }
 catch (  Throwable t) {
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else {
      throw new IOException(t);
    }
  }
}

Fixed version (ground truth):
/** 
 * Reads a new file header from the stream.
 * @param stream The stream to read from.
 * @return
 */
public static MapFileHeader readFromStream(InputStream stream) throws IOException {
  try {
    DataInputStream in=new DataInputStream(stream);
    for (    byte b : START_BYTES) {
      if (in.readByte() != b) {
        throw new IOException("String_Node_Str");
      }
    }
    int version=in.readShort();
    if (version < MIN_VERSION) {
      throw new IOException("String_Node_Str");
    }
    String typeStr=in.readUTF();
    MapType type=MapType.valueOf(typeStr);
    String mapName=in.readUTF();
    String mapId=(version == 2) ? in.readUTF() : mapName;
    String baseMapId=(version == 2) ? in.readUTF() : null;
    String description=in.readUTF();
    short width=in.readShort();
    short height=in.readShort();
    short minplayer=in.readShort();
    short maxplayer=in.readShort();
    short[] bgimage=new short[PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE];
    for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
      bgimage[i]=in.readShort();
    }
    ;
    Date date=null;
    if (type == MapType.SAVED_SINGLE) {
      long datetime=in.readLong();
      date=new Date(datetime);
    }
    return new MapFileHeader(type,mapName,mapId,baseMapId,description,width,height,minplayer,maxplayer,date,bgimage);
  }
 catch (  Throwable t) {
    if (t instanceof IOException) {
      throw (IOException)t;
    }
 else {
      throw new IOException(t);
    }
  }
}
Program: 56218
Project: 56218
Buggy source:
public String getUniqueId(){
  return getName();
}

Fixed version (ground truth):
public String getUniqueId(){
  return mapId;
}
Program: 56219
Project: 56219
Buggy source:
public void writeTo(OutputStream stream) throws IOException {
  DataOutputStream out=new DataOutputStream(stream);
  out.write(START_BYTES);
  out.writeShort(ALLOWED_VERSION);
  out.writeUTF(type.toString());
  out.writeUTF(name);
  out.writeUTF(description);
  out.writeShort(width);
  out.writeShort(height);
  out.writeShort(minPlayer);
  out.writeShort(maxPlayer);
  for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
    out.writeShort(bgimage[i]);
  }
  ;
  if (type == MapType.SAVED_SINGLE) {
    out.writeLong(date.getTime());
  }
}

Fixed version (ground truth):
public void writeTo(OutputStream stream) throws IOException {
  DataOutputStream out=new DataOutputStream(stream);
  out.write(START_BYTES);
  out.writeShort(VERSION);
  out.writeUTF(type.toString());
  out.writeUTF(name);
  out.writeUTF(mapId);
  out.writeUTF(baseMapId);
  out.writeUTF(description);
  out.writeShort(width);
  out.writeShort(height);
  out.writeShort(minPlayer);
  out.writeShort(maxPlayer);
  for (int i=0; i < PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE; i++) {
    out.writeShort(bgimage[i]);
  }
  ;
  if (type == MapType.SAVED_SINGLE) {
    out.writeLong(date.getTime());
  }
}
Program: 56220
Project: 56220
Buggy source:
public MapFileHeader(MapType type,String name,String description,short width,short height,short minplayer,short maxplayer,Date date,short[] bgimage){
  if (bgimage.length != PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.type=type;
  this.name=name;
  this.description=description;
  this.width=width;
  this.height=height;
  this.minPlayer=minplayer;
  this.maxPlayer=maxplayer;
  this.date=date;
  this.bgimage=bgimage;
}

Fixed version (ground truth):
public MapFileHeader(MapType type,String name,String mapId,String baseMapId,String description,short width,short height,short minplayer,short maxplayer,Date date,short[] bgimage){
  if (bgimage.length != PREVIEW_IMAGE_SIZE * PREVIEW_IMAGE_SIZE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.type=type;
  this.name=name;
  this.mapId=mapId;
  this.baseMapId=baseMapId;
  this.description=description;
  this.width=width;
  this.height=height;
  this.minPlayer=minplayer;
  this.maxPlayer=maxplayer;
  this.date=date;
  this.bgimage=bgimage;
}
Program: 56221
Project: 56221
Buggy source:
/** 
 * Gives the   {@link MapLoader} for the map with the given id.
 * @param id The id of the map to be found.
 * @return Returns the corresponding {@link MapLoader}<br> or null if no map with the given id has been found.
 */
public MapLoader getMapById(String id){
  ArrayList<MapLoader> maps=new ArrayList<MapLoader>();
  maps.addAll(getFreshMaps());
  maps.addAll(getSavedMaps());
  for (  MapLoader curr : maps) {
    if (curr.getUniqueID().equals(id)) {
      return curr;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Gives the   {@link MapLoader} for the map with the given id.
 * @param id The id of the map to be found.
 * @return Returns the corresponding {@link MapLoader}<br> or null if no map with the given id has been found.
 */
public MapLoader getMapById(String id){
  ArrayList<MapLoader> maps=new ArrayList<MapLoader>();
  maps.addAll(getFreshMaps());
  maps.addAll(getSavedMaps());
  for (  MapLoader curr : maps) {
    if (curr.getMapID().equals(id)) {
      return curr;
    }
  }
  return null;
}