nus-yam/ex-repair huggingface dataset:
Program: 86894
Project: 86894
Buggy source:
private void drawMemoryUsage(Canvas canvas){
  Runtime runtime=Runtime.getRuntime();
  long maxMemory=runtime.totalMemory() / (1024 * 1024);
  long usedMemory=maxMemory - runtime.freeMemory() / (1024 * 1024);
  int x=20;
  int y=canvas.getHeight() - 125;
  canvas.fillRect(x,y,100,15,0xcf696969);
  if (usedMemory > 0) {
    double percentage=((double)usedMemory / (double)maxMemory);
    canvas.fillRect(x,y,(int)(100 * percentage),15,0xdf3f3f3f);
  }
  canvas.drawRect(x - 1,y,101,15,0xff000000);
  canvas.drawLine(x,y + 1,x + 100,y + 1,0x8f000000);
  canvas.drawLine(x,y + 2,x + 100,y + 2,0x5f000000);
  canvas.drawLine(x,y + 3,x + 100,y + 3,0x2f000000);
  canvas.drawLine(x,y + 4,x + 100,y + 4,0x0f000000);
  canvas.drawLine(x,y + 5,x + 100,y + 5,0x0b000000);
  y=y + 15;
  canvas.drawLine(x,y - 5,x + 100,y - 5,0x0b000000);
  canvas.drawLine(x,y - 4,x + 100,y - 4,0x0f000000);
  canvas.drawLine(x,y - 3,x + 100,y - 3,0x2f000000);
  canvas.drawLine(x,y - 2,x + 100,y - 2,0x5f000000);
  canvas.drawLine(x,y - 1,x + 100,y - 1,0x8f000000);
  canvas.setFont("String_Node_Str",14);
  canvas.drawString(usedMemory + "String_Node_Str" + maxMemory+ "String_Node_Str",x - 20,y - 20,0xff00CC00);
}

Fixed version (ground truth):
private void drawMemoryUsage(Canvas canvas){
  Runtime runtime=Runtime.getRuntime();
  long maxMemory=runtime.totalMemory() / (1024 * 1024);
  long usedMemory=maxMemory - runtime.freeMemory() / (1024 * 1024);
  int x=20;
  int y=canvas.getHeight() - 125;
  canvas.fillRect(x,y,100,15,0xcf696969);
  if (usedMemory > 0 && maxMemory > 0) {
    double percentage=((double)usedMemory / (double)maxMemory);
    canvas.fillRect(x,y,(int)(100 * percentage),15,0xdf3f3f3f);
  }
  canvas.drawRect(x - 1,y,101,15,0xff000000);
  canvas.drawLine(x,y + 1,x + 100,y + 1,0x8f000000);
  canvas.drawLine(x,y + 2,x + 100,y + 2,0x5f000000);
  canvas.drawLine(x,y + 3,x + 100,y + 3,0x2f000000);
  canvas.drawLine(x,y + 4,x + 100,y + 4,0x0f000000);
  canvas.drawLine(x,y + 5,x + 100,y + 5,0x0b000000);
  y=y + 15;
  canvas.drawLine(x,y - 5,x + 100,y - 5,0x0b000000);
  canvas.drawLine(x,y - 4,x + 100,y - 4,0x0f000000);
  canvas.drawLine(x,y - 3,x + 100,y - 3,0x2f000000);
  canvas.drawLine(x,y - 2,x + 100,y - 2,0x5f000000);
  canvas.drawLine(x,y - 1,x + 100,y - 1,0x8f000000);
  canvas.setFont("String_Node_Str",14);
  canvas.drawString(usedMemory + "String_Node_Str" + maxMemory+ "String_Node_Str",x - 20,y - 20,0xff00CC00);
}
Program: 86895
Project: 86895
Buggy source:
/** 
 * Lets the brain think for a game tick
 * @param timeStep
 */
public void update(TimeStep timeStep){
  if (player.isAlive()) {
    this.memory.update(timeStep);
    this.sensors.update(timeStep);
    this.motion.update(timeStep);
    this.thoughtProcess.think(timeStep,this);
    this.targetingSystem.update(timeStep);
    debugDraw();
    debugDrawPathPlanner();
  }
}

Fixed version (ground truth):
/** 
 * Lets the brain think for a game tick
 * @param timeStep
 */
public void update(TimeStep timeStep){
  if (player.isAlive()) {
    this.memory.update(timeStep);
    this.sensors.update(timeStep);
    this.motion.update(timeStep);
    this.thoughtProcess.think(timeStep,this);
    this.targetingSystem.update(timeStep);
  }
}
Program: 86896
Project: 86896
Buggy source:
@Override public void onSpawn(Brain brain){
  this.currentGoal.cancel();
  this.currentGoal.start(brain);
}

Fixed version (ground truth):
@Override public void onSpawn(Brain brain){
  brain.getMotion().pickWeapon();
  this.currentGoal.cancel();
  this.currentGoal.start(brain);
}
Program: 86897
Project: 86897
Buggy source:
@Override public Action getAction(Brain brain){
  return getGoals().attack(brain.getTargetingSystem().getCurrentTarget());
}

Fixed version (ground truth):
@Override public Action getAction(Brain brain){
  return getGoals().enemyEncountered(getGoals(),brain);
}
Program: 86898
Project: 86898
Buggy source:
public static void main(final String[] args){
  final Console console=new DefaultConsole();
  Cons.setImpl(console);
  final Thread gameThread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        int port=DEFAULT_PORT;
        Leola runtime=Scripting.newRuntime();
        ServerSeventhConfig config=new ServerSeventhConfig(new Config("String_Node_Str","String_Node_Str",runtime));
        GameServer server=new GameServer(config,console,runtime);
        if (args.length > 0) {
          try {
            port=Integer.parseInt(args[0]);
          }
 catch (          Exception e) {
          }
        }
 else {
        }
        server.start(port);
      }
 catch (      Exception e) {
        console.println("String_Node_Str" + e);
      }
    }
  }
);
  if (isCmdLineOnly(args)) {
    gameThread.start();
    setupCommandLine(console);
  }
 else {
    javax.swing.SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new ConsoleFrame("String_Node_Str",BANNER,console);
        gameThread.start();
      }
    }
);
  }
}

