nus-yam/ex-repair huggingface dataset:
Program: 86539
Project: 86539
Buggy source:
@Test @Ignore("String_Node_Str") public void testZeroFill_FindHighestMatchingBuildNumber(){
  final Set<String> versionSet=new HashSet<String>();
  final Version version=new Version("String_Node_Str");
  versionSet.add("String_Node_Str");
  assertThat(version.findHighestMatchingBuildNumber(version,versionSet),equalTo(2));
  versionSet.clear();
}

Fixed version (ground truth):
@Test public void testZeroFill_FindHighestMatchingBuildNumber(){
  final Set<String> versionSet=new HashSet<String>();
  final Version majorOnlyVersion=new Version("String_Node_Str");
  majorOnlyVersion.appendQualifierSuffix("String_Node_Str");
  System.out.println("String_Node_Str" + majorOnlyVersion.getOSGiVersionString());
  versionSet.add("String_Node_Str");
  assertThat(majorOnlyVersion.findHighestMatchingBuildNumber(majorOnlyVersion,versionSet),equalTo(2));
  versionSet.clear();
  final Version majorMinorVersion=new Version("String_Node_Str");
  majorMinorVersion.appendQualifierSuffix("String_Node_Str");
  System.out.println("String_Node_Str" + majorMinorVersion.getOSGiVersionString());
  versionSet.add("String_Node_Str");
  assertThat(majorMinorVersion.findHighestMatchingBuildNumber(majorMinorVersion,versionSet),equalTo(2));
  versionSet.clear();
}
Program: 86540
Project: 86540
Buggy source:
public Map<String,Plugin> getPluginMap(final ModelBase base){
  if (base instanceof Model) {
    final Build build=((Model)base).getBuild();
    if (build == null) {
      return Collections.<String,Plugin>emptyMap();
    }
    final Map<String,Plugin> result=build.getPluginsAsMap();
    if (result == null) {
      return Collections.<String,Plugin>emptyMap();
    }
    return result;
  }
  return Collections.<String,Plugin>emptyMap();
}

