nus-yam/ex-repair huggingface dataset:
Program: 177400
Project: 177400
Buggy source:
@Override public ChannelBuffer encode(AddEntityMessage message){
  ChannelBuffer buffer=ChannelBuffers.buffer(8 + ChannelBufferUtils.TRANSFORM_SIZE);
  buffer.writeInt(message.getEntityId());
  buffer.writeInt(message.getType().getId());
  ChannelBufferUtils.writeTransform(buffer,message.getPosition());
  return buffer;
}

Fixed version (ground truth):
@Override public ChannelBuffer encode(AddEntityMessage message){
  ChannelBuffer buffer=ChannelBuffers.buffer(8 + ChannelBufferUtils.UUID_SIZE + ChannelBufferUtils.VECTOR3_SIZE * 2 + ChannelBufferUtils.QUATERNINON_SIZE);
  buffer.writeInt(message.getEntityId());
  buffer.writeInt(message.getType().getId());
  ChannelBufferUtils.writeUUID(buffer,message.getWorldUid());
  ChannelBufferUtils.writeVector3(buffer,message.getPosition());
  ChannelBufferUtils.writeQuaternion(buffer,message.getRotation());
  ChannelBufferUtils.writeVector3(buffer,message.getScale());
  return buffer;
}
Program: 177401
Project: 177401
Buggy source:
@Override public AddEntityMessage decode(ChannelBuffer buffer){
  final int entityId=buffer.readInt();
  final int controllerTypeId=buffer.readInt();
  final Transform position=ChannelBufferUtils.readTransform(buffer);
  return new AddEntityMessage(entityId,ControllerRegistry.get(controllerTypeId),position);
}

Fixed version (ground truth):
@Override public AddEntityMessage decode(ChannelBuffer buffer){
  final int entityId=buffer.readInt();
  final int controllerTypeId=buffer.readInt();
  final UUID worldUid=ChannelBufferUtils.readUUID(buffer);
  final Vector3 position=ChannelBufferUtils.readVector3(buffer);
  final Quaternion rotation=ChannelBufferUtils.readQuaternion(buffer);
  final Vector3 scale=ChannelBufferUtils.readVector3(buffer);
  return new AddEntityMessage(entityId,ControllerRegistry.get(controllerTypeId),worldUid,position,rotation,scale);
}
Program: 177402
Project: 177402
Buggy source:
@Override public ChannelBuffer encode(EntityPositionMessage message){
  ChannelBuffer buffer=ChannelBuffers.buffer(4 + ChannelBufferUtils.TRANSFORM_SIZE);
  buffer.writeInt(message.getEntityId());
  ChannelBufferUtils.writeTransform(buffer,message.getTransform());
  return buffer;
}

Fixed version (ground truth):
@Override public ChannelBuffer encode(EntityPositionMessage message){
  ChannelBuffer buffer=ChannelBuffers.buffer(4 + ChannelBufferUtils.TRANSFORM_SIZE);
  buffer.writeInt(message.getEntityId());
  ChannelBufferUtils.writeUUID(buffer,message.getWorldUid());
  ChannelBufferUtils.writeVector3(buffer,message.getPosition());
  ChannelBufferUtils.writeQuaternion(buffer,message.getRotation());
  ChannelBufferUtils.writeVector3(buffer,message.getScale());
  return buffer;
}
Program: 177403
Project: 177403
Buggy source:
@Override public EntityPositionMessage decode(ChannelBuffer buffer){
  final int entityId=buffer.readInt();
  final Transform transform=ChannelBufferUtils.readTransform(buffer);
  return new EntityPositionMessage(entityId,transform);
}

Fixed version (ground truth):
@Override public EntityPositionMessage decode(ChannelBuffer buffer){
  final int entityId=buffer.readInt();
  final UUID worldUid=ChannelBufferUtils.readUUID(buffer);
  final Vector3 position=ChannelBufferUtils.readVector3(buffer);
  final Quaternion rotation=ChannelBufferUtils.readQuaternion(buffer);
  final Vector3 scale=ChannelBufferUtils.readVector3(buffer);
  return new EntityPositionMessage(entityId,worldUid,position,rotation,scale);
}
Program: 177404
Project: 177404
Buggy source:
@Override public void handleClient(Session session,AddEntityMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Player player=session.getPlayer();
  Controller controller=message.getType().createController();
  if (controller == null) {
    throw new IllegalArgumentException("String_Node_Str" + message.getType().getName() + "String_Node_Str");
  }
  Entity newEntity=player.getWorld().createEntity(message.getPosition().getPosition(),controller);
  newEntity.setTransform(message.getPosition());
  player.getWorld().spawnEntity(newEntity);
}

Fixed version (ground truth):
@Override public void handleClient(Session session,AddEntityMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Player player=session.getPlayer();
  Entity newEntity;
  if (message.getEntityId() == session.getDataMap().get(SpoutProtocol.PLAYER_ENTITY_ID)) {
    newEntity=player;
  }
 else {
    newEntity=session.getEngine().getDefaultWorld().createEntity(message.getTransform().getPosition(),null);
  }
  Controller controller=message.getType().createController();
  if (controller == null) {
    throw new IllegalArgumentException("String_Node_Str" + message.getType().getName() + "String_Node_Str");
  }
  newEntity.setController(controller);
  newEntity.setTransform(message.getTransform());
  ((Client)session.getEngine()).getDefaultWorld().spawnEntity(newEntity);
}
Program: 177405
Project: 177405
Buggy source:
@Override public void handle(boolean upstream,Session session,CommandMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Player player=session.getPlayer();
  String command=session.getEngine().getRootCommand().getChildName(message.getCommand());
  player.processCommand(command,new ChatArguments(message.getArguments()));
}