Fixed version (ground truth):
public static void main(final String[] args){
  final Console console=new DefaultConsole();
  Cons.setImpl(console);
  final Thread gameThread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        int port=SeventhConstants.DEFAULT_PORT;
        Leola runtime=Scripting.newRuntime();
        ServerSeventhConfig config=new ServerSeventhConfig(new Config("String_Node_Str","String_Node_Str",runtime));
        GameServer server=new GameServer(config,console,runtime);
        if (args.length > 0) {
          try {
            port=Integer.parseInt(args[0]);
          }
 catch (          Exception e) {
            port=config.getPort();
          }
        }
 else {
          port=config.getPort();
        }
        server.start(port);
      }
 catch (      Exception e) {
        console.println("String_Node_Str" + e);
      }
    }
  }
);
  if (isCmdLineOnly(args)) {
    gameThread.start();
    setupCommandLine(console);
  }
 else {
    javax.swing.SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new ConsoleFrame("String_Node_Str",BANNER,console);
        gameThread.start();
      }
    }
);
  }
}
Program: 86899
Project: 86899
Buggy source:
/** 
 * Do the actual movement
 */
private void moveEntity(){
  moveDelta.zeroOut();
  if (pathFeeder != null) {
    if (!pathFeeder.atDestination()) {
      Vector2f nextDest=pathFeeder.nextDestination(me.getPos());
      moveDelta.set(nextDest);
    }
 else {
      Vector2f nextDest=pathFeeder.getDestination();
      Vector2f.Vector2fSubtract(nextDest,me.getPos(),moveDelta);
      if (moveDelta.lengthSquared() < 25) {
        moveDelta.zeroOut();
      }
    }
  }
  directMove(moveDelta);
}

Fixed version (ground truth):
/** 
 * Do the actual movement
 */
private void moveEntity(){
  moveDelta.zeroOut();
  if (pathFeeder != null) {
    if (!pathFeeder.atDestination()) {
      Vector2f nextDest=pathFeeder.nextDestination(me.getPos());
      moveDelta.set(nextDest);
    }
 else {
      Vector2f nextDest=pathFeeder.getDestination();
      Vector2f.Vector2fSubtract(nextDest,me.getPos(),moveDelta);
      if (moveDelta.lengthSquared() < 26) {
        moveDelta.zeroOut();
      }
    }
  }
  directMove(moveDelta);
}
Program: 86900
Project: 86900
Buggy source:
/** 
 * Check to see if our agent is stuck
 * @param timeStep
 * @param brain
 * @return true if we are stuck
 */
protected boolean checkIfStuck(TimeStep timeStep,Brain brain){
  PlayerEntity bot=brain.getEntityOwner();
  this.nextStuckCheck-=timeStep.getDeltaTime();
  if (this.nextStuckCheck < 0) {
    this.nextStuckCheck=1500;
    if (Vector2f.Vector2fApproxEquals(previousPosition,bot.getPos(),5.0f)) {
      this.stuckTimer.update(timeStep);
      if (this.stuckTimer.isTime()) {
        this.stuckTimer.reset();
        return true;
      }
    }
 else {
      this.stuckTimer.reset();
    }
  }
  this.previousPosition.set(bot.getPos());
  return false;
}

Fixed version (ground truth):
/** 
 * Check to see if our agent is stuck
 * @param timeStep
 * @param brain
 * @return true if we are stuck
 */
protected boolean checkIfStuck(TimeStep timeStep,Brain brain){
  PlayerEntity bot=brain.getEntityOwner();
  this.nextStuckCheck-=timeStep.getDeltaTime();
  if (this.nextStuckCheck < 0) {
    this.nextStuckCheck=1500;
    if (Vector2f.Vector2fApproxEquals(previousPosition,bot.getPos(),5.0f)) {
      this.stuckTimer.start();
      this.stuckTimer.update(timeStep);
      if (this.stuckTimer.isTime()) {
        this.stuckTimer.stop();
        return true;
      }
    }
 else {
      this.stuckTimer.stop();
    }
  }
  this.previousPosition.set(bot.getPos());
  return false;
}
Program: 86901
Project: 86901
Buggy source:
/** 
 * Check to see if the agent is too close to an active bomb
 * @param brain
 * @return the {@link BombTarget} with an active bomb on it.  Null if not too close
 */