Fixed version (ground truth):
public Map<String,Plugin> getPluginMap(final ModelBase base){
  final BuildBase build;
  if (base instanceof Model) {
    build=((Model)base).getBuild();
  }
 else {
    build=((Profile)base).getBuild();
  }
  if (build == null) {
    return Collections.<String,Plugin>emptyMap();
  }
  final Map<String,Plugin> result=build.getPluginsAsMap();
  if (result == null) {
    return Collections.<String,Plugin>emptyMap();
  }
  return result;
}
Program: 86541
Project: 86541
Buggy source:
public List<Plugin> getManagedPlugins(final ModelBase base){
  if (base instanceof Model) {
    final Build build=((Model)base).getBuild();
    if (build == null) {
      return Collections.emptyList();
    }
    final PluginManagement pm=build.getPluginManagement();
    if (pm == null) {
      return Collections.emptyList();
    }
    final List<Plugin> result=pm.getPlugins();
    if (result == null) {
      return Collections.emptyList();
    }
    return result;
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
public List<Plugin> getManagedPlugins(final ModelBase base){
  BuildBase build;
  if (base instanceof Model) {
    build=((Model)base).getBuild();
  }
 else {
    build=((Profile)base).getBuild();
  }
  if (build == null) {
    return Collections.emptyList();
  }
  final PluginManagement pm=build.getPluginManagement();
  if (pm == null) {
    return Collections.emptyList();
  }
  final List<Plugin> result=pm.getPlugins();
  if (result == null) {
    return Collections.emptyList();
  }
  return result;
}
Program: 86542
Project: 86542
Buggy source:
private void assertSkip(final Model model,final String profileId,final boolean managed,final boolean deploy,final boolean state){
  final Build build=model.getBuild();
  assertThat(build,notNullValue());
  final Plugin plugin=build.getPluginsAsMap().get(ga(MAVEN_PLUGIN_GROUPID,deploy ? MAVEN_DEPLOY_ARTIFACTID : MAVEN_INSTALL_ARTIFACTID));
  assertThat(plugin,notNullValue());
  assertThat(plugin.getConfiguration().toString().contains("String_Node_Str" + state + "String_Node_Str"),equalTo(true));
}

Fixed version (ground truth):
private void assertSkip(final Model model,final String profileId,final boolean managed,final boolean deploy,final boolean state){
  BuildBase build=null;
  if (profileId != null) {
    final List<Profile> profiles=model.getProfiles();
    if (profiles != null) {
      for (      final Profile profile : profiles) {
        if (profileId.equals(profile.getId())) {
          build=profile.getBuild();
        }
      }
    }
  }
 else {
    build=model.getBuild();
  }
  assertThat(build,notNullValue());
  final Plugin plugin=build.getPluginsAsMap().get(ga(MAVEN_PLUGIN_GROUPID,deploy ? MAVEN_DEPLOY_ARTIFACTID : MAVEN_INSTALL_ARTIFACTID));
  assertThat(plugin,notNullValue());
  assertThat(plugin.getConfiguration().toString().contains("String_Node_Str" + state + "String_Node_Str"),equalTo(true));
}
Program: 86543
Project: 86543
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void onEvent(final Object event) throws Exception {
  try {
    if (event instanceof ExecutionEvent) {
      final ExecutionEvent ee=(ExecutionEvent)event;
      final ExecutionEvent.Type type=ee.getType();
switch (type) {
case ProjectDiscoveryStarted:
{
          if (ee.getSession() != null) {
            manipulationManager.init(ee.getSession(),session);
          }
          if (!session.isEnabled()) {
            logger.info("String_Node_Str");
            super.onEvent(event);
            return;
          }
          final MavenExecutionRequest req=session.getRequest();
          manipulationManager.scan(req.getPom(),session);
          final List<Project> projects=session.getProjects();
          for (          final Project project : projects) {
            logger.debug("String_Node_Str" + project + "String_Node_Str"+ project.getPom()+ "String_Node_Str");
          }
          manipulationManager.applyManipulations(projects,session);
          break;
        }
    }
    if (ee.getType() == Type.ProjectDiscoveryStarted) {
    }
  }
}
 catch (final ManipulationException e) {
  logger.error("String_Node_Str",e);
  session.setError(e);
}
super.onEvent(event);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void onEvent(final Object event) throws Exception {
  try {
    if (event instanceof ExecutionEvent) {
      final ExecutionEvent ee=(ExecutionEvent)event;
      final ExecutionEvent.Type type=ee.getType();
switch (type) {
case ProjectDiscoveryStarted:
{
          if (ee.getSession() != null) {
            manipulationManager.init(ee.getSession(),session);
            if (ee.getSession().getRequest().getLoggingLevel() == 0) {
              final ch.qos.logback.classic.Logger root=(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
              root.setLevel(Level.DEBUG);
            }
          }
          if (!session.isEnabled()) {
            logger.info("String_Node_Str");
            super.onEvent(event);
            return;
          }
          final MavenExecutionRequest req=session.getRequest();
          manipulationManager.scan(req.getPom(),session);
          final List<Project> projects=session.getProjects();
          for (          final Project project : projects) {
            logger.debug("String_Node_Str" + project + "String_Node_Str"+ project.getPom()+ "String_Node_Str");
          }
          manipulationManager.applyManipulations(projects,session);
          break;
        }
    }
    if (ee.getType() == Type.ProjectDiscoveryStarted) {
    }
  }
}
 catch (final ManipulationException e) {
  logger.error("String_Node_Str",e);
  session.setError(e);
}
super.onEvent(event);
}
Program: 86544
Project: 86544
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void onEvent(final Object event) throws Exception {
  try {
    if (event instanceof ExecutionEvent) {
      final ExecutionEvent ee=(ExecutionEvent)event;
      final ExecutionEvent.Type type=ee.getType();
switch (type) {
case ProjectDiscoveryStarted:
{
          if (ee.getSession() != null) {
            manipulationManager.init(ee.getSession(),session);
            if (ee.getSession().getRequest().getLoggingLevel() == 0) {
              final ch.qos.logback.classic.Logger root=(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
              root.setLevel(Level.DEBUG);
            }
          }
          if (!session.isEnabled()) {
            logger.info("String_Node_Str");
            super.onEvent(event);
            return;
          }
          final MavenExecutionRequest req=session.getRequest();
          manipulationManager.scan(req.getPom(),session);
          final List<Project> projects=session.getProjects();
          for (          final Project project : projects) {
            logger.debug("String_Node_Str" + project + "String_Node_Str"+ project.getPom()+ "String_Node_Str");
          }
          manipulationManager.applyManipulations(projects,session);
          break;
        }
    }
    if (ee.getType() == Type.ProjectDiscoveryStarted) {
    }
  }
}
 catch (final ManipulationException e) {
  logger.error("String_Node_Str",e);
  session.setError(e);
}
super.onEvent(event);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void onEvent(final Object event) throws Exception {
  try {
    if (event instanceof ExecutionEvent) {
      final ExecutionEvent ee=(ExecutionEvent)event;
      final ExecutionEvent.Type type=ee.getType();
switch (type) {
case ProjectDiscoveryStarted:
{
          if (ee.getSession() != null) {
            if (ee.getSession().getRequest().getLoggingLevel() == 0) {
              final ch.qos.logback.classic.Logger root=(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
              root.setLevel(Level.DEBUG);
            }
            manipulationManager.init(ee.getSession(),session);
          }
          if (!session.isEnabled()) {
            logger.info("String_Node_Str");
            super.onEvent(event);
            return;
          }
          final MavenExecutionRequest req=session.getRequest();
          manipulationManager.scan(req.getPom(),session);
          final List<Project> projects=session.getProjects();
          for (          final Project project : projects) {
            logger.debug("String_Node_Str" + project + "String_Node_Str"+ project.getPom()+ "String_Node_Str");
          }
          manipulationManager.applyManipulations(projects,session);
          break;
        }
    }
    if (ee.getType() == Type.ProjectDiscoveryStarted) {
    }
  }
}
 catch (final ManipulationException e) {
  logger.error("String_Node_Str",e);
  session.setError(e);
}
super.onEvent(event);
}
Program: 86545
Project: 86545
Buggy source:
/** 
 * Add properties to the build which match the version overrides. The property names are in the format
 * @param session
 */
private void addVersionOverrideProperties(final ManipulationSession session,final Map<String,String> overrides,final Properties props){
  final Properties properties=session.getUserProperties();
  VersionPropertyFormat result=VersionPropertyFormat.VG;
switch (VersionPropertyFormat.valueOf(properties.getProperty("String_Node_Str",VersionPropertyFormat.VG.toString()).toUpperCase())) {
case VG:
{
      result=VersionPropertyFormat.VG;
      break;
    }
case VGA:
{
    result=VersionPropertyFormat.VGA;
    break;
  }
case NONE:
{
  result=VersionPropertyFormat.NONE;
  return;
}
}
for (final String currentGA : overrides.keySet()) {
final String versionPropName="String_Node_Str" + (result == VersionPropertyFormat.VGA ? currentGA.replace("String_Node_Str","String_Node_Str") : currentGA.split("String_Node_Str")[0]);
props.setProperty(versionPropName,overrides.get(currentGA));
}
}

Fixed version (ground truth):
/** 
 * Add properties to the build which match the version overrides. The property names are in the format
 * @param session
 */
private void addVersionOverrideProperties(final ManipulationSession session,final Map<String,String> overrides,final Properties props){
  final Properties properties=session.getUserProperties();
  VersionPropertyFormat result=VersionPropertyFormat.VG;
switch (VersionPropertyFormat.valueOf(properties.getProperty("String_Node_Str",VersionPropertyFormat.VG.toString()).toUpperCase())) {
case VG:
{
      result=VersionPropertyFormat.VG;
      break;
    }
case VGA:
{
    result=VersionPropertyFormat.VGA;
    break;
  }
case NONE:
{
  result=VersionPropertyFormat.NONE;
  return;
}
}
for (final String currentGA : overrides.keySet()) {
logger.debug("String_Node_Str",currentGA,overrides.get(currentGA));
final String versionPropName="String_Node_Str" + (result == VersionPropertyFormat.VGA ? currentGA.replace("String_Node_Str","String_Node_Str") : currentGA.split("String_Node_Str")[0]);
props.setProperty(versionPropName,overrides.get(currentGA));
}
}
Program: 86546
Project: 86546
Buggy source:
public void setMavenSession(final MavenSession mavenSession){
  this.mavenSession=mavenSession;
}

Fixed version (ground truth):
public void setMavenSession(final MavenSession mavenSession){
  this.mavenSession=mavenSession;
  final File pom=mavenSession.getRequest().getPom();
  if (pom != null) {
    File dir=pom.getParentFile();
    if (dir == null) {
      dir=pom.getAbsoluteFile().getParentFile();
    }
    markerFile=new File(dir,"String_Node_Str");
  }
 else {
    markerFile=new File("String_Node_Str");
  }
}
Program: 86547
Project: 86547
Buggy source:
/** 
 * True (enabled) by default, this is the master kill switch for all manipulations. Manipulator implementations MAY also be enabled/disabled  individually.
 * @see #MANIPULATIONS_DISABLED_PROP
 * @see VersioningState#isEnabled()
 */
public boolean isEnabled(){
  return Boolean.valueOf(getUserProperties().getProperty(MANIPULATIONS_DISABLED_PROP,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * True (enabled) by default, this is the master kill switch for all manipulations. Manipulator implementations MAY also be enabled/disabled  individually.
 * @see #MANIPULATIONS_DISABLED_PROP
 * @see VersioningState#isEnabled()
 */
public boolean isEnabled(){
  return !Boolean.valueOf(getUserProperties().getProperty(MANIPULATIONS_DISABLED_PROP,"String_Node_Str"));
}
Program: 86548
Project: 86548
Buggy source:
public VersioningState(final Properties userProps){
  suffix=userProps.getProperty(VERSION_SUFFIX_SYSPROP);
  incrementSerialSuffix=userProps.getProperty(INCREMENT_SERIAL_SUFFIX_SYSPROP);
  preserveSnapshot=Boolean.parseBoolean(userProps.getProperty(VERSION_SUFFIX_SNAPSHOT_SYSPROP));
}

Fixed version (ground truth):
public VersioningState(final Properties userProps){
  suffix=userProps.getProperty(VERSION_SUFFIX_SYSPROP);
  incrementSerialSuffix=userProps.getProperty(INCREMENT_SERIAL_SUFFIX_SYSPROP);
  preserveSnapshot=Boolean.parseBoolean(userProps.getProperty(VERSION_SUFFIX_SNAPSHOT_SYSPROP));
  Logger.getLogger(getClass().getName()).info(String.format("String_Node_Str",suffix,incrementSerialSuffix,preserveSnapshot));
}
Program: 86550
Project: 86550
Buggy source:
public void applyFullGameState(NetGameState gs){
  clearGameState();
  applyGameStats(gs.stats);
  if (gs.entities != null) {
    int size=gs.entities.length;
    for (int i=0; i < size; i++) {
      NetEntity netEnt=gs.entities[i];
      if (netEnt != null) {
        createEntity(netEnt);
      }
    }
  }
  NetGameTypeInfo gameType=gs.gameType;
  if (gameType != null) {
    this.gameType=GameType.Type.fromNet(gameType.type);
    if (gameType.alliedTeam.isAttacker) {
      this.attackingTeam=ClientTeam.fromId(gameType.alliedTeam.id);
    }
 else {
      this.attackingTeam=ClientTeam.fromId(gameType.axisTeam.id);
    }
    if (gameType.alliedTeam.isDefender) {
      this.defendingTeam=ClientTeam.fromId(gameType.alliedTeam.id);
    }
 else {
      this.defendingTeam=ClientTeam.fromId(gameType.axisTeam.id);
    }
    if (this.gameType == GameType.Type.CMD) {
    }
 else     if (this.gameType == GameType.Type.CTF) {
      NetCtfGameTypeInfo ctfInfo=(NetCtfGameTypeInfo)gameType;
      this.gameEffects.addCtfInformation(ctfInfo);
    }
  }
  NetMapDestructables destructables=gs.mapDestructables;
  if (destructables != null) {
    this.map.removeDestructableTilesAt(destructables.tiles);
  }
}

Fixed version (ground truth):
public void applyFullGameState(NetGameState gs){
  clearGameState();
  applyGameStats(gs.stats);
  if (gs.entities != null) {
    int size=gs.entities.length;
    for (int i=0; i < size; i++) {
      NetEntity netEnt=gs.entities[i];
      if (netEnt != null) {
        createEntity(netEnt);
      }
    }
  }
  NetGameTypeInfo gameType=gs.gameType;
  if (gameType != null) {
    this.gameType=GameType.Type.fromNet(gameType.type);
    if (gameType.alliedTeam.isAttacker) {
      this.attackingTeam=ClientTeam.fromId(gameType.alliedTeam.id);
    }
 else {
      this.attackingTeam=ClientTeam.fromId(gameType.axisTeam.id);
    }
    if (gameType.alliedTeam.isDefender) {
      this.defendingTeam=ClientTeam.fromId(gameType.alliedTeam.id);
    }
 else {
      this.defendingTeam=ClientTeam.fromId(gameType.axisTeam.id);
    }
    if (this.gameType == GameType.Type.CMD) {
    }
 else     if (this.gameType == GameType.Type.CTF) {
      NetCtfGameTypeInfo ctfInfo=(NetCtfGameTypeInfo)gameType;
      this.gameEffects.addCtfInformation(ctfInfo);
    }
  }
  NetMapDestructables destructables=gs.mapDestructables;
  if (destructables != null) {
    this.map.removeDestructableTilesAt(destructables.tiles);
  }
  NetMapAdditions additions=gs.mapAdditions;
  if (additions != null && additions.tiles != null) {
    for (int i=0; i < additions.tiles.length; i++) {
      NetMapAddition addition=additions.tiles[i];
      addTile(addition);
    }
  }
}
Program: 86551
Project: 86551
Buggy source:
@Override protected GameState doUpdate(Game game,TimeStep timeStep){
  this.startTimer.update(timeStep);
  if (this.startTimer.isOnFirstTime()) {
    this.availablePlayers.clear();
    initializeGame(game);
    for (    Player player : getAxisTeam().getPlayers()) {
      this.availablePlayers.add(player);
    }
    for (    Player player : getAlliedTeam().getPlayers()) {
      super.spawnPlayer(player,game);
    }
    getDispatcher().queueEvent(new RoundStartedEvent(this));
  }
  return this.currentGameState;
}

Fixed version (ground truth):
@Override protected GameState doUpdate(Game game,TimeStep timeStep){
  this.startTimer.update(timeStep);
  if (this.startTimer.isOnFirstTime()) {
    this.availablePlayers.clear();
    initializeGame(game);
    for (    Player player : getAxisTeam().getPlayers()) {
      this.availablePlayers.add(player);
    }
    for (    Player player : getAlliedTeam().getPlayers()) {
      super.spawnPlayer(player,game);
    }
    getDispatcher().queueEvent(new RoundStartedEvent(this));
  }
  checkSpectating(timeStep,game);
  return this.currentGameState;
}
Program: 86552
Project: 86552
Buggy source:
public boolean canAddTile(Vector2f tilePos){
  int tileX=(int)tilePos.x;
  int tileY=(int)tilePos.y;
  if (!map.hasWorldCollidableTile(tileX,tileY)) {
    Tile groundTile=map.getWorldTile(0,tileX,tileY);
    Rectangle bounds=groundTile.getBounds();
    for (int i=0; i < this.players.getMaxNumberOfPlayers(); i++) {
      ClientPlayer player=this.players.getPlayer(i);
      if (player != null && player.isAlive()) {
        ClientPlayerEntity ent=player.getEntity();
        if (ent.isRelativelyUpdated() && ent.getBounds().intersects(bounds)) {
          return false;
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean canAddTile(Vector2f tilePos){
  int tileX=(int)tilePos.x;
  int tileY=(int)tilePos.y;
  if (!map.hasWorldCollidableTile(tileX,tileY)) {
    Tile groundTile=map.getWorldTile(0,tileX,tileY);
    if (groundTile == null) {
      return false;
    }
    Rectangle bounds=groundTile.getBounds();
    for (int i=0; i < this.players.getMaxNumberOfPlayers(); i++) {
      ClientPlayer player=this.players.getPlayer(i);
      if (player != null && player.isAlive()) {
        ClientPlayerEntity ent=player.getEntity();
        if (ent.isRelativelyUpdated() && ent.getBounds().intersects(bounds)) {
          return false;
        }
      }
    }
    return true;
  }
  return false;
}
Program: 86554
Project: 86554
Buggy source:
@Override public void render(Canvas canvas,Camera camera,float alpha){
  if (this.loadAssets && this.sprite != null) {
    Vector2f cameraPos=camera.getRenderPosition(alpha);
    float x=this.pos.x - cameraPos.x;
    float y=this.pos.y - cameraPos.y;
    this.sprite.setPosition(x,y);
    canvas.drawRawSprite(this.sprite);
  }
}

Fixed version (ground truth):
@Override public void render(Canvas canvas,Camera camera,float alpha){
  if (this.loadAssets && this.sprite != null) {
    Vector2f cameraPos=camera.getRenderPosition(alpha);
    Vector2f pos=centerSprite ? getCenterPos() : this.pos;
    float x=pos.x - cameraPos.x;
    float y=pos.y - cameraPos.y;
    this.sprite.setPosition(x,y);
    canvas.drawRawSprite(this.sprite);
  }
}
Program: 86555
Project: 86555
Buggy source:
private void renderMapObjects(Canvas canvas,Camera camera,float alpha){
  Rectangle viewport=camera.getWorldViewPort();
  for (int i=0; i < this.mapObjects.size(); i++) {
    MapObject object=this.mapObjects.get(i);
    if (viewport.intersects(object.getBounds())) {
      object.render(canvas,camera,alpha);
    }
  }
}

Fixed version (ground truth):
private void renderMapObjects(Canvas canvas,Camera camera,float alpha,List<MapObject> mapObjects){
  Rectangle viewport=camera.getWorldViewPort();
  for (int i=0; i < mapObjects.size(); i++) {
    MapObject object=mapObjects.get(i);
    if (viewport.intersects(object.getBounds())) {
      object.render(canvas,camera,alpha);
    }
  }
}
Program: 86557
Project: 86557
Buggy source:
public void destroy(){
  if (this.backgroundLayers != null) {
    for (int i=0; i < this.backgroundLayers.length; i++) {
      Layer layer=this.backgroundLayers[i];
      if (layer == null) {
        continue;
      }
      for (int j=0; j < this.backgroundLayers[i].numberOfRows(); j++) {
        this.backgroundLayers[i].destroy();
      }
      this.backgroundLayers[i]=null;
    }
  }
  this.backgroundLayers=null;
  if (this.foregroundLayers != null) {
    for (int i=0; i < this.foregroundLayers.length; i++) {
      Layer layer=this.foregroundLayers[i];
      if (layer == null) {
        continue;
      }
      for (int j=0; j < this.foregroundLayers[i].numberOfRows(); j++) {
        this.foregroundLayers[i].destroy();
      }
      this.foregroundLayers[i]=null;
    }
  }
  this.foregroundLayers=null;
  this.collidableLayers=null;
  this.surfaces=null;
  this.mapOffset=null;
  this.backgroundImage=null;
  this.mapHeight=0;
  this.mapWidth=0;
  this.maxX=0;
  this.maxY=0;
  this.tileHeight=0;
  this.tileWidth=0;
  this.destroyedTiles.clear();
  this.destructableLayer=null;
  if (this.backgroundImage != null) {
    this.backgroundImage.getTexture().dispose();
  }
  if (this.atlas != null) {
    this.atlas.destroy();
  }
  if (this.mapObjects != null) {
    for (    MapObject object : this.mapObjects) {
      object.destroy();
    }
    this.mapObjects.clear();
  }
}

Fixed version (ground truth):
public void destroy(){
  if (this.backgroundLayers != null) {
    for (int i=0; i < this.backgroundLayers.length; i++) {
      Layer layer=this.backgroundLayers[i];
      if (layer == null) {
        continue;
      }
      for (int j=0; j < this.backgroundLayers[i].numberOfRows(); j++) {
        this.backgroundLayers[i].destroy();
      }
      this.backgroundLayers[i]=null;
    }
  }
  this.backgroundLayers=null;
  if (this.foregroundLayers != null) {
    for (int i=0; i < this.foregroundLayers.length; i++) {
      Layer layer=this.foregroundLayers[i];
      if (layer == null) {
        continue;
      }
      for (int j=0; j < this.foregroundLayers[i].numberOfRows(); j++) {
        this.foregroundLayers[i].destroy();
      }
      this.foregroundLayers[i]=null;
    }
  }
  this.foregroundLayers=null;
  this.collidableLayers=null;
  this.surfaces=null;
  this.mapOffset=null;
  this.backgroundImage=null;
  this.mapHeight=0;
  this.mapWidth=0;
  this.maxX=0;
  this.maxY=0;
  this.tileHeight=0;
  this.tileWidth=0;
  this.destroyedTiles.clear();
  this.destructableLayer=null;
  if (this.backgroundImage != null) {
    this.backgroundImage.getTexture().dispose();
  }
  if (this.atlas != null) {
    this.atlas.destroy();
  }
  if (this.mapObjects != null) {
    for (    MapObject object : this.mapObjects) {
      object.destroy();
    }
    this.mapObjects.clear();
    this.foregroundMapObjects.clear();
    this.backgroundMapObjects.clear();
  }
}
Program: 86558
Project: 86558
Buggy source:
/** 
 * Constructs a new   {@link OrthoMap}.
 */
public OrthoMap(boolean loadAssets){
  this.currentFrameViewport=new Rectangle();
  this.destroyedTiles=new ArrayList<Tile>();
  this.addedTiles=new ArrayList<>();
  this.collisionTilePos=new Vector2f();
  if (loadAssets) {
    this.shadeTilesLookup=new HashMap<Integer,TextureRegion>();
  }
  destroy();
}

Fixed version (ground truth):
/** 
 * Constructs a new   {@link OrthoMap}.
 */
public OrthoMap(boolean loadAssets){
  this.currentFrameViewport=new Rectangle();
  this.destroyedTiles=new ArrayList<Tile>();
  this.addedTiles=new ArrayList<>();
  this.collisionTilePos=new Vector2f();
  this.backgroundMapObjects=new ArrayList<>();
  this.foregroundMapObjects=new ArrayList<>();
  if (loadAssets) {
    this.shadeTilesLookup=new HashMap<Integer,TextureRegion>();
  }
  destroy();
}
Program: 86560
Project: 86560
Buggy source:
public void renderForeground(Canvas canvas,Camera camera,float alpha){
  Vector2f camPos=camera.getRenderPosition(alpha);
  Rectangle viewport=camera.getViewPort();
  int vx=viewport.getX();
  int vy=viewport.getY();
  int pixelX=0;
  int pixelY=0;
  int indexX=0;
  int indexY=0;
  int toIndex_x=0, toIndex_y=0;
  int tileOffset_x=-((int)camPos.x % this.tileWidth);
  toIndex_x=(tileOffset_x + (int)camPos.x) / this.tileWidth;
  int tileOffset_y=-((int)camPos.y % this.tileHeight);
  toIndex_y=(tileOffset_y + (int)camPos.y) / this.tileHeight;
  indexY=toIndex_y;
  for (pixelY=tileOffset_y; pixelY < viewport.getHeight() && indexY < this.maxY; pixelY+=this.tileHeight, indexY++) {
    for (pixelX=tileOffset_x, indexX=toIndex_x; pixelX < viewport.getWidth() && indexX < this.maxX; pixelX+=this.tileWidth, indexX++) {
      if ((indexY >= 0 && indexX >= 0) && (indexY < this.maxY && indexX < this.maxX)) {
        for (int i=0; i < this.foregroundLayers.length; i++) {
          Layer layer=this.foregroundLayers[i];
          if (layer == null) {
            continue;
          }
          if (layer.isPropertyLayer()) {
            continue;
          }
          Tile tile=layer.getRow(indexY)[indexX];
          if (tile != null) {
            tile.setRenderingPosition(pixelX + vx,pixelY + vy);
            tile.render(canvas,camera,alpha);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void renderForeground(Canvas canvas,Camera camera,float alpha){
  Vector2f camPos=camera.getRenderPosition(alpha);
  Rectangle viewport=camera.getViewPort();
  int vx=viewport.getX();
  int vy=viewport.getY();
  int pixelX=0;
  int pixelY=0;
  int indexX=0;
  int indexY=0;
  int toIndex_x=0, toIndex_y=0;
  int tileOffset_x=-((int)camPos.x % this.tileWidth);
  toIndex_x=(tileOffset_x + (int)camPos.x) / this.tileWidth;
  int tileOffset_y=-((int)camPos.y % this.tileHeight);
  toIndex_y=(tileOffset_y + (int)camPos.y) / this.tileHeight;
  indexY=toIndex_y;
  for (pixelY=tileOffset_y; pixelY < viewport.getHeight() && indexY < this.maxY; pixelY+=this.tileHeight, indexY++) {
    for (pixelX=tileOffset_x, indexX=toIndex_x; pixelX < viewport.getWidth() && indexX < this.maxX; pixelX+=this.tileWidth, indexX++) {
      if ((indexY >= 0 && indexX >= 0) && (indexY < this.maxY && indexX < this.maxX)) {
        for (int i=0; i < this.foregroundLayers.length; i++) {
          Layer layer=this.foregroundLayers[i];
          if (layer == null) {
            continue;
          }
          if (layer.isPropertyLayer()) {
            continue;
          }
          Tile tile=layer.getRow(indexY)[indexX];
          if (tile != null) {
            tile.setRenderingPosition(pixelX + vx,pixelY + vy);
            tile.render(canvas,camera,alpha);
          }
        }
      }
    }
  }
  renderMapObjects(canvas,camera,alpha,this.foregroundMapObjects);
}
Program: 86561
Project: 86561
Buggy source:
/** 
 * @param game
 * @param owner
 */
public RocketLauncher(Game game,Entity owner){
  super(game,owner,Type.ROCKET_LAUNCHER);
  this.damage=120;
  this.reloadTime=0;
  this.clipSize=5;
  this.totalAmmo=0;
  this.bulletsInClip=this.clipSize;
  this.lineOfSight=WeaponConstants.RPG_LINE_OF_SIGHT;
  this.weaponWeight=WeaponConstants.RPG_WEIGHT;
  applyScriptAttributes("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param game
 * @param owner
 */
public RocketLauncher(Game game,Entity owner){
  super(game,owner,Type.ROCKET_LAUNCHER);
  this.damage=120;
  this.reloadTime=0;
  this.clipSize=5;
  this.totalAmmo=0;
  this.bulletsInClip=this.clipSize;
  this.lineOfSight=WeaponConstants.RPG_LINE_OF_SIGHT;
  this.weaponWeight=WeaponConstants.RPG_WEIGHT;
  this.endFire=true;
  applyScriptAttributes("String_Node_Str");
}
Program: 86562
Project: 86562
Buggy source:
/** 
 * Loads any map scripts and/or special entities associated with the game map.  This should be invoked every time a new Round begins  
 */
private void loadMapScripts(){
  File propertiesFile=new File(gameMap.getMapFileName() + "String_Node_Str");
  if (propertiesFile.exists()) {
    try {
      this.eventRegistration.unregisterListeners();
      Leola runtime=Scripting.newSandboxedRuntime();
      runtime.loadStatics(SeventhScriptingCommonLibrary.class);
      GameServerLeolaLibrary gLib=new GameServerLeolaLibrary(this);
      runtime.loadLibrary(gLib,"String_Node_Str");
      AILeolaLibrary aiLib=new AILeolaLibrary(this.aiSystem);
      runtime.loadLibrary(aiLib,"String_Node_Str");
      runtime.put("String_Node_Str",this);
      runtime.eval(propertiesFile);
      this.collidableMapObjects.clear();
      List<MapObject> objects=map.getMapObjects();
      for (int i=0; i < objects.size(); i++) {
        MapObject mapObject=objects.get(i);
        mapObject.onLoad(this);
        if (mapObject.isCollidable()) {
          this.collidableMapObjects.add(mapObject);
        }
      }
    }
 catch (    Exception e) {
      Cons.println("String_Node_Str" + propertiesFile.getName() + "String_Node_Str");
      Cons.println(e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Loads any map scripts and/or special entities associated with the game map.  This should be invoked every time a new Round begins  
 */
private void loadMapScripts(){
  this.eventRegistration.unregisterListeners();
  File propertiesFile=new File(gameMap.getMapFileName() + "String_Node_Str");
  if (propertiesFile.exists()) {
    try {
      Leola runtime=Scripting.newSandboxedRuntime();
      runtime.loadStatics(SeventhScriptingCommonLibrary.class);
      GameServerLeolaLibrary gLib=new GameServerLeolaLibrary(this);
      runtime.loadLibrary(gLib,"String_Node_Str");
      AILeolaLibrary aiLib=new AILeolaLibrary(this.aiSystem);
      runtime.loadLibrary(aiLib,"String_Node_Str");
      runtime.put("String_Node_Str",this);
      runtime.eval(propertiesFile);
    }
 catch (    Exception e) {
      Cons.println("String_Node_Str" + propertiesFile.getName() + "String_Node_Str");
      Cons.println(e);
    }
  }
  this.collidableMapObjects.clear();
  List<MapObject> objects=map.getMapObjects();
  for (int i=0; i < objects.size(); i++) {
    MapObject mapObject=objects.get(i);
    mapObject.onLoad(this);
    if (mapObject.isCollidable()) {
      this.collidableMapObjects.add(mapObject);
    }
  }
}
Program: 86563
Project: 86563
Buggy source:
@Override public void damage(Entity damager,int amount){
  if (damager instanceof Explosion) {
    amount=1;
  }
 else   if (damager instanceof Rocket) {
  }
 else   if (damager instanceof Bullet) {
    amount=0;
  }
 else {
    amount/=10;
  }
  armor-=amount;
  if (armor < 0) {
    super.damage(damager,amount);
  }
}

Fixed version (ground truth):
@Override public void damage(Entity damager,int amount){
  if (damager instanceof Explosion) {
    amount=1;
  }
 else   if (damager instanceof Rocket) {
  }
 else   if (damager instanceof Bullet) {
    amount=0;
  }
 else {
    amount/=10;
  }
  armor-=amount;
  if (armor < 0) {
    super.damage(damager,amount);
  }
 else {
    if (damager instanceof Bullet) {
      Bullet bullet=(Bullet)damager;
      bullet.kill(this);
      game.emitSound(bullet.getId(),SoundType.IMPACT_METAL,bullet.getCenterPos());
    }
  }
}
Program: 86564
Project: 86564
Buggy source:
@Override protected NetGameTypeInfo createNetGameTypeInfo(){
  this.netGameTypeInfo=new NetCommanderGameTypeInfo();
  return this.netGameTypeInfo;
}

Fixed version (ground truth):
@Override protected NetGameTypeInfo createNetGameTypeInfo(){
  this.netGameTypeInfo=new NetCommanderGameTypeInfo();
  this.netGameTypeInfo.alliedSquad=new NetSquad();
  this.netGameTypeInfo.axisSquad=new NetSquad();
  return this.netGameTypeInfo;
}
Program: 86565
Project: 86565
Buggy source:
/** 
 * Picks a semi-random weapon.  It may attempt to pick  a weapon based on the world (this is chosen randomly).
 * @param team
 * @return the weapon type
 */
private Type getRandomWeapon(Team team){
  int index=-1;
  if (team != null) {
    PlayerClass playerClass=this.brain.getPlayer().getPlayerClass();
    List<WeaponEntry> availableWeapons=playerClass.getAvailableWeapons();
    int max=availableWeapons.size();
    boolean pickSmart=random.nextBoolean();
    if (pickSmart) {
      index=pickThoughtfulWeapon(team,availableWeapons);
    }
 else {
      index=random.nextInt(max);
    }
    return availableWeapons.get(index).type;
  }
  return Type.UNKNOWN;
}

Fixed version (ground truth):
/** 
 * Picks a semi-random weapon.  It may attempt to pick  a weapon based on the world (this is chosen randomly).
 * @param team
 * @return the weapon type
 */
private Type getRandomWeapon(Team team){
  int index=-1;
  if (team != null) {
    PlayerClass playerClass=this.brain.getPlayer().getPlayerClass();
    List<WeaponEntry> availableWeapons=playerClass.getAvailableWeapons();
    int max=availableWeapons.size();
    if (max > 3) {
      if (random.nextInt(4) != 1) {
        max-=1;
      }
    }
    boolean pickSmart=random.nextBoolean();
    if (pickSmart) {
      index=pickThoughtfulWeapon(team,availableWeapons);
    }
 else {
      index=random.nextInt(max);
    }
    return availableWeapons.get(index).type.getTeamWeapon(team);
  }
  return Type.UNKNOWN;
}
Program: 86566
Project: 86566
Buggy source:
/** 
 * @param healthMultiplier
 * @param speedMultiplier
 * @param damageMultiplier
 * @param availableWeapons
 * @param defaultWeapons
 * @param defaultPrimaryWeapon
 */
public PlayerClass(int healthMultiplier,int speedMultiplier,int damageMultiplier,List<WeaponEntry> availableWeapons,List<WeaponEntry> defaultWeapons,Type defaultPrimaryWeapon){
  this.healthMultiplier=healthMultiplier;
  this.speedMultiplier=speedMultiplier;
  this.damageMultiplier=damageMultiplier;
  this.availableWeapons=availableWeapons;
  this.defaultWeapons=defaultWeapons;
  this.defaultPrimaryWeapon=defaultPrimaryWeapon;
}

Fixed version (ground truth):
/** 
 * @param healthMultiplier
 * @param speedMultiplier
 * @param damageMultiplier
 * @param availableWeapons
 * @param defaultWeapons
 * @param defaultPrimaryWeapon
 */
public void PlayerClass(int healthMultiplier,int speedMultiplier,int damageMultiplier,List<WeaponEntry> availableWeapons,List<WeaponEntry> defaultWeapons,WeaponClass defaultPrimaryWeapon){
  this.healthMultiplier=healthMultiplier;
  this.speedMultiplier=speedMultiplier;
  this.damageMultiplier=damageMultiplier;
  this.availableWeapons=availableWeapons;
  this.defaultWeapons=defaultWeapons;
  this.defaultPrimaryWeapon=defaultPrimaryWeapon;
}
Program: 86567
Project: 86567
Buggy source:
private static WeaponEntry entry(Type type){
  return entry(type,-1);
}

Fixed version (ground truth):
private static WeaponEntry entry(WeaponClass type){
  return entry(type,-1);
}
Program: 86568
Project: 86568
Buggy source:
/** 
 * Get the   {@link WeaponEntry} for the supplied weapontype
 * @param weaponType
 * @return the {@link WeaponEntry} or null if not an option
 */
public WeaponEntry getAvailableWeaponEntry(Type weaponType){
  for (int i=0; i < availableWeapons.size(); i++) {
    WeaponEntry entry=availableWeapons.get(i);
    if (entry.type == weaponType) {
      return entry;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the   {@link WeaponEntry} for the supplied weapontype
 * @param weaponType
 * @return the {@link WeaponEntry} or null if not an option
 */
public WeaponEntry getAvailableWeaponEntry(Type weaponType){
  for (int i=0; i < availableWeapons.size(); i++) {
    WeaponEntry entry=availableWeapons.get(i);
    if (entry.type.hasWeapon(weaponType)) {
      return entry;
    }
  }
  return null;
}
Program: 86569
Project: 86569
Buggy source:
public WeaponEntry(Type type,int ammoBag){
  this.type=type;
  this.ammoBag=ammoBag;
}

Fixed version (ground truth):
public WeaponEntry(WeaponClass type,int ammoBag){
  this.type=type;
  this.ammoBag=ammoBag;
}
Program: 86570
Project: 86570
Buggy source:
/** 
 * @return the defaultPrimaryWeapon
 */
public Type getDefaultPrimaryWeapon(){
  return defaultPrimaryWeapon;
}

Fixed version (ground truth):
/** 
 * @return the defaultPrimaryWeapon
 */
public WeaponClass getDefaultPrimaryWeapon(){
  return defaultPrimaryWeapon;
}
Program: 86571
Project: 86571
Buggy source:
/** 
 * Apply the player class
 * @param playerClass
 * @param activeWeapon
 * @return true if success, false otherwise
 */
public void setPlayerClass(PlayerClass playerClass,Type activeWeapon){
  if (!playerClass.isAvailableWeapon(activeWeapon)) {
    activeWeapon=playerClass.getDefaultPrimaryWeapon();
  }
  this.inventory.clear();
  WeaponEntry weaponEntry=playerClass.getAvailableWeaponEntry(activeWeapon);
  Weapon currentWeapon=createWeapon(weaponEntry);
  if (currentWeapon != null) {
    this.inventory.addItem(currentWeapon);
  }
  List<WeaponEntry> weapons=playerClass.getDefaultWeapons();
  for (int i=0; i < weapons.size(); i++) {
    WeaponEntry entry=weapons.get(i);
    Weapon weapon=createWeapon(entry);
    if (weapon != null) {
      this.inventory.addItem(weapon);
    }
  }
  checkLineOfSightChange();
}

Fixed version (ground truth):
/** 
 * Apply the player class
 * @param playerClass
 * @param activeWeapon
 * @return true if success, false otherwise
 */
public void setPlayerClass(PlayerClass playerClass,Type activeWeapon){
  if (!playerClass.isAvailableWeapon(activeWeapon)) {
    activeWeapon=playerClass.getDefaultPrimaryWeapon().getTeamWeapon(getTeam());
  }
  this.inventory.clear();
  WeaponEntry weaponEntry=playerClass.getAvailableWeaponEntry(activeWeapon);
  Weapon currentWeapon=createWeapon(weaponEntry);
  if (currentWeapon != null) {
    this.inventory.addItem(currentWeapon);
  }
  List<WeaponEntry> weapons=playerClass.getDefaultWeapons();
  for (int i=0; i < weapons.size(); i++) {
    WeaponEntry entry=weapons.get(i);
    Weapon weapon=createWeapon(entry);
    if (weapon != null) {
      this.inventory.addItem(weapon);
    }
  }
  checkLineOfSightChange();
}
Program: 86572
Project: 86572
Buggy source:
private Weapon createWeapon(WeaponEntry entry){
  Weapon weapon=null;
switch (entry.type) {
case SPRINGFIELD:
case KAR98:
    weapon=isAlliedPlayer() ? new Springfield(game,this) : new Kar98(game,this);
  break;
case THOMPSON:
case MP40:
weapon=isAlliedPlayer() ? new Thompson(game,this) : new MP40(game,this);
break;
case M1_GARAND:
case MP44:
weapon=isAlliedPlayer() ? new M1Garand(game,this) : new MP44(game,this);
break;
case PISTOL:
weapon=new Pistol(game,this);
break;
case HAMMER:
weapon=new Hammer(game,this);
break;
case SHOTGUN:
weapon=new Shotgun(game,this);
break;
case RISKER:
weapon=new Risker(game,this);
break;
case ROCKET_LAUNCHER:
weapon=new RocketLauncher(game,this);
break;
case FLAME_THROWER:
weapon=new FlameThrower(game,this);
break;
case GRENADE:
weapon=GrenadeBelt.newFrag(game,this,entry.ammoBag);
break;
case SMOKE_GRENADE:
weapon=GrenadeBelt.newSmoke(game,this,entry.ammoBag);
break;
default :
}
if (weapon != null && entry.ammoBag > -1) {
weapon.setTotalAmmo(entry.ammoBag);
}
return weapon;
}

Fixed version (ground truth):
private Weapon createWeapon(WeaponEntry entry){
  Weapon weapon=null;
switch (entry.type.getTeamWeapon(getTeam())) {
case SPRINGFIELD:
case KAR98:
    weapon=isAlliedPlayer() ? new Springfield(game,this) : new Kar98(game,this);
  break;
case THOMPSON:
case MP40:
weapon=isAlliedPlayer() ? new Thompson(game,this) : new MP40(game,this);
break;
case M1_GARAND:
case MP44:
weapon=isAlliedPlayer() ? new M1Garand(game,this) : new MP44(game,this);
break;
case PISTOL:
weapon=new Pistol(game,this);
break;
case HAMMER:
weapon=new Hammer(game,this);
break;
case SHOTGUN:
weapon=new Shotgun(game,this);
break;
case RISKER:
weapon=new Risker(game,this);
break;
case ROCKET_LAUNCHER:
weapon=new RocketLauncher(game,this);
break;
case FLAME_THROWER:
weapon=new FlameThrower(game,this);
break;
case GRENADE:
weapon=GrenadeBelt.newFrag(game,this,entry.ammoBag);
break;
case SMOKE_GRENADE:
weapon=GrenadeBelt.newSmoke(game,this,entry.ammoBag);
break;
default :
}
if (weapon != null && entry.ammoBag > -1) {
weapon.setTotalAmmo(entry.ammoBag);
}
return weapon;
}
Program: 86573
Project: 86573
Buggy source:
public static double weaponStrengthScore(Weapon weapon){
  double score=0;
  if (weapon != null) {
switch (weapon.getType()) {
case PISTOL:
      score=0.2;
    break;
case ROCKET_LAUNCHER:
  score=0.5;
break;
case MP40:
score=0.7;
break;
case THOMPSON:
score=0.7;
break;
case KAR98:
score=0.8;
break;
case M1_GARAND:
score=0.8;
break;
case MP44:
score=0.8;
break;
case MG42:
score=0.8;
break;
case RISKER:
score=0.8;
break;
case SHOTGUN:
score=0.8;
break;
case SPRINGFIELD:
score=0.8;
break;
case FLAME_THROWER:
score=0.75;
break;
default :
break;
}
}
return score;
}

Fixed version (ground truth):
public static double weaponStrengthScore(Weapon weapon){
  double score=0;
  if (weapon != null) {
switch (weapon.getType()) {
case PISTOL:
      score=0.2;
    break;
case ROCKET_LAUNCHER:
  score=0.6;
break;
case MP40:
score=0.7;
break;
case THOMPSON:
score=0.7;
break;
case KAR98:
score=0.8;
break;
case M1_GARAND:
score=0.8;
break;
case MP44:
score=0.8;
break;
case MG42:
score=0.8;
break;
case RISKER:
score=0.8;
break;
case SHOTGUN:
score=0.8;
break;
case SPRINGFIELD:
score=0.8;
break;
case FLAME_THROWER:
score=0.75;
break;
default :
break;
}
}
return score;
}
Program: 86574
Project: 86574
Buggy source:
/** 
 * Current weapon score (only accounts for bullets in clip)
 * @param ent
 * @return
 */
public static double weaponAmmoScore(Weapon weapon){
  double score=0;
  if (weapon != null) {
    double clipSize=(double)weapon.getClipSize();
    if (clipSize != 0) {
      return (double)weapon.getBulletsInClip() / clipSize;
    }
  }
  return score;
}

Fixed version (ground truth):
/** 
 * Current weapon score (only accounts for bullets in clip)
 * @param ent
 * @return
 */
public static double weaponAmmoScore(Weapon weapon){
  double score=0;
  if (weapon != null) {
    double clipSize=(double)weapon.getClipSize();
    if (clipSize != 0) {
      return (double)weapon.getBulletsInClip() / clipSize;
    }
 else {
      if (weapon.getBulletsInClip() > 0) {
        score+=0.1;
      }
    }
  }
  return score;
}
Program: 86575
Project: 86575
Buggy source:
@Override public double calculateDesirability(Brain brain){
  double desire=0.0;
  Inventory inventory=brain.getEntityOwner().getInventory();
  if (inventory.numberOfItems() > 1) {
    Weapon weapon=inventory.currentItem();
    if (weapon != null) {
      if (weapon.isReady()) {
        if (weapon.getTotalAmmo() <= 0) {
          desire=1;
        }
        Weapon bestWeapon=getBestScoreWeapon(inventory);
        if (bestWeapon != weapon) {
          desire+=brain.getRandomRange(0.1,0.4);
        }
      }
    }
 else {
      desire=1.0;
    }
    TargetingSystem system=brain.getTargetingSystem();
    if (desire < 1.0 && system.hasTarget()) {
      desire*=brain.getRandomRange(0.4,0.7);
    }
    desire*=getCharacterBias();
  }
  return desire;
}

Fixed version (ground truth):
@Override public double calculateDesirability(Brain brain){
  double desire=0.0;
  Inventory inventory=brain.getEntityOwner().getInventory();
  if (inventory.numberOfItems() > 1) {
    Weapon weapon=inventory.currentItem();
    if (weapon != null) {
      if (weapon.isReady()) {
        if (weapon.getTotalAmmo() <= 0 && weapon.getBulletsInClip() <= 0) {
          desire=1;
        }
        Weapon bestWeapon=getBestScoreWeapon(inventory);
        if (bestWeapon != weapon) {
          desire+=brain.getRandomRange(0.1,0.4);
        }
      }
    }
 else {
      desire=1.0;
    }
    TargetingSystem system=brain.getTargetingSystem();
    if (desire < 1.0 && system.hasTarget()) {
      desire*=brain.getRandomRange(0.4,0.7);
    }
    desire*=getCharacterBias();
  }
  return desire;
}
Program: 86577
Project: 86577
Buggy source:
public double getDouble(int length){
  long value=0;
  for (int i=0; i < length; i++) {
    checkPosition();
    value|=(data.getBit(position++) ? 1 : 0) << (i % Double.SIZE);
  }
  return Double.doubleToLongBits(value);
}

Fixed version (ground truth):
public double getDouble(int length){
  long value=0;
  for (int i=0; i < length; i++) {
    checkPosition();
    value|=(data.getBit(position++) ? 1L : 0L) << (i % Double.SIZE);
  }
  return Double.longBitsToDouble(value);
}
Program: 86578
Project: 86578
Buggy source:
public long getLong(int length){
  long value=0;
  for (int i=0; i < length; i++) {
    checkPosition();
    value|=(data.getBit(position++) ? 1 : 0) << (i % Long.SIZE);
  }
  return value;
}

Fixed version (ground truth):
public long getLong(int length){
  long value=0;
  for (int i=0; i < length; i++) {
    checkPosition();
    value|=(data.getBit(position++) ? 1L : 0L) << (i % Long.SIZE);
  }
  return value;
}
Program: 86579
Project: 86579
Buggy source:
public static void writeBigString(IOBuffer buffer,String str){
  byte[] chars=str.getBytes();
  int len=chars.length;
  buffer.putShort((short)len);
  for (byte i=0; i < len; i++) {
    buffer.putByte(chars[i]);
  }
}

Fixed version (ground truth):
public static void writeBigString(IOBuffer buffer,String str){
  byte[] chars=str.getBytes();
  int len=chars.length;
  buffer.putShort((short)len);
  for (int i=0; i < len; i++) {
    buffer.putByte(chars[i]);
  }
}
Program: 86580
Project: 86580
Buggy source:
public static String readBigString(IOBuffer buffer){
  int len=buffer.getShort();
  byte[] chars=new byte[len];
  for (byte i=0; i < len; i++) {
    chars[i]=buffer.getByte();
  }
  return new String(chars);
}

Fixed version (ground truth):
public static String readBigString(IOBuffer buffer){
  int len=buffer.getShort();
  byte[] chars=new byte[len];
  for (int i=0; i < len; i++) {
    chars[i]=buffer.getByte();
  }
  return new String(chars);
}
Program: 86581
Project: 86581
Buggy source:
public static String readString(IOBuffer buffer){
  int len=buffer.getUnsignedByte();
  byte[] chars=new byte[len];
  for (byte i=0; i < len; i++) {
    chars[i]=buffer.getByte();
  }
  return new String(chars);
}

Fixed version (ground truth):
public static String readString(IOBuffer buffer){
  int len=buffer.getUnsignedByte();
  byte[] chars=new byte[len];
  for (int i=0; i < len; i++) {
    chars[i]=buffer.getByte();
  }
  return new String(chars);
}
Program: 86582
Project: 86582
Buggy source:
public static void writeString(IOBuffer buffer,String str){
  byte[] chars=str.getBytes();
  int len=chars.length;
  buffer.putUnsignedByte(len);
  for (byte i=0; i < len; i++) {
    buffer.putByte(chars[i]);
  }
}

Fixed version (ground truth):
public static void writeString(IOBuffer buffer,String str){
  byte[] chars=str.getBytes();
  int len=chars.length;
  buffer.putUnsignedByte(len);
  for (int i=0; i < len; i++) {
    buffer.putByte(chars[i]);
  }
}