Fixed version (ground truth):
@Override public void handle(boolean upstream,Session session,CommandMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Player player=session.getPlayer();
  String command=session.getEngine().getRootCommand().getChildName(message.getCommand());
  if (command == null) {
    player.sendMessage("String_Node_Str",message.getCommand());
  }
  player.processCommand(command,new ChatArguments(message.getArguments()));
}
Program: 177406
Project: 177406
Buggy source:
@Override public void handleClient(Session session,EntityPositionMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Entity entity=session.getPlayer().getWorld().getEntity(message.getEntityId());
  if (entity != null) {
    entity.setTransform(message.getTransform());
  }
}

Fixed version (ground truth):
@Override public void handleClient(Session session,EntityPositionMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  Entity entity;
  if (message.getEntityId() == session.getDataMap().get(SpoutProtocol.PLAYER_ENTITY_ID)) {
    entity=session.getPlayer();
  }
 else {
    entity=session.getEngine().getDefaultWorld().getEntity(message.getEntityId());
  }
  if (entity != null) {
    entity.setTransform(message.getTransform());
  }
}
Program: 177407
Project: 177407
Buggy source:
@Override public void handleServer(Session session,LoginMessage message){
  if (!session.hasPlayer()) {
    return;
  }
  session.getEngine().getEventManager().callEvent(new PlayerConnectEvent(session,message.getPlayerName()));
  session.setState(Session.State.GAME);
  session.send(false,new LoginMessage("String_Node_Str",session.getPlayer().getId()));
}

Fixed version (ground truth):
@Override public void handleServer(Session session,LoginMessage message){
  session.getEngine().getEventManager().callEvent(new PlayerConnectEvent(session,message.getPlayerName()));
  session.setState(Session.State.GAME);
  session.send(false,new LoginMessage("String_Node_Str",session.getPlayer().getId()));
}
Program: 177408
Project: 177408
Buggy source:
@Override public void handleClient(Session session,WorldChangeMessage message){
  UUID worldUUID=message.getWorldUUID();
}

Fixed version (ground truth):
@Override public void handleClient(Session session,WorldChangeMessage message){
  ((Client)session.getEngine()).worldChanged(message.getWorldName(),message.getWorldUUID(),message.getCompressedData());
}
Program: 177409
Project: 177409
Buggy source:
public Transform getPosition(){
  return position;
}

Fixed version (ground truth):
public Vector3 getPosition(){
  return pos;
}
Program: 177410
Project: 177410
Buggy source:
public AddEntityMessage(int entityId,ControllerType type,Transform position){
  this.entityId=entityId;
  this.type=type;
  this.position=position;
}

Fixed version (ground truth):
public AddEntityMessage(int entityId,ControllerType type,UUID worldUid,Vector3 pos,Quaternion rotation,Vector3 scale){
  this.entityId=entityId;
  this.type=type;
  this.worldUid=worldUid;
  this.pos=pos;
  this.rotation=rotation;
  this.scale=scale;
}
Program: 177411
Project: 177411
Buggy source:
@Override public String toString(){
  return new ToStringBuilder(this,SpoutToStringStyle.INSTANCE).append("String_Node_Str",entityId).append("String_Node_Str",type).append("String_Node_Str",position).toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return new ToStringBuilder(this,SpoutToStringStyle.INSTANCE).append("String_Node_Str",entityId).append("String_Node_Str",type).append("String_Node_Str",worldUid).append("String_Node_Str",pos).append("String_Node_Str",scale).append("String_Node_Str",rotation).toString();
}
Program: 177412
Project: 177412
Buggy source:
@Override public String toString(){
  return new ToStringBuilder(this,SpoutToStringStyle.INSTANCE).append("String_Node_Str",unload).append("String_Node_Str",x).append("String_Node_Str",y).append("String_Node_Str",z).append("String_Node_Str",blockIds).append("String_Node_Str",blockData).append("String_Node_Str",blockLight).append("String_Node_Str",skyLight).append("String_Node_Str",biomeData).toString();
}