private BombTarget checkIfCloseToActiveBomb(Brain brain){
  World world=brain.getWorld();
  List<BombTarget> targets=world.getBombTargetsWithActiveBombs();
  for (int i=0; i < targets.size(); i++) {
    BombTarget target=targets.get(i);
    Zone zone=world.getZone(target.getCenterPos());
    if (zone != null) {
      Bomb bomb=target.getBomb();
      if (bomb.getBlastRadius().intersects(brain.getEntityOwner().getBounds())) {
        return target;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Check to see if the agent is too close to an active bomb
 * @param brain
 * @return the {@link BombTarget} with an active bomb on it.  Null if not too close
 */
private BombTarget checkIfCloseToActiveBomb(Brain brain){
  World world=brain.getWorld();
  if (!world.isOnOffense(brain.getEntityOwner().getTeam())) {
    return null;
  }
  List<BombTarget> targets=world.getBombTargetsWithActiveBombs();
  for (int i=0; i < targets.size(); i++) {
    BombTarget target=targets.get(i);
    Zone zone=world.getZone(target.getCenterPos());
    if (zone != null) {
      Bomb bomb=target.getBomb();
      if (bomb.getBlastRadius().intersects(brain.getEntityOwner().getBounds())) {
        return target;
      }
    }
  }
  return null;
}
Program: 86902
Project: 86902
Buggy source:
@Override public void update(Brain brain,TimeStep timeStep){
  if (isDefused()) {
    this.getActionResult().setSuccess();
  }
 else {
    Locomotion motion=brain.getMotion();
    if (!bomb.isTouching(brain.getEntityOwner())) {
      motion.moveTo(bomb.getCenterPos());
    }
 else     if (!bomb.bombDisarming() || !motion.isDefusing()) {
      motion.defuseBomb(bomb);
    }
    getActionResult().setFailure();
  }
}

Fixed version (ground truth):
@Override public void update(Brain brain,TimeStep timeStep){
  if (isDefused()) {
    this.getActionResult().setSuccess();
  }
 else {
    Locomotion motion=brain.getMotion();
    if (!bomb.isTouching(brain.getEntityOwner())) {
      Vector2f dest=motion.getDestination();
      if (dest == null || !dest.equals(bomb.getCenterPos())) {
        motion.moveTo(bomb.getCenterPos());
      }
    }
 else     if (!bomb.bombDisarming() || !motion.isDefusing()) {
      motion.defuseBomb(bomb);
    }
    getActionResult().setFailure();
  }
}
Program: 86903
Project: 86903
Buggy source:
@Override public void update(TimeStep timeStep,GameInfo game){
  if (this.timeUntilOrganizedAttack > 0) {
    this.timeUntilOrganizedAttack-=timeStep.getDeltaTime();
    giveOrders(DefensiveState.RANDOM);
    return;
  }
  if (zoneToAttack == null) {
    return;
  }
  if (zoneToAttack.hasActiveBomb()) {
    if (isBombBeingDisarmed(zoneToAttack)) {
      giveOrders(DefensiveState.ATTACK_ZONE);
    }
 else {
      giveOrders(DefensiveState.DEFUSE_BOMB);
    }
  }
 else {
    zoneToAttack=calculateZoneToAttack();
    if (zoneToAttack != null) {
      giveOrders(DefensiveState.ATTACK_ZONE);
    }
  }
}

Fixed version (ground truth):
@Override public void update(TimeStep timeStep,GameInfo game){
  if (isBombPlanted()) {
    zoneToAttack=calculateZoneToAttack();
    if (isBombBeingDisarmed(zoneToAttack)) {
      giveOrders(DefensiveState.ATTACK_ZONE);
    }
 else {
      giveOrders(DefensiveState.DEFUSE_BOMB);
    }
  }
 else {
    if (this.timeUntilOrganizedAttack > 0) {
      this.timeUntilOrganizedAttack-=timeStep.getDeltaTime();
      giveOrders(DefensiveState.RANDOM);
      return;
    }
    zoneToAttack=calculateZoneToAttack();
    if (zoneToAttack != null) {
      giveOrders(DefensiveState.ATTACK_ZONE);
    }
  }
}
Program: 86904
Project: 86904
Buggy source:
/** 
 * Gives all the available Agents orders
 */
private void giveOrders(DefensiveState state){
  if (currentState != state) {
    currentState=state;
    List<Player> players=team.getPlayers();
    for (int i=0; i < players.size(); i++) {
      Player player=players.get(i);
      if (player.isBot() && player.isAlive()) {
        Brain brain=aiSystem.getBrain(player);
        brain.getCommunicator().post(getCurrentAction(brain));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Gives all the available Agents orders
 */
private void giveOrders(DefensiveState state){
  if (currentState != state) {
    currentState=state;
    List<Player> players=team.getPlayers();
    for (int i=0; i < players.size(); i++) {
      Player player=players.get(i);
      if (player.isBot() && player.isAlive()) {
        Brain brain=aiSystem.getBrain(player);
        if (!brain.getMotion().isDefusing()) {
          brain.getCommunicator().post(getCurrentAction(brain));
        }
      }
    }
  }
}
Program: 86905
Project: 86905
Buggy source:
public void teamTextMessage(TeamTextMessage msg){
  ClientPlayer player=players.get(msg.playerId);
  if (player != null) {
    hud.postMessage("String_Node_Str" + player.getName() + "String_Node_Str"+ msg.message);
  }
 else {
    hud.postMessage("String_Node_Str" + msg.message);
  }
}

Fixed version (ground truth):
public void teamTextMessage(TeamTextMessage msg){
  ClientPlayer player=players.get(msg.playerId);
  if (player != null) {
    if (player.isAlive()) {
      hud.postMessage("String_Node_Str" + player.getName() + "String_Node_Str"+ msg.message);
    }
 else {
      hud.postMessage("String_Node_Str" + player.getName() + "String_Node_Str"+ msg.message);
    }
  }
 else {
    hud.postMessage("String_Node_Str" + msg.message);
  }
}
Program: 86906
Project: 86906
Buggy source:
public void textMessage(TextMessage msg){
  ClientPlayer player=players.get(msg.playerId);
  if (player != null) {
    hud.postMessage(player.getName() + "String_Node_Str" + msg.message);
  }
 else {
    hud.postMessage(msg.message);
  }
}

Fixed version (ground truth):
public void textMessage(TextMessage msg){
  ClientPlayer player=players.get(msg.playerId);
  if (player != null) {
    if (player.isAlive()) {
      hud.postMessage(player.getName() + "String_Node_Str" + msg.message);
    }
 else {
      hud.postMessage("String_Node_Str" + player.getName() + "String_Node_Str"+ msg.message);
    }
  }
 else {
    hud.postMessage(msg.message);
  }
}
Program: 86907
Project: 86907
Buggy source:
/** 
 * Updates the special effects, etc.
 * @param timeStep
 */
public void update(TimeStep timeStep){
  this.lightSystem.update(timeStep);
  long gameClock=timeStep.getGameClock();
  this.deadEntities.clear();
  int size=this.entityList.size();
  for (int i=0; i < size; i++) {
    ClientEntity ent=this.entityList.get(i);
    ent.update(timeStep);
    if (ent.killIfOutdated(gameClock)) {
      this.deadEntities.add(ent);
    }
  }
  size=this.deadEntities.size();
  for (int i=0; i < size; i++) {
    ClientEntity ent=deadEntities.get(i);
    removeEntity(ent.getId());
  }
  backgroundEffects.update(timeStep);
  foregroundEffects.update(timeStep);
  size=frameBufferRenderables.size();
  for (int i=0; i < size; i++) {
    FrameBufferRenderable r=this.frameBufferRenderables.get(i);
    r.update(timeStep);
  }
  if (this.localPlayer.isAlive() || this.localPlayer.isSpectating()) {
    ClientPlayerEntity entity=(this.localPlayer.isAlive()) ? this.localPlayer.getEntity() : (this.players.containsKey(this.localPlayer.getSpectatingPlayerId())) ? this.players.get(this.localPlayer.getSpectatingPlayerId()).getEntity() : null;
    if (entity != null) {
      entity.movementPrediction(map,timeStep,playerVelocity);
      cameraCenterAround.set(entity.getPos());
      Vector2f.Vector2fRound(cameraCenterAround,cameraCenterAround);
      ;
      camera.centerAround(cameraCenterAround);
      Sounds.setPosition(cameraCenterAround);
      nextFOWUpdate-=timeStep.getDeltaTime();
      if (nextFOWUpdate <= 0) {
        fowTiles=Geom.calculateLineOfSight(fowTiles,entity.getCenterPos(),entity.getFacing(),entity.getLineOfSite(),map,entity.getHeightMask());
        Geom.addFadeEffect(map,fowTiles);
        nextFOWUpdate=100;
      }
    }
  }
  map.update(timeStep);
  miniMap.update(timeStep);
  camera.update(timeStep);
  hud.update(timeStep);
}

Fixed version (ground truth):
/** 
 * Updates the special effects, etc.
 * @param timeStep
 */
public void update(TimeStep timeStep){
  this.lightSystem.update(timeStep);
  long gameClock=timeStep.getGameClock();
  this.deadEntities.clear();
  int size=this.entityList.size();
  for (int i=0; i < size; i++) {
    ClientEntity ent=this.entityList.get(i);
    ent.update(timeStep);
    if (ent.killIfOutdated(gameClock)) {
      this.deadEntities.add(ent);
    }
  }
  size=this.deadEntities.size();
  for (int i=0; i < size; i++) {
    ClientEntity ent=deadEntities.get(i);
    removeEntity(ent.getId());
  }
  backgroundEffects.update(timeStep);
  foregroundEffects.update(timeStep);
  size=frameBufferRenderables.size();
  for (int i=0; i < size; i++) {
    FrameBufferRenderable r=this.frameBufferRenderables.get(i);
    r.update(timeStep);
  }
  updateFow(timeStep);
  map.update(timeStep);
  camera.update(timeStep);
  hud.update(timeStep);
}
Program: 86908
Project: 86908
Buggy source:
/** 
 * Renders the game
 * @param canvas
 */
public void render(Canvas canvas){
  renderFrameBuffer(canvas);
  canvas.begin();
  map.render(canvas,camera,0);
  canvas.end();
  backgroundEffects.render(canvas,camera,0);
  int size=this.entityList.size();
  for (int i=0; i < size; i++) {
    ClientEntity entity=this.entityList.get(i);
    entity.render(canvas,camera,0);
    boolean debug=false;
    if (debug) {
      debugRenderEntity(canvas,entity);
    }
  }
  foregroundEffects.render(canvas,camera,0);
  map.renderForeground(canvas,camera,0);
  canvas.setColor(0,45);
  map.renderSolid(canvas,camera,0);
  lightSystem.render(canvas,camera,0);
  miniMap.render(canvas,camera,0);
  DebugDraw.enable(false);
  DebugDraw.render(canvas,camera);
  canvas.setShader(null);
  hud.render(canvas,camera,0);
}

Fixed version (ground truth):
/** 
 * Renders the game
 * @param canvas
 */
public void render(Canvas canvas){
  renderFrameBuffer(canvas);
  canvas.begin();
  map.render(canvas,camera,0);
  canvas.end();
  backgroundEffects.render(canvas,camera,0);
  int size=this.entityList.size();
  for (int i=0; i < size; i++) {
    ClientEntity entity=this.entityList.get(i);
    entity.render(canvas,camera,0);
    boolean debug=false;
    if (debug) {
      debugRenderEntity(canvas,entity);
    }
  }
  foregroundEffects.render(canvas,camera,0);
  map.renderForeground(canvas,camera,0);
  canvas.setColor(0,45);
  map.renderSolid(canvas,camera,0);
  lightSystem.render(canvas,camera,0);
  DebugDraw.enable(false);
  DebugDraw.render(canvas,camera);
  canvas.setShader(null);
  hud.render(canvas,camera,0);
}
Program: 86909
Project: 86909
Buggy source:
/** 
 * @throws Exception 
 */
public ClientGame(SeventhGame app,java.util.Map<Integer,ClientPlayer> players,Map map,int localPlayerId) throws Exception {
  this.app=app;
  this.players=players;
  this.map=map;
  this.localPlayer=players.get(localPlayerId);
  this.scoreboard=new Scoreboard(this);
  this.entities=new HashMap<Integer,ClientEntity>();
  this.entityList=new ArrayList<ClientEntity>();
  this.deadEntities=new ArrayList<ClientEntity>();
  this.bombTargets=new ArrayList<ClientBombTarget>();
  this.frameBufferRenderables=new ArrayList<>();
  this.fowTiles=new ArrayList<Tile>();
  this.cameraCenterAround=new Vector2f();
  this.backgroundEffects=new Effects();
  this.foregroundEffects=new Effects();
  this.camera=newCamera(map.getMapWidth(),map.getMapHeight());
  this.cameraShakeBounds=new Rectangle(600,600);
  this.playerVelocity=new Vector2f();
  this.hud=new Hud(this);
  this.random=new Random();
  this.gameType=GameType.Type.TDM;
  this.cacheRect=new Rectangle();
  this.lightSystem=new ImageBasedLightSystem();
  this.frameBufferRenderables.add(lightSystem);
  this.entityListener=lightSystem.getClientEntityListener();
  this.miniMap=new MiniMap(this);
}

Fixed version (ground truth):
/** 
 * @throws Exception 
 */
public ClientGame(SeventhGame app,java.util.Map<Integer,ClientPlayer> players,Map map,int localPlayerId) throws Exception {
  this.app=app;
  this.players=players;
  this.map=map;
  this.localPlayer=players.get(localPlayerId);
  this.scoreboard=new Scoreboard(this);
  this.entities=new HashMap<Integer,ClientEntity>();
  this.entityList=new ArrayList<ClientEntity>();
  this.deadEntities=new ArrayList<ClientEntity>();
  this.bombTargets=new ArrayList<ClientBombTarget>();
  this.frameBufferRenderables=new ArrayList<>();
  this.fowTiles=new ArrayList<Tile>();
  this.cameraCenterAround=new Vector2f();
  this.backgroundEffects=new Effects();
  this.foregroundEffects=new Effects();
  this.camera=newCamera(map.getMapWidth(),map.getMapHeight());
  this.cameraShakeBounds=new Rectangle(600,600);
  this.playerVelocity=new Vector2f();
  this.hud=new Hud(this);
  this.random=new Random();
  this.gameType=GameType.Type.TDM;
  this.cacheRect=new Rectangle();
  this.lightSystem=new ImageBasedLightSystem();
  this.frameBufferRenderables.add(lightSystem);
  this.entityListener=lightSystem.getClientEntityListener();
}
Program: 86910
Project: 86910
Buggy source:
private void drawScore(Canvas canvas){
  canvas.setFont("String_Node_Str",18);
  int x=0;
  int y=20;
  int width=50;
  canvas.fillRect(x,y - 15,width,20,0x8fffffff & ClientTeam.ALLIES.getColor());
  canvas.drawRect(x,y - 15,width,20,0xff000000);
  String txt=scoreboard.getAlliedScore() + "String_Node_Str";
  RenderFont.drawShadedString(canvas,txt,x + (width - canvas.getWidth(txt)) - 1,y,0xffffffff);
  y+=20;
  canvas.fillRect(x,y - 15,width,20,0x8fffffff & ClientTeam.AXIS.getColor());
  canvas.drawRect(x,y - 15,width,20,0xff000000);
  txt=scoreboard.getAxisScore() + "String_Node_Str";
  RenderFont.drawShadedString(canvas,txt,x + (width - canvas.getWidth(txt)) - 1,y,0xffffffff);
}

Fixed version (ground truth):
private void drawScore(Canvas canvas){
  canvas.setFont("String_Node_Str",18);
  int textLen=canvas.getWidth("String_Node_Str");
  int x=canvas.getWidth() / 2 - textLen;
  int y=canvas.getHeight() - 10;
  int width=50;
  int height=20;
  canvas.fillRect(x,y - 15,width,height,0x8fffffff & ClientTeam.ALLIES.getColor());
  canvas.drawRect(x,y - 15,width,height,0xff000000);
  String txt=scoreboard.getAlliedScore() + "String_Node_Str";
  RenderFont.drawShadedString(canvas,txt,x + (width - canvas.getWidth(txt)) - 1,y,0xffffffff);
  x+=textLen + 2;
  canvas.fillRect(x - 2,y - 15,2,height,0xff000000);
  canvas.fillRect(x,y - 15,width,height,0x8fffffff & ClientTeam.AXIS.getColor());
  canvas.drawRect(x,y - 15,width,height,0xff000000);
  txt=scoreboard.getAxisScore() + "String_Node_Str";
  RenderFont.drawShadedString(canvas,txt,x + 4,y,0xffffffff);
}
Program: 86911
Project: 86911
Buggy source:
@Override public void update(TimeStep timeStep){
  killLog.update(timeStep);
  messageLog.update(timeStep);
  centerLog.update(timeStep);
  if (this.isAtBomb) {
    if (useButtonReleased) {
      bombTime+=timeStep.getDeltaTime();
      float percentageCompleted=(float)((float)bombTime / this.completionTime);
      bombProgressBar.setProgress((int)(percentageCompleted * 100));
      bombProgressBar.show();
      if (bombProgressBar.getProgress() >= 99) {
        bombTime=0;
        bombProgressBar.hide();
        useButtonReleased=false;
      }
    }
  }
 else {
    bombProgressBar.hide();
    bombProgressBar.setProgress(0);
    bombTime=0;
    useButtonReleased=true;
  }
  bombProgressBarView.update(timeStep);
}

Fixed version (ground truth):
@Override public void update(TimeStep timeStep){
  killLog.update(timeStep);
  messageLog.update(timeStep);
  centerLog.update(timeStep);
  miniMap.update(timeStep);
  miniMap.setMapAlpha(scoreboard.isVisible() ? 0x3f : 0x8f);
  updateProgressBar(timeStep);
}
Program: 86912
Project: 86912
Buggy source:
/** 
 */
public Hud(ClientGame game){
  this.game=game;
  this.app=game.getApp();
  this.localPlayer=game.getLocalPlayer();
  int screenWidth=game.getApp().getScreenWidth();
  this.killLog=new KillLog(screenWidth - 260,30,5000);
  this.messageLog=new MessageLog(10,60,15000,6);
  this.centerLog=new MessageLog(screenWidth / 2,90,3000,2){
    @Override protected void onRenderMesage(    Canvas canvas,    Camera camera,    String message,    int x,    int y){
      int width=canvas.getWidth(message);
      canvas.drawString(message,x - (width / 2),y,0xffffffff);
    }
  }
;
  this.centerLog.setFontSize(24);
  this.scoreboard=game.getScoreboard();
  this.gameClockDate=new Date();
  this.bombProgressBar=new ProgressBar();
  this.bombProgressBar.setTheme(app.getTheme());
  this.bombProgressBar.setBounds(new Rectangle(300,15));
  this.bombProgressBar.getBounds().centerAround(screenWidth / 2,app.getScreenHeight() - 80);
  this.bombProgressBarView=new ProgressBarView(bombProgressBar);
}

Fixed version (ground truth):
/** 
 */
public Hud(ClientGame game){
  this.game=game;
  this.app=game.getApp();
  this.localPlayer=game.getLocalPlayer();
  int screenWidth=game.getApp().getScreenWidth();
  this.killLog=new KillLog(screenWidth - 260,30,5000);
  this.messageLog=new MessageLog(10,60,15000,6);
  this.centerLog=new MessageLog(screenWidth / 2,90,3000,2){
    @Override protected void onRenderMesage(    Canvas canvas,    Camera camera,    String message,    int x,    int y){
      int width=canvas.getWidth(message);
      canvas.drawString(message,x - (width / 2),y,0xffffffff);
    }
  }
;
  this.centerLog.setFontSize(24);
  this.scoreboard=game.getScoreboard();
  this.gameClockDate=new Date();
  this.bombProgressBar=new ProgressBar();
  this.bombProgressBar.setTheme(app.getTheme());
  this.bombProgressBar.setBounds(new Rectangle(300,15));
  this.bombProgressBar.getBounds().centerAround(screenWidth / 2,app.getScreenHeight() - 80);
  this.bombProgressBarView=new ProgressBarView(bombProgressBar);
  this.miniMap=new MiniMap(game);
}
Program: 86913
Project: 86913
Buggy source:
@Override public void render(Canvas canvas,Camera camera,long alpha){
  canvas.setFont("String_Node_Str",12);
  canvas.drawString("String_Node_Str" + app.getFps(),canvas.getWidth() - 60,10,0xff10f0ef);
  killLog.render(canvas,camera,0);
  messageLog.render(canvas,camera,0);
  centerLog.render(canvas,camera,0);
  if (localPlayer.isAlive()) {
    ClientPlayerEntity ent=localPlayer.getEntity();
    ClientWeapon weapon=ent.getWeapon();
    if (!ent.isMech()) {
      drawWeaponIcons(canvas,weapon);
      drawGrenadeIcons(canvas,ent.getNumberOfGrenades());
    }
    drawHealth(canvas,ent.getHealth());
    drawStamina(canvas,ent.getStamina());
  }
 else {
    drawHealth(canvas,0);
    drawStamina(canvas,0);
  }
  if (this.scoreboard.isVisible()) {
    this.scoreboard.drawScoreboard(canvas);
  }
  drawScore(canvas);
  drawClock(canvas);
  drawSpectating(canvas);
  drawBombProgressBar(canvas,camera);
}

Fixed version (ground truth):
@Override public void render(Canvas canvas,Camera camera,long alpha){
  canvas.setFont("String_Node_Str",12);
  canvas.drawString("String_Node_Str" + app.getFps(),canvas.getWidth() - 60,10,0xff10f0ef);
  killLog.render(canvas,camera,0);
  messageLog.render(canvas,camera,0);
  centerLog.render(canvas,camera,0);
  miniMap.render(canvas,camera,alpha);
  if (localPlayer.isAlive()) {
    ClientPlayerEntity ent=localPlayer.getEntity();
    ClientWeapon weapon=ent.getWeapon();
    if (!ent.isMech()) {
      drawWeaponIcons(canvas,weapon);
      drawGrenadeIcons(canvas,ent.getNumberOfGrenades());
    }
    drawHealth(canvas,ent.getHealth());
    drawStamina(canvas,ent.getStamina());
  }
 else {
    drawHealth(canvas,0);
    drawStamina(canvas,0);
  }
  if (this.scoreboard.isVisible()) {
    this.scoreboard.drawScoreboard(canvas);
  }
  drawScore(canvas);
  drawClock(canvas);
  drawSpectating(canvas);
  drawBombProgressBar(canvas,camera);
}
Program: 86914
Project: 86914
Buggy source:
/** 
 * Kill all entities, invokes a softKill on all active game entities
 */
public void killAll(){
  for (int i=0; i < entities.length; i++) {
    Entity ent=entities[i];
    if (ent != null) {
      ent.softKill();
    }
  }
  for (int i=0; i < playerEntities.length; i++) {
    playerEntities[i]=null;
  }
}

Fixed version (ground truth):
/** 
 * Kill all entities, invokes a softKill on all active game entities
 */
public void killAll(){
  for (int i=0; i < entities.length; i++) {
    Entity ent=entities[i];
    if (ent != null) {
      ent.softKill();
    }
  }
  for (int i=0; i < playerEntities.length; i++) {
    playerEntities[i]=null;
  }
  this.bombTargets.clear();
  this.vehicles.clear();
}
Program: 86916
Project: 86916
Buggy source:
@Override @EventMethod public void onRoundStarted(RoundStartedEvent event){
  RoundStartedMessage msg=new RoundStartedMessage();
  msg.gameState=game.getNetGameState();
  listener.queueSendToAll(Endpoint.FLAG_RELIABLE,msg);
}

Fixed version (ground truth):
@Override @EventMethod public void onRoundStarted(RoundStartedEvent event){
  loadProperties(map.getMapFileName(),game);
  RoundStartedMessage msg=new RoundStartedMessage();
  msg.gameState=game.getNetGameState();
  listener.queueSendToAll(Endpoint.FLAG_RELIABLE,msg);
}
Program: 86917
Project: 86917
Buggy source:
public ODatabaseInternal<?> db(){
  return ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner();
}

Fixed version (ground truth):
public ODatabaseInternal<?> db(){
  ODatabaseInternal<?> db;
  if (!ODatabaseRecordThreadLocal.INSTANCE.isDefined()) {
    db=openDatabase();
    log.debug("String_Node_Str",db.hashCode());
  }
 else {
    db=ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner();
    log.debug("String_Node_Str",db.hashCode());
  }
  return db;
}
Program: 86918
Project: 86918
Buggy source:
@Override public String getRid(Object entity){
  Class clazz=entity.getClass();
  while (clazz != Object.class) {
    for (    Field field : clazz.getDeclaredFields()) {
      OId ridAnnotation=field.getAnnotation(OId.class);
      if (ridAnnotation != null) {
        field.setAccessible(true);
        try {
          Object rid=field.get(entity);
          return rid != null ? rid.toString() : null;
        }
 catch (        IllegalAccessException|IllegalArgumentException ex) {
          throw new RuntimeException(ex);
        }
      }
    }
    clazz=clazz.getSuperclass();
  }
  return null;
}

Fixed version (ground truth):
@Override public String getRid(Object entity){
  Class clazz=entity.getClass();
  while (clazz != Object.class) {
    for (    Field field : clazz.getDeclaredFields()) {
      OId ridAnnotation=field.getAnnotation(OId.class);
      if (ridAnnotation != null) {
        field.setAccessible(true);
        try {
          Object rid=field.get(entity);
          if (rid == null) {
            Method method=clazz.getDeclaredMethod(getterName(field.getName()));
            rid=method.invoke(entity);
          }
          return rid != null ? rid.toString() : null;
        }
 catch (        IllegalAccessException|IllegalArgumentException|NoSuchMethodException|InvocationTargetException ex) {
          throw new RuntimeException(ex);
        }
      }
    }
    clazz=clazz.getSuperclass();
  }
  return null;
}
Program: 86919
Project: 86919
Buggy source:
/** 
 * Returns whether the given repository interface requires a   {@link OrinetObjectRepository} specific implementation to be chosen.
 * @param repositoryInterface the repository interface
 * @return true, if is repository assignable from OrientObjectRepository
 */
private boolean isObjectRepository(Class<?> repositoryInterface){
  return OrientObjectRepository.class.isAssignableFrom(repositoryInterface);
}

Fixed version (ground truth):
/** 
 * Returns whether the given repository interface requires a   {@link org.springframework.data.orient.object.repository.OrientObjectRepository} specific implementation to be chosen.
 * @param repositoryInterface the repository interface
 * @return true, if is repository assignable from OrientObjectRepository
 */
private boolean isObjectRepository(Class<?> repositoryInterface){
  return OrientObjectRepository.class.isAssignableFrom(repositoryInterface);
}
Program: 86920
Project: 86920
Buggy source:
@Override @SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected Object getTargetRepository(RepositoryMetadata metadata){
  EntityInformation<?,Serializable> entityInformation=getEntityInformation(metadata.getDomainType());
  Class<?> repositoryInterface=metadata.getRepositoryInterface();
  Class<?> javaType=entityInformation.getJavaType();
  if (isObjectRepository(metadata.getRepositoryInterface())) {
    return new SimpleOrientObjectRepository(operations,javaType,repositoryInterface);
  }
 else {
    return new SimpleOrientRepository(operations,javaType,repositoryInterface);
  }
}

Fixed version (ground truth):
@Override @SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected Object getTargetRepository(RepositoryMetadata metadata){
  EntityInformation<?,Serializable> entityInformation=getEntityInformation(metadata.getDomainType());
  Class<?> repositoryInterface=metadata.getRepositoryInterface();
  Class<?> javaType=entityInformation.getJavaType();
  String customClusterName=getCustomCluster(metadata);
  if (customClusterName != null) {
    if (isObjectRepository(metadata.getRepositoryInterface())) {
      return new ClusteredOrientObjectRepository(operations,javaType,customClusterName,repositoryInterface);
    }
 else {
      return new ClusteredOrientRepository(operations,javaType,customClusterName,repositoryInterface);
    }
  }
 else {
    if (isObjectRepository(metadata.getRepositoryInterface())) {
      return new SimpleOrientObjectRepository(operations,javaType,repositoryInterface);
    }
 else {
      return new SimpleOrientRepository(operations,javaType,repositoryInterface);
    }
  }
}
Program: 86921
Project: 86921
Buggy source:
protected OrientSource getSource(){
  OrientSource orientSource=accessor.getSource();
  if (orientSource != null) {
    return orientSource;
  }
  Source source=findAnnotation(Source.class);
  if (source != null) {
    new DefaultSource(source.type(),source.value());
  }
  Cluster cluster=findAnnotation(Cluster.class);
  if (cluster != null) {
    orientSource=new DefaultSource(cluster.value());
  }
  return new DefaultSource(domainClass);
}

Fixed version (ground truth):
protected OrientSource getSource(){
  OrientSource orientSource=accessor.getSource();
  if (orientSource != null) {
    return orientSource;
  }
  Source source=findAnnotation(Source.class);
  if (source != null) {
    return new DefaultSource(source.type(),source.value());
  }
  Cluster cluster=findAnnotation(Cluster.class);
  if (cluster != null) {
    return new DefaultSource(cluster.value());
  }
  return new DefaultSource(domainClass);
}
Program: 86922
Project: 86922
Buggy source:
public static List<Span> splitIntoSpans(String regex,String text){
  List<Span> spans=new ArrayList<>();
  int curstart=0;
  Matcher m=Pattern.compile(regex).matcher(text);
  while (m.find()) {
    spans.add(new Span(curstart,m.start()));
    curstart=m.end();
  }
  spans.add(new Span(curstart,text.length()));
  return spans;
}

Fixed version (ground truth):
/** 
 * a-bb-c- ==> [0,1), [2,4), [5,6), [7,7) 
 */
public static List<Span> splitIntoSpans(String regex,String text){
  List<Span> spans=new ArrayList<>();
  int curstart=0;
  Matcher m=Pattern.compile(regex).matcher(text);
  while (m.find()) {
    spans.add(new Span(curstart,m.start()));
    curstart=m.end();
  }
  spans.add(new Span(curstart,text.length()));
  return spans;
}
Program: 86923
Project: 86923
Buggy source:
/** 
 * 0, {4,8}, 10 ===> [0,4), [4,8), [8,10) 
 */
public static List<Span> breakpointsToSpans(int start,List<Integer> breakpoints,int end){
  List<Span> spans=new ArrayList<>();
  int curstart=start;
  for (  int p : breakpoints) {
    spans.add(new Span(curstart,p));
    curstart=p;
  }
  spans.add(new Span(curstart,end));
  return spans;
}

Fixed version (ground truth):
/** 
 * 0, {4,8}, 10 ===> [0,4), [4,8), [8,10) 
 */
public static List<Span> breakpointsToSpans(int start,List<Integer> breakpoints,int end){
  List<Span> spans=new ArrayList<>();
  if (end < start)   return spans;
  if (start == end && breakpoints.size() > 0)   return spans;
  int curstart=start;
  for (  int p : breakpoints) {
    spans.add(new Span(curstart,p));
    curstart=p;
  }
  spans.add(new Span(curstart,end));
  return spans;
}
Program: 86924
Project: 86924
Buggy source:
@Test public void regextests(){
  List<Span> spans;
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,3)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,5)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,2)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,0),new Span(1,1)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,2),new Span(3,3)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
@Test public void regextests(){
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,3)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,5)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,2)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,0),new Span(1,1)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,2),new Span(3,3)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
  assertEquals(Lists.newArrayList(new Span(0,1),new Span(2,4),new Span(5,6),new Span(7,7)),GUtil.splitIntoSpans("String_Node_Str","String_Node_Str"));
}
Program: 86925
Project: 86925
Buggy source:
@Test public void spantests(){
  List<Span> spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(4,8),10);
  assertEquals(Lists.newArrayList(new Span(0,4),new Span(4,8),new Span(8,10)),spans);
  spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(),10);
  assertEquals(Lists.newArrayList(new Span(0,10)),spans);
  spans=GUtil.breakpointsToSpans(-4,Lists.newArrayList(3),10);
  assertEquals(Lists.newArrayList(new Span(-4,3),new Span(3,10)),spans);
}

Fixed version (ground truth):
@Test public void spantests(){
  List<Span> spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(4,8),10);
  assertEquals(Lists.newArrayList(new Span(0,4),new Span(4,8),new Span(8,10)),spans);
  spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(),10);
  assertEquals(Lists.newArrayList(new Span(0,10)),spans);
  spans=GUtil.breakpointsToSpans(-4,Lists.newArrayList(3),10);
  assertEquals(Lists.newArrayList(new Span(-4,3),new Span(3,10)),spans);
  spans=GUtil.breakpointsToSpans(3,Lists.newArrayList(),3);
  assertEquals(Lists.newArrayList(new Span(3,3)),spans);
  spans=GUtil.breakpointsToSpans(3,Lists.newArrayList(),2);
  assertEquals(Lists.newArrayList(),spans);
}
Program: 86926
Project: 86926
Buggy source:
@Override public void paintComponent(Graphics _g){
  Graphics2D g=(Graphics2D)_g;
  U.pf("String_Node_Str",getSize(),g.getClip(),getVisibleRect());
  draw(g,getWidth());
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics _g){
  Graphics2D g=(Graphics2D)_g;
  draw(g,getWidth());
}
Program: 86927
Project: 86927
Buggy source:
void draw(Graphics2D g,int width){
  long t0=System.nanoTime();
  U.pf("String_Node_Str");
  Rectangle clip=g.getClipBounds();
  Rendering rend=getRendering();
  int lineHeight=getLineHeight();
  int totalHeight=rend.totalScreenLines * lineHeight;
  g.setColor(Color.WHITE);
  g.fillRect(clip.x,clip.y,clip.width,clip.height);
  g.setColor(Color.BLACK);
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_NORMALIZE);
  g.setFont(NORMAL_FONT);
  U.p(clip);
  int firstline=clip.y / lineHeight;
  int lastline=(clip.y + clip.height) / lineHeight;
  firstline--;
  firstline=Math.max(firstline,0);
  lastline++;
  lastline=Math.min(lastline,rend.totalScreenLines - 1);
  U.pf("String_Node_Str",firstline,lastline);
  for (int line=firstline; line <= lastline; line++) {
    Span span=rend.screenlineCharSpans.get(line);
    String str=GUtil.substring(doc.text,span);
    g.drawString(str,0,(line + 1) * lineHeight);
  }
  U.pf("String_Node_Str",(System.nanoTime() - t0) / 1e6);
}