Fixed version (ground truth):
@Override public String toString(){
  return new ToStringBuilder(this,SpoutToStringStyle.INSTANCE).append("String_Node_Str",unload).append("String_Node_Str",x).append("String_Node_Str",y).append("String_Node_Str",z).append("String_Node_Str",blockIds,false).append("String_Node_Str",blockData,false).append("String_Node_Str",blockLight,false).append("String_Node_Str",skyLight,false).append("String_Node_Str",biomeData,false).toString();
}
Program: 177413
Project: 177413
Buggy source:
public ChunkIterator(){
  for (int dx=0; dx < CHUNKS.SIZE; dx++) {
    for (int dy=0; dy < CHUNKS.SIZE; dy++) {
      for (int dz=0; dz < CHUNKS.SIZE; dz++) {
        next=getChunk(dx,dy,dz,LoadOption.NO_LOAD);
        if (next != null) {
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
public ChunkIterator(){
  loop:   for (int dx=0; dx < CHUNKS.SIZE; dx++) {
    for (int dy=0; dy < CHUNKS.SIZE; dy++) {
      for (int dz=0; dz < CHUNKS.SIZE; dz++) {
        next=getChunk(dx,dy,dz,LoadOption.NO_LOAD);
        if (next != null) {
          break loop;
        }
      }
    }
  }
}
Program: 177414
Project: 177414
Buggy source:
@Override public Chunk next(){
  Chunk current=next;
  next=null;
  for (int dx=current.getX(); dx < CHUNKS.SIZE; dx++) {
    for (int dy=current.getY(); dy < CHUNKS.SIZE; dy++) {
      for (int dz=current.getZ(); dz < CHUNKS.SIZE; dz++) {
        next=getChunk(dx,dy,dz,LoadOption.NO_LOAD);
        if (next != null) {
          break;
        }
      }
    }
  }
  return current;
}

Fixed version (ground truth):
@Override public Chunk next(){
  Chunk current=next;
  next=null;
  final int cx=current.getX() & CHUNKS.MASK;
  final int cy=current.getY() & CHUNKS.MASK;
  final int cz=current.getZ() & CHUNKS.MASK;
  for (int dx=cx; dx < CHUNKS.SIZE; dx++) {
    for (int dy=cy; dy < CHUNKS.SIZE; dy++) {
      for (int dz=cz; dz < CHUNKS.SIZE; dz++) {
        next=getChunk(dx,dy,dz,LoadOption.NO_LOAD);
        if (next != null && next != current) {
          return current;
        }
      }
    }
  }
  return current;
}
Program: 177416
Project: 177416
Buggy source:
/** 
 * Checks if the InputStream exists at the given index.
 * @param i the block index
 * @return true if the input stream exists
 */
public boolean inputStreamExists(int i){
  while (true) {
    ByteArrayArray baa=getByteArrayArray();
    if (baa == null) {
      return false;
    }
    try {
      return baa.exists(i);
    }
 catch (    BAAClosedException e) {
      continue;
    }
catch (    IOException e) {
      return false;
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks if the InputStream exists at the given index.
 * @param i the block index
 * @return true if the input stream exists
 */
public boolean inputStreamExists(int i){
  while (true) {
    ByteArrayArray baa=getByteArrayArray();
    if (baa == null) {
      return false;
    }
    if (baa == BAAOpenInProgress.getInstance()) {
      continue;
    }
    try {
      return baa.exists(i);
    }
 catch (    BAAClosedException e) {
      continue;
    }
catch (    IOException e) {
      return false;
    }
  }
}
Program: 177418
Project: 177418
Buggy source:
/** 
 * Waits until a notify
 * @return true if interrupted during the wait
 */
private boolean atomicWait(){
  waiting.incrementAndGet();
  try {
synchronized (this) {
      try {
        wait();
      }
 catch (      InterruptedException e) {
        return true;
      }
    }
  }
  finally {
    waiting.decrementAndGet();
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Waits until a notify
 * @return true if interrupted during the wait
 */
private final boolean atomicWait(int index){
  AtomicInteger i=getWaiting(index);
  i.incrementAndGet();
  try {
    short blockId=blockIds.get(index);
    boolean reserved=auxStore.isReserved(blockId);
synchronized (i) {
      if (!reserved || !auxStore.testUnstable(blockId)) {
        return false;
      }
      try {
        i.wait();
      }
 catch (      InterruptedException e) {
        return true;
      }
    }
  }
  finally {
    i.decrementAndGet();
  }
  return false;
}
Program: 177419
Project: 177419
Buggy source:
public AtomicBlockStoreImpl(int shift,int dirtySize,short[] blocks,short[] data){
  this.side=1 << shift;
  this.shift=shift;
  this.doubleShift=shift << 1;
  int size=side * side * side;
  blockIds=new AtomicShortArray(size);
  auxStore=new AtomicIntArrayStore(size);
  dirtyX=new byte[dirtySize];
  dirtyY=new byte[dirtySize];
  dirtyZ=new byte[dirtySize];
  if (blocks != null) {
    int x=0;
    int z=0;
    int y=0;
    int max=(1 << shift) - 1;
    for (int i=0; i < Math.min(blocks.length,size); i++) {
      short d=0;
      if (data != null) {
        d=data[i];
      }
      this.setBlock(x,y,z,blocks[i],d);
      if (x < max) {
        x++;
      }
 else {
        x=0;
        if (z < max) {
          z++;
        }
 else {
          z=0;
          if (y < max) {
            y++;
          }
 else {
            y=0;
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public AtomicBlockStoreImpl(int shift,int dirtySize,short[] blocks,short[] data){
  this.side=1 << shift;
  this.shift=shift;
  this.doubleShift=shift << 1;
  int size=side * side * side;
  blockIds=new AtomicShortArray(size);
  auxStore=new AtomicIntArrayStore(size);
  dirtyX=new byte[dirtySize];
  dirtyY=new byte[dirtySize];
  dirtyZ=new byte[dirtySize];
  waiting=new AtomicInteger[WAIT_COUNT];
  for (int i=0; i < WAIT_COUNT; i++) {
    waiting[i]=new AtomicInteger(0);
  }
  if (blocks != null) {
    int x=0;
    int z=0;
    int y=0;
    int max=(1 << shift) - 1;
    for (int i=0; i < Math.min(blocks.length,size); i++) {
      short d=0;
      if (data != null) {
        d=data[i];
      }
      this.setBlock(x,y,z,blocks[i],d);
      if (x < max) {
        x++;
      }
 else {
        x=0;
        if (z < max) {
          z++;
        }
 else {
          z=0;
          if (y < max) {
            y++;
          }
 else {
            y=0;
          }
        }
      }
    }
  }
}
Program: 177420
Project: 177420
Buggy source:
private int getAndSetBlockRaw(int x,int y,int z,short id,short data){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait();
      }
      checkCompressing();
      short oldBlockId=blockIds.get(index);
      boolean oldReserved=auxStore.isReserved(oldBlockId);
      if (data == 0 && !auxStore.isReserved(id)) {
        if (!blockIds.compareAndSet(index,oldBlockId,id)) {
          continue;
        }
      }
 else {
        int newIndex=auxStore.add(id,data);
        if (!blockIds.compareAndSet(index,oldBlockId,(short)newIndex)) {
          auxStore.remove(newIndex);
          continue;
        }
      }
      if (oldReserved) {
        return auxStore.remove(oldBlockId);
      }
      return BlockFullState.getPacked(oldBlockId,(short)0);
    }
  }
  finally {
    markDirty(x,y,z);
    atomicNotify();
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}

Fixed version (ground truth):
private int getAndSetBlockRaw(int x,int y,int z,short id,short data){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait(index);
      }
      checkCompressing();
      short oldBlockId=blockIds.get(index);
      boolean oldReserved=auxStore.isReserved(oldBlockId);
      if (data == 0 && !auxStore.isReserved(id)) {
        if (!blockIds.compareAndSet(index,oldBlockId,id)) {
          continue;
        }
      }
 else {
        int newIndex=auxStore.add(id,data);
        if (!blockIds.compareAndSet(index,oldBlockId,(short)newIndex)) {
          auxStore.remove(newIndex);
          continue;
        }
      }
      if (oldReserved) {
        return auxStore.remove(oldBlockId);
      }
      return BlockFullState.getPacked(oldBlockId,(short)0);
    }
  }
  finally {
    markDirty(x,y,z);
    atomicNotify(index);
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
Program: 177421
Project: 177421
Buggy source:
/** 
 * Gets the block id for a block at a particular location.<br> <br> Block ids range from 0 to 65535.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the block id
 */
public int getBlockId(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait();
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        blockId=auxStore.getId(blockId);
        if (testSequence(x,y,z,seq)) {
          return blockId & 0x0000FFFF;
        }
      }
 else {
        return blockId & 0x0000FFFF;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the block id for a block at a particular location.<br> <br> Block ids range from 0 to 65535.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the block id
 */
public int getBlockId(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait(index);
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        blockId=auxStore.getId(blockId);
        if (testSequence(x,y,z,seq)) {
          return blockId & 0x0000FFFF;
        }
      }
 else {
        return blockId & 0x0000FFFF;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
Program: 177422
Project: 177422
Buggy source:
/** 
 * Gets the block data for a block at a particular location.<br> <br> Block data ranges from 0 to 65535.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the block data
 */
public int getData(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait();
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        blockId=auxStore.getData(blockId);
        if (testSequence(x,y,z,seq)) {
          return blockId & 0x0000FFFF;
        }
      }
 else {
        return 0;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the block data for a block at a particular location.<br> <br> Block data ranges from 0 to 65535.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the block data
 */
public int getData(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait(index);
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        blockId=auxStore.getData(blockId);
        if (testSequence(x,y,z,seq)) {
          return blockId & 0x0000FFFF;
        }
      }
 else {
        return 0;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
Program: 177423
Project: 177423
Buggy source:
/** 
 * Atomically gets the full set of data associated with the block.<br> <br>
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the full state of the block
 */
public int getFullData(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait();
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        int state=auxStore.getInt(blockId);
        if (testSequence(x,y,z,seq)) {
          return state;
        }
      }
 else {
        int state=BlockFullState.getPacked(blockId,(short)0);
        return state;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}

Fixed version (ground truth):
/** 
 * Atomically gets the full set of data associated with the block.<br> <br>
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the full state of the block
 */
public int getFullData(int x,int y,int z){
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait(index);
      }
      checkCompressing();
      int seq=getSequence(x,y,z);
      short blockId=blockIds.get(index);
      if (auxStore.isReserved(blockId)) {
        int state=auxStore.getInt(blockId);
        if (testSequence(x,y,z,seq)) {
          return state;
        }
      }
 else {
        int state=BlockFullState.getPacked(blockId,(short)0);
        return state;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
Program: 177424
Project: 177424
Buggy source:
/** 
 * Notifies all waiting threads
 */
private void atomicNotify(){
  if (waiting.getAndAdd(0) > 0) {
synchronized (this) {
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Notifies all waiting threads
 */
private final void atomicNotify(int index){
  AtomicInteger i=getWaiting(index);
  if (!i.compareAndSet(0,0)) {
synchronized (i) {
      i.notifyAll();
    }
  }
}
Program: 177425
Project: 177425
Buggy source:
/** 
 * Gets the sequence number associated with a block location.<br> <br> If soft is true, this method counts as a volatile read. Otherwise, it is both a volatile read and a volatile write.<br> <br> Soft reads should only be used for the first of the 2 step process for confirming that data hasn't changed.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the sequence number, or DatatableSequenceNumber.ATOMIC for asingle short record
 */
public int getSequence(int x,int y,int z){
  checkCompressing();
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait();
      }
      checkCompressing();
      int blockId=blockIds.get(index);
      if (!auxStore.isReserved(blockId)) {
        return DatatableSequenceNumber.ATOMIC;
      }
      int sequence=auxStore.getSequence(blockId);
      if (sequence != DatatableSequenceNumber.UNSTABLE) {
        return sequence;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}

Fixed version (ground truth):
/** 
 * Gets the sequence number associated with a block location.<br> <br> If soft is true, this method counts as a volatile read. Otherwise, it is both a volatile read and a volatile write.<br> <br> Soft reads should only be used for the first of the 2 step process for confirming that data hasn't changed.
 * @param x the x coordinate
 * @param y the y coordinate
 * @param z the z coordinate
 * @return the sequence number, or DatatableSequenceNumber.ATOMIC for asingle short record
 */
public int getSequence(int x,int y,int z){
  checkCompressing();
  int index=getIndex(x,y,z);
  int spins=0;
  boolean interrupted=false;
  try {
    while (true) {
      if (spins++ > SPINS) {
        interrupted|=atomicWait(index);
      }
      checkCompressing();
      int blockId=blockIds.get(index);
      if (!auxStore.isReserved(blockId)) {
        return DatatableSequenceNumber.ATOMIC;
      }
      int sequence=auxStore.getSequence(blockId);
      if (sequence != DatatableSequenceNumber.UNSTABLE) {
        return sequence;
      }
    }
  }
  finally {
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
  }
}
Program: 177426
Project: 177426
Buggy source:
/** 
 * Adds an entry to the store. The auxData parameter should be set to null to indicate no auxiliary data.<br> <br> The index that is returned is guaranteed to be one of the reserved indexes.<br> <br>
 * @param id the id
 * @param data the data
 * @param auxData the auxiliary data
 * @return the index that the entry was stored in the array
 */
public final int add(short id,short data){
  entries.incrementAndGet();
  while (true) {
    if (needsResize()) {
      resizeArrays();
    }
    int testIndex=scan.getAndIncrement() & length.get() - 1;
    int prevSeq=seqArray.get().getAndSet(testIndex,DatatableSequenceNumber.UNSTABLE);
    if (prevSeq == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    try {
      if (!emptyArray.get()[testIndex]) {
        continue;
      }
      int idAndData=id << 16 | data & 0xFFFF;
      intArray.get()[testIndex]=idAndData;
      emptyArray.get()[testIndex]=false;
      return toExternal(testIndex);
    }
  finally {
      seqArray.get().set(testIndex,DatatableSequenceNumber.get());
      atomicNotify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds an entry to the store. The auxData parameter should be set to null to indicate no auxiliary data.<br> <br> The index that is returned is guaranteed to be one of the reserved indexes.<br> <br>
 * @param id the id
 * @param data the data
 * @param auxData the auxiliary data
 * @return the index that the entry was stored in the array
 */
public final int add(short id,short data){
  entries.incrementAndGet();
  while (true) {
    if (needsResize()) {
      resizeArrays();
    }
    int testIndex=scan.getAndIncrement() & length.get() - 1;
    int prevSeq=seqArray.get().getAndSet(testIndex,DatatableSequenceNumber.UNSTABLE);
    if (prevSeq == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    try {
      if (!emptyArray.get()[testIndex]) {
        continue;
      }
      int idAndData=id << 16 | data & 0xFFFF;
      intArray.get()[testIndex]=idAndData;
      emptyArray.get()[testIndex]=false;
      return toExternal(testIndex);
    }
  finally {
      seqArray.get().set(testIndex,DatatableSequenceNumber.get());
      atomicNotify(testIndex);
    }
  }
}
Program: 177427
Project: 177427
Buggy source:
private void unlock(int lockedIndexes){
  for (int i=0; i < lockedIndexes; i++) {
    if (!seqArray.get().compareAndSet(i,DatatableSequenceNumber.UNSTABLE,DatatableSequenceNumber.get())) {
      throw new IllegalStateException("String_Node_Str" + i + "String_Node_Str");
    }
  }
  atomicNotify();
}

Fixed version (ground truth):
private void unlock(int lockedIndexes){
  for (int i=0; i < lockedIndexes; i++) {
    if (!seqArray.get().compareAndSet(i,DatatableSequenceNumber.UNSTABLE,DatatableSequenceNumber.get())) {
      throw new IllegalStateException("String_Node_Str" + i + "String_Node_Str");
    }
    atomicNotify(i);
  }
}
Program: 177428
Project: 177428
Buggy source:
/** 
 * Waits until a notify
 * @return true if interrupted during the wait
 */
private final boolean atomicWait(){
  waiting.incrementAndGet();
  try {
synchronized (this) {
      try {
        wait();
      }
 catch (      InterruptedException e) {
        return true;
      }
    }
  }
  finally {
    waiting.decrementAndGet();
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Waits until a notify
 * @return true if interrupted during the wait
 */
private final boolean atomicWait(int index){
  AtomicInteger i=getWaiting(index);
  i.incrementAndGet();
  try {
synchronized (i) {
      if (!testUnstableInternal(index)) {
        return false;
      }
      try {
        i.wait();
      }
 catch (      InterruptedException e) {
        return true;
      }
    }
  }
  finally {
    i.decrementAndGet();
  }
  return false;
}
Program: 177429
Project: 177429
Buggy source:
/** 
 * Notifies all waiting threads
 */
private final void atomicNotify(){
  if (!waiting.compareAndSet(0,0)) {
synchronized (this) {
      notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Notifies all waiting threads
 */
private final void atomicNotify(int index){
  AtomicInteger i=getWaiting(index);
  if (!i.compareAndSet(0,0)) {
synchronized (i) {
      i.notifyAll();
    }
  }
}
Program: 177430
Project: 177430
Buggy source:
/** 
 * Removes the array elements at the given index. The array should not be empty at the index in question.<br> <br>
 * @param index the index
 * @return the int for old entry, or 0 if none
 */
public int remove(int index){
  index=toInternal(index);
  while (true) {
    int prevSeq=seqArray.get().getAndSet(index,DatatableSequenceNumber.UNSTABLE);
    if (prevSeq == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    try {
      int oldInt=intArray.get()[index];
      boolean current=emptyArray.get()[index];
      if (current) {
        throw new IllegalStateException("String_Node_Str");
      }
      emptyArray.get()[index]=true;
      entries.decrementAndGet();
      return oldInt;
    }
  finally {
      seqArray.get().set(index,DatatableSequenceNumber.get());
      atomicNotify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Removes the array elements at the given index. The array should not be empty at the index in question.<br> <br>
 * @param index the index
 * @return the int for old entry, or 0 if none
 */
public int remove(int index){
  index=toInternal(index);
  while (true) {
    int prevSeq=seqArray.get().getAndSet(index,DatatableSequenceNumber.UNSTABLE);
    if (prevSeq == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    try {
      int oldInt=intArray.get()[index];
      boolean current=emptyArray.get()[index];
      if (current) {
        throw new IllegalStateException("String_Node_Str");
      }
      emptyArray.get()[index]=true;
      entries.decrementAndGet();
      return oldInt;
    }
  finally {
      seqArray.get().set(index,DatatableSequenceNumber.get());
      atomicNotify(index);
    }
  }
}
Program: 177431
Project: 177431
Buggy source:
/** 
 * Gets the int value stored at a given index.<br> <br> If there is no int stored at the index, then the return value is undefined.<br> <br>
 * @param index the index
 * @return the int value
 */
public final int getInt(int index){
  index=toInternal(index);
  int spins=0;
  boolean interrupted=false;
  while (true) {
    if (spins++ > SPINS) {
      interrupted|=atomicWait();
    }
    int initialSequence=seqArray.get().get(index);
    if (initialSequence == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    int value=intArray.get()[index];
    if (!seqArray.get().compareAndSet(index,initialSequence,initialSequence)) {
      continue;
    }
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
    return value;
  }
}

Fixed version (ground truth):
/** 
 * Gets the int value stored at a given index.<br> <br> If there is no int stored at the index, then the return value is undefined.<br> <br>
 * @param index the index
 * @return the int value
 */
public final int getInt(int index){
  index=toInternal(index);
  int spins=0;
  boolean interrupted=false;
  while (true) {
    if (spins++ > SPINS) {
      interrupted|=atomicWait(index);
    }
    int initialSequence=seqArray.get().get(index);
    if (initialSequence == DatatableSequenceNumber.UNSTABLE) {
      continue;
    }
    int value=intArray.get()[index];
    if (!seqArray.get().compareAndSet(index,initialSequence,initialSequence)) {
      continue;
    }
    if (interrupted) {
      Thread.currentThread().interrupt();
    }
    return value;
  }
}
Program: 177432
Project: 177432
Buggy source:
public AtomicIntArrayStore(int maxEntries,double loadFactor,int initialSize){
  this.maxLength=MathHelper.roundUpPow2((int)(maxEntries / loadFactor));
  this.reservedMask=-MathHelper.roundUpPow2(maxLength) & 0xFFFF;
  this.length.set(MathHelper.roundUpPow2(initialSize));
  this.entries.set(0);
  intArray=new AtomicReference<int[]>(new int[this.length.get()]);
  seqArray=new AtomicReference<AtomicIntegerArray>(new AtomicIntegerArray(this.length.get()));
  emptyArray=new AtomicReference<boolean[]>(new boolean[this.length.get()]);
  emptyFill(emptyArray.get(),seqArray.get());
}

Fixed version (ground truth):
public AtomicIntArrayStore(int maxEntries,double loadFactor,int initialSize){
  this.maxLength=MathHelper.roundUpPow2((int)(maxEntries / loadFactor));
  this.reservedMask=-MathHelper.roundUpPow2(maxLength) & 0xFFFF;
  this.length.set(MathHelper.roundUpPow2(initialSize));
  this.entries.set(0);
  intArray=new AtomicReference<int[]>(new int[this.length.get()]);
  seqArray=new AtomicReference<AtomicIntegerArray>(new AtomicIntegerArray(this.length.get()));
  emptyArray=new AtomicReference<boolean[]>(new boolean[this.length.get()]);
  emptyFill(emptyArray.get(),seqArray.get());
  waiting=new AtomicInteger[WAIT_COUNT];
  for (int i=0; i < WAIT_COUNT; i++) {
    waiting[i]=new AtomicInteger(0);
  }
}
Program: 177433
Project: 177433
Buggy source:
public void finalizeRun(){
  Profiler.start("String_Node_Str");
  try {
    Profiler.start("String_Node_Str");
    long worldAge=getWorld().getAge();
    for (int reap=0; reap < REAP_PER_TICK; reap++) {
      if (++reapX >= CHUNKS.SIZE) {
        reapX=0;
        if (++reapY >= CHUNKS.SIZE) {
          reapY=0;
          if (++reapZ >= CHUNKS.SIZE) {
            reapZ=0;
          }
        }
      }
      SpoutChunk chunk=chunks[reapX][reapY][reapZ].get();
      if (chunk != null) {
        chunk.compressIfRequired();
        boolean doUnload=true;
        if (chunk.isReapable(worldAge)) {
          if (ChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0) {
            ChunkUnloadEvent event=Spout.getEngine().getEventManager().callEvent(new ChunkUnloadEvent(chunk));
            if (event.isCancelled()) {
              doUnload=false;
            }
          }
        }
        if (doUnload) {
          chunk.unload(true);
        }
 else         if (!chunk.isPopulated()) {
          queueChunkForPopulation(chunk);
        }
      }
    }
    Profiler.startAndStop("String_Node_Str");
    entityManager.finalizeRun();
    Profiler.stop();
  }
  finally {
    Profiler.stop();
  }
}

Fixed version (ground truth):
public void finalizeRun(){
  Profiler.start("String_Node_Str");
  try {
    Profiler.start("String_Node_Str");
    long worldAge=getWorld().getAge();
    for (int reap=0; reap < REAP_PER_TICK; reap++) {
      if (++reapX >= CHUNKS.SIZE) {
        reapX=0;
        if (++reapY >= CHUNKS.SIZE) {
          reapY=0;
          if (++reapZ >= CHUNKS.SIZE) {
            reapZ=0;
          }
        }
      }
      SpoutChunk chunk=chunks[reapX][reapY][reapZ].get();
      if (chunk != null) {
        chunk.compressIfRequired();
        boolean doUnload;
        if (doUnload=chunk.isReapable(worldAge)) {
          if (ChunkUnloadEvent.getHandlerList().getRegisteredListeners().length > 0) {
            ChunkUnloadEvent event=Spout.getEngine().getEventManager().callEvent(new ChunkUnloadEvent(chunk));
            if (event.isCancelled()) {
              doUnload=false;
            }
          }
        }
        if (doUnload) {
          chunk.unload(true);
        }
 else         if (!chunk.isPopulated()) {
          queueChunkForPopulation(chunk);
        }
      }
    }
    Profiler.startAndStop("String_Node_Str");
    entityManager.finalizeRun();
    Profiler.stop();
  }
  finally {
    Profiler.stop();
  }
}
Program: 177434
Project: 177434
Buggy source:
public void connect(String playerName){
  String hostname="String_Node_Str";
  int port=25565;
  ChannelFuture f=clientBootstrap.connect(new InetSocketAddress(hostname,port));
  System.out.println("String_Node_Str");
  try {
    f.await();
  }
 catch (  InterruptedException e) {
    System.out.println("String_Node_Str");
  }
  System.out.println("String_Node_Str" + f.isSuccess() + "String_Node_Str"+ f.isDone()+ "String_Node_Str"+ f.getCause());
  f.getCause().printStackTrace();
}

Fixed version (ground truth):
public void connect(String playerName,Session session){
  String hostname="String_Node_Str";
  int port=25565;
  ChannelFutureListener listener=new SpoutProxyConnectListener(this,playerName,session);
  clientBootstrap.connect(new InetSocketAddress(hostname,port)).addListener(listener);
}
Program: 177435
Project: 177435
Buggy source:
@EventHandler(order=Order.MONITOR) public void onPlayerConnect(PlayerConnectEvent event){
  if (event.isCancelled()) {
    return;
  }
  server.connect(event.getPlayerName());
  System.out.println("String_Node_Str" + event.getSession().getProtocol());
}

Fixed version (ground truth):
@EventHandler(order=Order.MONITOR) public void onPlayerConnect(PlayerConnectEvent event){
  if (event.isCancelled()) {
    return;
  }
  server.connect(event.getPlayerName(),event.getSession());
}
Program: 177436
Project: 177436
Buggy source:
@Override public boolean disconnect(String reason,boolean kick){
  if (player != null) {
    PlayerLeaveEvent event;
    if (kick) {
      event=getEngine().getEventManager().callEvent(new PlayerKickEvent(player,getDefaultLeaveMessage(),reason));
      if (event.isCancelled()) {
        return false;
      }
      getEngine().getLogger().log(Level.INFO,"String_Node_Str",new Object[]{player.getName(),reason});
    }
 else {
      event=new PlayerLeaveEvent(player,getDefaultLeaveMessage());
    }
    dispose(event);
  }
  Message kickMessage=getNetworkSynchronizer().getKickMessage(reason);
  if (kickMessage != null) {
    channel.write(kickMessage).addListener(ChannelFutureListener.CLOSE);
  }
 else {
    channel.close();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean disconnect(String reason,boolean kick){
  if (player != null) {
    PlayerLeaveEvent event;
    if (kick) {
      event=getEngine().getEventManager().callEvent(new PlayerKickEvent(player,getDefaultLeaveMessage(),reason));
      if (event.isCancelled()) {
        return false;
      }
      getEngine().getLogger().log(Level.INFO,"String_Node_Str",new Object[]{player.getName(),reason});
    }
 else {
      event=new PlayerLeaveEvent(player,getDefaultLeaveMessage());
    }
    dispose(event);
  }
  Protocol protocol=getProtocol();
  Message kickMessage=null;
  if (protocol != null) {
    kickMessage=protocol.getKickMessage(reason);
  }
  if (kickMessage != null) {
    channel.write(kickMessage).addListener(ChannelFutureListener.CLOSE);
  }
 else {
    channel.close();
  }
  return true;
}
Program: 177437
Project: 177437
Buggy source:
@Override public void setNetworkSynchronizer(NetworkSynchronizer synchronizer){
  if (synchronizer == null && player == null) {
    this.synchronizer.set(nullSynchronizer);
  }
 else   if (!this.synchronizer.compareAndSet(nullSynchronizer,synchronizer)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void setNetworkSynchronizer(NetworkSynchronizer synchronizer){
  if (synchronizer == null && player == null) {
    this.synchronizer.set(nullSynchronizer);
  }
 else   if (!this.synchronizer.compareAndSet(nullSynchronizer,synchronizer)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
 else {
    synchronizer.setProtocol(protocol.get());
  }
}
Program: 177438
Project: 177438
Buggy source:
@Override public void setProtocol(Protocol protocol){
  if (!this.protocol.compareAndSet(bootstrapProtocol,protocol)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  server.getLogger().info("String_Node_Str" + protocol.getName());
}

Fixed version (ground truth):
@Override public void setProtocol(Protocol protocol){
  if (!this.protocol.compareAndSet(bootstrapProtocol,protocol)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.synchronizer.get().setProtocol(protocol);
  server.getLogger().info("String_Node_Str" + protocol.getName());
}
Program: 177439
Project: 177439
Buggy source:
public String getDefaultLeaveMessage(){
  return ChatColor.CYAN + player.getDisplayName() + ChatColor.CYAN+ "String_Node_Str";
}

Fixed version (ground truth):
public String getDefaultLeaveMessage(){
  if (player == null) {
    return ChatColor.CYAN + "String_Node_Str" + ChatColor.CYAN+ "String_Node_Str";
  }
 else {
    return ChatColor.CYAN + player.getDisplayName() + ChatColor.CYAN+ "String_Node_Str";
  }
}
Program: 177440
Project: 177440
Buggy source:
private void checkChunkUpdates(Point currentPosition){
  priorityChunkSendQueue.clear();
  chunkSendQueue.clear();
  chunkFreeQueue.clear();
  chunkInitQueue.clear();
  World world=currentPosition.getWorld();
  int bx=(int)currentPosition.getX();
  int by=(int)currentPosition.getY();
  int bz=(int)currentPosition.getZ();
  Point playerChunkBase=Chunk.pointToBase(currentPosition);
  for (  Point p : initializedChunks) {
    if (p.getManhattanDistance(playerChunkBase) > blockViewDistance) {
      chunkFreeQueue.add(p);
    }
  }
  int cx=bx >> Chunk.BLOCKS.BITS;
  int cy=by >> Chunk.BLOCKS.BITS;
  int cz=bz >> Chunk.BLOCKS.BITS;
  Iterator<IntVector3> itr=new OutwardIterator(cx,cy,cz,viewDistance);
  int distance=0;
  while (itr.hasNext()) {
    IntVector3 v=itr.next();
    Point base=new Point(world,v.getX() << Chunk.BLOCKS.BITS,v.getY() << Chunk.BLOCKS.BITS,v.getZ() << Chunk.BLOCKS.BITS);
    if (!activeChunks.contains(base)) {
      if (distance <= targetSize) {
        priorityChunkSendQueue.add(base);
      }
 else {
        chunkSendQueue.add(base);
      }
    }
    if (!initializedChunks.contains(base)) {
      chunkInitQueue.add(base);
    }
  }
}

Fixed version (ground truth):
private void checkChunkUpdates(Point currentPosition){
  priorityChunkSendQueue.clear();
  chunkSendQueue.clear();
  chunkFreeQueue.clear();
  chunkInitQueue.clear();
  World world=currentPosition.getWorld();
  int bx=(int)currentPosition.getX();
  int by=(int)currentPosition.getY();
  int bz=(int)currentPosition.getZ();
  Point playerChunkBase=Chunk.pointToBase(currentPosition);
  for (  Point p : initializedChunks) {
    if (p.getManhattanDistance(playerChunkBase) > blockViewDistance) {
      chunkFreeQueue.add(p);
    }
  }
  int cx=bx >> Chunk.BLOCKS.BITS;
  int cy=by >> Chunk.BLOCKS.BITS;
  int cz=bz >> Chunk.BLOCKS.BITS;
  Iterator<IntVector3> itr=new OutwardIterator(cx,cy,cz,viewDistance);
  while (itr.hasNext()) {
    IntVector3 v=itr.next();
    Point base=new Point(world,v.getX() << Chunk.BLOCKS.BITS,v.getY() << Chunk.BLOCKS.BITS,v.getZ() << Chunk.BLOCKS.BITS);
    boolean inTargetArea=playerChunkBase.getManhattanDistance(base) <= targetSize;
    if (!activeChunks.contains(base)) {
      if (inTargetArea) {
        priorityChunkSendQueue.add(base);
        chunkSendQueue.remove(base);
      }
 else {
        priorityChunkSendQueue.remove(base);
        chunkSendQueue.add(base);
      }
    }
    if (!initializedChunks.contains(base)) {
      chunkInitQueue.add(base);
    }
  }
}
Program: 177441
Project: 177441
Buggy source:
public NetworkSynchronizer(Player owner,Session session,Entity entity){
  this.owner=owner;
  this.entity=entity;
  entity.setObserver(true);
  this.session=session;
  blockViewDistance=entity.getViewDistance();
  viewDistance=blockViewDistance >> Chunk.BLOCKS.BITS;
  targetSize=blockViewDistance / 2;
}

Fixed version (ground truth):
public NetworkSynchronizer(Player owner,Session session,Entity entity){
  this.owner=owner;
  this.entity=entity;
  entity.setObserver(true);
  this.session=session;
  blockViewDistance=entity.getViewDistance();
  viewDistance=blockViewDistance >> Chunk.BLOCKS.BITS;
  targetSize=Math.max(Chunk.BLOCKS.SIZE << 2,blockViewDistance >> 2);
}
Program: 177442
Project: 177442
Buggy source:
/** 
 * Takes in an NBT tag, sanely checks null status, and then returns it value. This method will return null if the value cannot be cast to the given class.
 * @param t Tag to get the value from
 * @param clazz the return type to use
 * @return the value as an onbject of the same type as the given class
 */
public static <T>T getTagValue(Tag t,Class<T> clazz){
  Object o=toTagValue(t);
  if (o == null) {
    return null;
  }
  try {
    T value=(T)o;
    return value;
  }
 catch (  ClassCastException e) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Takes in an NBT tag, sanely checks null status, and then returns it value. This method will return null if the value cannot be cast to the given class.
 * @param t Tag to get the value from
 * @param clazz the return type to use
 * @return the value as an onbject of the same type as the given class
 */
public static <T>T getTagValue(Tag t,Class<? extends T> clazz){
  Object o=toTagValue(t);
  if (o == null) {
    return null;
  }
  try {
    return clazz.cast(o);
  }
 catch (  ClassCastException e) {
    return null;
  }
}
Program: 177443
Project: 177443
Buggy source:
/** 
 * Takes in an NBT tag, sanely checks null status, and then returns it value. This method will return null if the value cannot be cast to the default value.
 * @param t Tag to get the value from
 * @param defaultValue the value to return if the tag or its value is null or the value cannot be cast
 * @return the value as an onbject of the same type as the default value, or the default value
 */
public static <T>T toTagValue(Tag t,T defaultValue){
  Object o=toTagValue(t);
  if (o == null) {
    return defaultValue;
  }
  try {
    T value=(T)o;
    return value;
  }
 catch (  ClassCastException e) {
    return defaultValue;
  }
}

Fixed version (ground truth):
/** 
 * Takes in an NBT tag, sanely checks null status, and then returns it value. This method will return null if the value cannot be cast to the default value.
 * @param t Tag to get the value from
 * @param defaultValue the value to return if the tag or its value is null or the value cannot be cast
 * @return the value as an onbject of the same type as the default value, or the default value
 */
public static <T,U extends T>T toTagValue(Tag t,Class<? extends T> clazz,U defaultValue){
  Object o=toTagValue(t);
  if (o == null) {
    return defaultValue;
  }
  try {
    T value=clazz.cast(o);
    return value;
  }
 catch (  ClassCastException e) {
    return defaultValue;
  }
}
Program: 177444
Project: 177444
Buggy source:
protected Class<?> findClass(String name,boolean checkGlobal) throws ClassNotFoundException {
  Class<?> result=classes.get(name);
  if (result == null) {
    if (checkGlobal) {
      result=loader.getClassByName(name);
    }
    if (result == null) {
      result=super.findClass(name);
      if (result != null) {
        loader.setClass(name,result);
      }
    }
    classes.put(name,result);
  }
  return result;
}

Fixed version (ground truth):
protected Class<?> findClass(String name,boolean checkGlobal) throws ClassNotFoundException {
  Class<?> result=classes.get(name);
  if (result == null) {
    result=super.findClass(name);
    if (result == null && checkGlobal) {
      result=loader.getClassByName(name);
    }
    classes.put(name,result);
  }
  return result;
}