Fixed version (ground truth):
void draw(Graphics2D g,int width){
  long t0=System.nanoTime();
  Rectangle clip=g.getClipBounds();
  Rendering rend=_rendering;
  if (rend == null) {
    return;
  }
  int lineHeight=getLineHeight();
  g.setColor(Color.WHITE);
  g.fillRect(clip.x,clip.y,clip.width,clip.height);
  g.setColor(Color.BLACK);
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_NORMALIZE);
  g.setFont(NORMAL_FONT);
  int firstline=clip.y / lineHeight;
  int lastline=(clip.y + clip.height) / lineHeight;
  firstline--;
  firstline=Math.max(firstline,0);
  lastline++;
  lastline=Math.min(lastline,rend.totalScreenLines - 1);
  for (int line=firstline; line <= lastline; line++) {
    Span span=rend.screenlineCharSpans.get(line);
    String str=GUtil.substring(doc.text,span);
    g.drawString(str,0,(line + 1) * lineHeight);
  }
}
Program: 86928
Project: 86928
Buggy source:
@Override public void componentResized(ComponentEvent e){
  U.p(e);
  rerenderText();
}

Fixed version (ground truth):
@Override public void componentResized(ComponentEvent e){
  launchTextRender();
}
Program: 86929
Project: 86929
Buggy source:
InternalTextArea(){
  addComponentListener(new ComponentAdapter(){
    @Override public void componentResized(    ComponentEvent e){
      U.p(e);
      rerenderText();
    }
  }
);
}

Fixed version (ground truth):
InternalTextArea(){
  addComponentListener(new ComponentAdapter(){
    @Override public void componentResized(    ComponentEvent e){
      launchTextRender();
    }
  }
);
}
Program: 86930
Project: 86930
Buggy source:
/** 
 * calculate all visible break positions for a given rendering width and font. includes both softbreaks (ones caused by wordwrap) as well as hardbreaks (forced by newlines)
 */
static List<Integer> calculateBreaks(Document doc,int width,FontMetrics fm){
  return calculateBreaks(doc,0,doc.text.length(),width,fm::stringWidth);
}

Fixed version (ground truth):
/** 
 * this can't handle hard breaks. only infers soft breaks. 
 */
public static List<Integer> calculateBreaks(Document doc,int charstart,int charend,int width,Function<String,Integer> widthMeasure){
}
Program: 86931
Project: 86931
Buggy source:
Rendering renderWordWrapping(int width){
  Rendering r=new Rendering();
  FontMetrics fm=new Canvas(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).getFontMetrics(NORMAL_FONT);
  for (int p=0; p < paragraphSpans.size(); p++) {
    Span pspan=paragraphSpans.get(p);
    Rendering.Paragraph pp=new Rendering.Paragraph();
    List<Integer> softbreaks=calculateBreaks(doc,pspan.start,pspan.end,width,fm::stringWidth);
    int nl=softbreaks.size() + 1;
    pp.numScreenLines=nl;
    if (p == 0) {
      pp.screenLinePosition=0;
    }
 else {
      Rendering.Paragraph prev=r.paragraphs.get(p - 1);
      pp.screenLinePosition=prev.numScreenLines + prev.screenLinePosition;
    }
    pp.screenlineCharSpans=GUtil.breakpointsToSpans(pspan.start,softbreaks,pspan.end);
    for (    Span scs : pp.screenlineCharSpans) {
      r.screenlineCharSpans.add(scs);
    }
    r.paragraphs.add(pp);
  }
  Rendering.Paragraph pp=r.paragraphs.get(r.paragraphs.size() - 1);
  r.totalScreenLines=pp.screenLinePosition + pp.numScreenLines;
  return r;
}

Fixed version (ground truth):
/** 
 * can fail with null if thread is interrupted 
 */
Rendering renderWordWrapping(int width){
  Rendering r=new Rendering();
  FontMetrics fm=new Canvas(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).getFontMetrics(NORMAL_FONT);
  for (int p=0; p < paragraphSpans.size(); p++) {
    if (Thread.interrupted()) {
      return null;
    }
    Span pspan=paragraphSpans.get(p);
    List<Integer> softbreaks=calculateBreaks(doc,pspan.start,pspan.end,width,fm::stringWidth);
    int nl=softbreaks.size() + 1;
    List<Span> screenlineCharSpans=GUtil.breakpointsToSpans(pspan.start,softbreaks,pspan.end);
    for (    Span scs : screenlineCharSpans) {
      r.screenlineCharSpans.add(scs);
    }
  }
  r.totalScreenLines=r.screenlineCharSpans.size();
  return r;
}
Program: 86932
Project: 86932
Buggy source:
/** 
 * 0, {4,8}, 10 ===> [0,4), [4,8), [8,10) 
 */
public static List<Span> breakpointsToSpans(int start,List<Integer> breakpoints,int end){
  List<Span> spans=new ArrayList<>();
  int curstart=0;
  for (  int p : breakpoints) {
    spans.add(new Span(curstart,p));
    curstart=p;
  }
  spans.add(new Span(curstart,end));
  return spans;
}

Fixed version (ground truth):
/** 
 * 0, {4,8}, 10 ===> [0,4), [4,8), [8,10) 
 */
public static List<Span> breakpointsToSpans(int start,List<Integer> breakpoints,int end){
  List<Span> spans=new ArrayList<>();
  int curstart=start;
  for (  int p : breakpoints) {
    spans.add(new Span(curstart,p));
    curstart=p;
  }
  spans.add(new Span(curstart,end));
  return spans;
}
Program: 86933
Project: 86933
Buggy source:
@Test public void spantests(){
  List<Span> spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(4,8),10);
  assertEquals(Lists.newArrayList(new Span(0,4),new Span(4,8),new Span(8,10)),spans);
  spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(),10);
  assertEquals(Lists.newArrayList(new Span(0,10)),spans);
}

Fixed version (ground truth):
@Test public void spantests(){
  List<Span> spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(4,8),10);
  assertEquals(Lists.newArrayList(new Span(0,4),new Span(4,8),new Span(8,10)),spans);
  spans=GUtil.breakpointsToSpans(0,Lists.newArrayList(),10);
  assertEquals(Lists.newArrayList(new Span(0,10)),spans);
  spans=GUtil.breakpointsToSpans(-4,Lists.newArrayList(3),10);
  assertEquals(Lists.newArrayList(new Span(-4,3),new Span(3,10)),spans);
}
Program: 86934
Project: 86934
Buggy source:
static List<Integer> possibleBreakpoints(Document doc){
  int curtok=0;
  int curchar=0;
  List<Integer> breaks=new ArrayList<>();
  while (true) {
    while (curchar <= doc.tokens.get(curtok).startChar) {
      breaks.add(curchar);
      curchar++;
    }
    curchar=doc.tokens.get(curtok).endChar;
    curtok++;
    if (curchar >= doc.text.length())     break;
    if (curtok >= doc.tokens.size()) {
      while (curchar < doc.text.length()) {
        breaks.add(curchar);
        curchar++;
      }
      break;
    }
  }
  return breaks;
}

Fixed version (ground truth):
public static List<Integer> possibleBreakpoints(Document doc,int charStart,int charEnd){
}
Program: 86935
Project: 86935
Buggy source:
/** 
 * calculate all visible break positions for a given rendering width and font. includes both softbreaks (ones caused by wordwrap) as well as hardbreaks (forced by newlines)
 */
static List<Integer> calculateBreaks(Document doc,int width,FontMetrics fm){
  return calculateBreaks(doc,width,fm::stringWidth);
}

Fixed version (ground truth):
/** 
 * calculate all visible break positions for a given rendering width and font. includes both softbreaks (ones caused by wordwrap) as well as hardbreaks (forced by newlines)
 */
static List<Integer> calculateBreaks(Document doc,int width,FontMetrics fm){
  return calculateBreaks(doc,0,doc.text.length(),width,fm::stringWidth);
}