nus-yam/ex-repair huggingface dataset:
Program: 96665
Project: 96665
Buggy source:
/** 
 * Create a scheduler hook for a   {@link io.vertx.rxjava.core.Context} object.
 * @param context the context object
 * @return the scheduler hook
 */
public static RxJavaSchedulersHook schedulerHook(Context context){
  return io.vertx.rx.java.RxHelper.schedulerHook(context.delegate);
}

Fixed version (ground truth):
/** 
 * Create a scheduler hook for a   {@link io.vertx.rxjava.core.Context} object.
 * @param context the context object
 * @return the scheduler hook
 */
public static RxJavaSchedulersHook schedulerHook(Context context){
  return io.vertx.rx.java.RxHelper.schedulerHook(context.getDelegate());
}
Program: 96666
Project: 96666
Buggy source:
/** 
 * Create a scheduler for a   {@link Vertx} object, actions can be blocking, they are not executedon Vertx event loop.
 * @param vertx the vertx object
 * @return the scheduler
 */
public static Scheduler blockingScheduler(Vertx vertx){
  return new ContextScheduler(vertx.delegate.getOrCreateContext(),true);
}

Fixed version (ground truth):
/** 
 * Create a scheduler for a   {@link Vertx} object, actions can be blocking, they are not executedon Vertx event loop.
 * @param vertx the vertx object
 * @return the scheduler
 */
public static Scheduler blockingScheduler(Vertx vertx){
  return new ContextScheduler(vertx.getDelegate().getOrCreateContext(),true);
}
Program: 96667
Project: 96667
Buggy source:
public ContextScheduler(Vertx vertx,boolean blocking){
  this.vertx=vertx;
  this.blocking=blocking;
}

Fixed version (ground truth):
public ContextScheduler(Vertx vertx,boolean blocking){
  this.vertx=vertx;
  this.context=vertx.getOrCreateContext();
  this.blocking=blocking;
}
Program: 96668
Project: 96668
Buggy source:
public TimedAction(Action0 action,long delayMillis,long periodMillis){
  this.cancelled=false;
  this.action=action;
  this.periodMillis=periodMillis;
  if (delayMillis > 0) {
    id=vertx.setTimer(delayMillis,this);
  }
 else {
    id=-1;
    if (blocking) {
      vertx.executeBlocking(future -> run(),result -> {
      }
);
    }
 else {
      vertx.runOnContext(v -> run());
    }
  }
}

Fixed version (ground truth):
public TimedAction(Action0 action,long delayMillis,long periodMillis){
  this.cancelled=false;
  this.action=action;
  this.periodMillis=periodMillis;
  if (delayMillis > 0) {
    id=vertx.setTimer(delayMillis,this);
  }
 else {
    id=-1;
    if (blocking) {
      vertx.executeBlocking(this::run,result -> {
      }
);
    }
 else {
      context.runOnContext(this::run);
    }
  }
}
Program: 96669
Project: 96669
Buggy source:
/** 
 * Create a scheduler for a   {@link Vertx} object.
 * @param vertx the vertx object
 * @return the scheduler
 */
public static Scheduler scheduler(Vertx vertx){
  return new ContextScheduler(vertx);
}

Fixed version (ground truth):
/** 
 * Create a scheduler for a   {@link Vertx} object.
 * @param vertx the vertx object
 * @return the scheduler
 */
public static Scheduler scheduler(io.vertx.rxjava.core.Vertx vertx){
  return new ContextScheduler((Vertx)vertx.getDelegate());
}
Program: 96670
Project: 96670
Buggy source:
public void disconnect(String reason){
  this.sendPacket(new DisconnectPacket(reason));
  if (session != null)   session.onDisconnect();
}

Fixed version (ground truth):
public void disconnect(String reason){
  kick(reason);
  this.sendPacket(new DisconnectPacket(reason));
  if (session != null)   session.onDisconnect();
}
Program: 96671
Project: 96671
Buggy source:
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str" + DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}

Fixed version (ground truth):
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_PROTOCOL + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}
Program: 96672
Project: 96672
Buggy source:
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str" + DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}

Fixed version (ground truth):
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_PROTOCOL + "String_Node_Str";
  name+="String_Node_Str" + DragonetVersioning.MINECRAFT_PC_VERSION + "String_Node_Str"+ DragonetVersioning.MINECRAFT_PE_VERSION+ "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}
Program: 96673
Project: 96673
Buggy source:
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_PROTOCOL + "String_Node_Str";
  name+="String_Node_Str" + DragonetVersioning.MINECRAFT_PC_VERSION + "String_Node_Str"+ DragonetVersioning.MINECRAFT_PE_VERSION+ "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}

Fixed version (ground truth):
public RakNetInterface(SessionManager sesMan,String bindAddress,int port){
  this.sesMan=sesMan;
  this.raknetServer=new RakNetServer(port,bindAddress);
  this.handler=new ServerHandler(raknetServer,this);
  String name="String_Node_Str";
  name+=sesMan.getServer().getServer().getServerName().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_PROTOCOL + "String_Node_Str";
  name+=DragonetVersioning.MINECRAFT_PE_VERSION + "String_Node_Str";
  name+="String_Node_Str";
  this.handler.sendOption("String_Node_Str",name);
}
Program: 96675
Project: 96675
Buggy source:
public void onTick(){
  if (System.currentTimeMillis() - lastTimeSendOption > 1000) {
    handler.sendOption("String_Node_Str",getServerName());
    lastTimeSendOption=System.currentTimeMillis();
  }
  int cnt=0;
  while (cnt < 2400 && handler.handlePacket()) {
    cnt++;
  }
}

Fixed version (ground truth):
public void onTick(){
  if (System.currentTimeMillis() - lastTimeSendOption > 1000) {
    handler.sendOption("String_Node_Str",getServerName());
    lastTimeSendOption=System.currentTimeMillis();
  }
  while (handler.handlePacket())   ;
}
Program: 96676
Project: 96676
Buggy source:
/** 
 * Wraps <code>bytes</code> into an encapsulated packet and sends it.
 * @param session The Session this packet is being sent from.
 * @param packet The Packet being sent.
 * @param immediate If the packet should be sent immediately (nocompression, skips packet queues)
 */
public void sendPacket(PENetworkClient session,PEPacket packet,boolean immediate){
  if (packet == null)   return;
  System.out.println("String_Node_Str" + packet.getClass().getSimpleName());
  if (packet.getData() == null) {
    packet.encode();
  }
  if (!immediate && !(packet instanceof BatchPacket) && (packet.getData().length >= 512)) {
    BatchPacket bp=new BatchPacket();
    bp.packets.add(packet);
    bp.encode();
    sendPacket(session,bp,false);
  }
  EncapsulatedPacket pk=new EncapsulatedPacket();
  pk.buffer=Unpooled.wrappedBuffer(packet.getData());
  pk.messageIndex=0;
  if (packet.getChannel() != NetworkChannel.CHANNEL_NONE) {
    pk.reliability=2;
    pk.orderChannel=packet.getChannel().getAsByte();
    pk.orderIndex=0;
  }
 else {
    pk.reliability=2;
  }
  handler.sendEncapsulated(session.getRaknetSession(),pk,(byte)((byte)0 | (immediate || packet.getChannel() == NetworkChannel.CHANNEL_PRIORITY ? JRakLib.PRIORITY_IMMEDIATE : JRakLib.PRIORITY_NORMAL)));
}

Fixed version (ground truth):
/** 
 * Wraps <code>bytes</code> into an encapsulated packet and sends it.
 * @param session The Session this packet is being sent from.
 * @param packet The Packet being sent.
 * @param immediate If the packet should be sent immediately (nocompression, skips packet queues)
 */
public void sendPacket(PENetworkClient session,PEPacket packet,boolean immediate){
  if (packet == null)   return;
  if (packet.getClass().equals(UpdateBlockPacket.class))   return;
  System.out.println("String_Node_Str" + packet.getClass().getSimpleName());
  if (packet.getData() == null) {
    packet.encode();
  }
  if (packet.getData() == null) {
    return;
  }
  if (!(packet instanceof BatchPacket) && (packet.getData().length >= 512)) {
    BatchPacket bp=new BatchPacket();
    bp.packets.add(packet);
    bp.encode();
    sendPacket(session,bp,true);
    return;
  }
  EncapsulatedPacket pk=new EncapsulatedPacket();
  pk.buffer=Unpooled.copiedBuffer(packet.getData());
  pk.messageIndex=0;
  pk.reliability=2;
  handler.sendEncapsulated(session.getRaknetSession(),pk,(byte)((byte)0 | (immediate || packet.isShouldSendImmidate() ? JRakLib.PRIORITY_IMMEDIATE : JRakLib.PRIORITY_NORMAL)));
}
Program: 96677
Project: 96677
Buggy source:
public static String dumpHexFromBytes(byte[] bytes){
  StringBuilder sb=new StringBuilder();
  for (  byte b : bytes) {
    sb.append(String.format("String_Node_Str",b) + "String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
public static String dumpHexFromBytes(byte[] bytes){
  StringBuilder sb=new StringBuilder();
  for (  byte b : bytes) {
    sb.append(String.format("String_Node_Str",b));
    sb.append("String_Node_Str");
  }
  return sb.toString();
}
Program: 96678
Project: 96678
Buggy source:
@Override public void encode(){
  try {
    ByteArrayOutputStream packetCombinerData=new ByteArrayOutputStream();
    PEBinaryWriter packetCombiner=new PEBinaryWriter(packetCombinerData);
    for (    PEPacket pk : packets) {
      pk.encode();
      packetCombiner.writeInt(pk.getData().length);
      packetCombiner.write(pk.getData());
    }
    Deflater def=new Deflater(7);
    def.reset();
    def.setInput(packetCombinerData.toByteArray());
    def.finish();
    byte[] deflateBuffer=new byte[65535];
    int size=def.deflate(deflateBuffer);
    deflateBuffer=Arrays.copyOfRange(deflateBuffer,0,size);
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(deflateBuffer.length);
    writer.write(deflateBuffer);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void encode(){
  try {
    setShouldSendImmidate(true);
    ByteArrayOutputStream packetCombinerData=new ByteArrayOutputStream();
    PEBinaryWriter packetCombiner=new PEBinaryWriter(packetCombinerData);
    for (    PEPacket pk : packets) {
      pk.encode();
      packetCombiner.writeInt(pk.getData().length);
      packetCombiner.write(pk.getData());
    }
    Deflater def=new Deflater(7);
    def.reset();
    def.setInput(packetCombinerData.toByteArray());
    def.finish();
    byte[] deflateBuffer=new byte[65535];
    int size=def.deflate(deflateBuffer);
    deflateBuffer=Arrays.copyOfRange(deflateBuffer,0,size);
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(deflateBuffer.length);
    writer.write(deflateBuffer);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}
Program: 96679
Project: 96679
Buggy source:
@Override public void encode(){
  try {
    setChannel(NetworkChannel.CHANNEL_WORLD_CHUNKS);
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(chunkX);
    writer.writeInt(chunkZ);
    writer.writeByte(order != null ? order.getType() : (byte)0);
    writer.writeInt(chunkData.length);
    writer.write(chunkData);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void encode(){
  try {
    setShouldSendImmidate(true);
    setChannel(NetworkChannel.CHANNEL_WORLD_CHUNKS);
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(chunkX);
    writer.writeInt(chunkZ);
    writer.writeByte(order != null ? order.getType() : (byte)0);
    writer.writeInt(chunkData.length);
    writer.write(chunkData);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}
Program: 96680
Project: 96680
Buggy source:
@Override public void encode(){
  try {
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(this.status);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void encode(){
  setShouldSendImmidate(true);
  try {
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(this.status);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}
Program: 96681
Project: 96681
Buggy source:
public PEEnchantment(){
}

Fixed version (ground truth):
public PEEnchantment(int id,String name){
  this.id=id;
  this.name=name;
}
Program: 96682
Project: 96682
Buggy source:
@Override public Message[] handleSpecific(WindowItemsPacket packet){
  if (packet.windowID != PEWindowConstantID.PLAYER_CRAFTING) {
    return null;
  }
  if (packet.slots.length < 9) {
    emptyCrafting();
    return null;
  }
  ItemStack[] map=new ItemStack[9];
  for (int x=0; x < 3; x++) {
    for (int y=0; y < 3; y++) {
      map[x * 3 + y]=new ItemStack(this.getTranslator().getItemTranslator().translateToPC(packet.slots[x * 3 + y].id & 0xFFFF),packet.slots[x * 3 + y].count & 0xFF,packet.slots[x * 3 + y].meta);
    }
  }
  Recipe recipe=this.getSession().getServer().getCraftingManager().getCraftingRecipe(map);
  if (recipe == null) {
    emptyCrafting();
    return null;
  }
  this.getSession().getPlayer().getInventory().addItem(recipe.getResult());
  this.getSession().getServer().getCraftingManager().removeItems(this.getSession().getPlayer().getInventory().getContents(),recipe);
  emptyCrafting();
  return null;
}

Fixed version (ground truth):
@Override public Message[] handleSpecific(WindowItemsPacket packet){
  if (packet.windowID != PEWindowConstantID.PLAYER_CRAFTING) {
    return null;
  }
  if (packet.slots.length < 9) {
    emptyCrafting();
    return null;
  }
  ItemStack[] map=new ItemStack[9];
  for (int x=0; x < 3; x++) {
    for (int y=0; y < 3; y++) {
      map[x * 3 + y]=new ItemStack(this.getTranslator().getItemTranslator().translateToPC(packet.slots[x * 3 + y].id & 0xFFFF),packet.slots[x * 3 + y].count & 0xFF,packet.slots[x * 3 + y].meta);
    }
  }
  Recipe recipe=this.getSession().getServer().getCraftingManager().getCraftingRecipe(map);
  if (recipe == null) {
    emptyCrafting();
    return null;
  }
  this.getSession().getPlayer().getInventory().addItem(recipe.getResult());
  this.removeItems(this.getSession().getPlayer().getInventory().getContents(),recipe);
  emptyCrafting();
  return null;
}
Program: 96683
Project: 96683
Buggy source:
public DragonetServer(GlowServer server){
  INSTANCE=this;
  this.server=server;
  ServerConfig serverConfig=new ServerConfig(server.getConfigDir(),new File(server.getConfigDir(),"String_Node_Str"),new HashMap<ServerConfig.Key,Object>());
  pluginFolder=new File(serverConfig.getString(ServerConfig.Key.PLUGIN_FOLDER));
  this.logger=LoggerFactory.getLogger("String_Node_Str");
  this.customMaterialManager=new CustomItemManager(this);
  this.logger.info("String_Node_Str" + DragonetVersioning.DRAGONET_VERSION + "String_Node_Str");
  this.rhino=new Rhino();
}

Fixed version (ground truth):
public DragonetServer(GlowServer server){
  INSTANCE=this;
  this.server=server;
  ServerConfig serverConfig=new ServerConfig(server.getConfigDir(),new File(server.getConfigDir(),"String_Node_Str"),new HashMap<ServerConfig.Key,Object>());
  pluginFolder=new File(serverConfig.getString(ServerConfig.Key.PLUGIN_FOLDER));
  this.logger=LoggerFactory.getLogger("String_Node_Str");
  this.customMaterialManager=new CustomItemManager(this);
  this.logger.info("String_Node_Str" + DragonetVersioning.DRAGONET_VERSION + "String_Node_Str");
  this.rhino=new Rhino(this.getServer());
}
Program: 96685
Project: 96685
Buggy source:
public DragonetSession(DragonetServer dServer,BaseTranslator translator){
  super(dServer.getServer());
  this.dServer=dServer;
  this.translator=translator;
  this.dServer.getSessionManager().getSessions().put(getSessionKey(),this);
  this.chunkManager=new ClientChunkManager(this);
}

Fixed version (ground truth):
public DragonetSession(DragonetServer dServer,BaseTranslator translator,String sessionKey){
  super(dServer.getServer());
  this.dServer=dServer;
  this.sessionKey=sessionKey;
  this.translator=translator;
  this.dServer.getSessionManager().getSessions().put(getSessionKey(),this);
  this.chunkManager=new ClientChunkManager(this);
}
Program: 96686
Project: 96686
Buggy source:
public MCPESession(DragonetServer dServer,PENetworkClient client){
  super(dServer,null);
  this.dServer=dServer;
  this.client=client;
}

Fixed version (ground truth):
public MCPESession(DragonetServer dServer,PENetworkClient client){
  super(dServer,null,"String_Node_Str" + client.getRemoteAddress().toString());
  this.dServer=dServer;
  this.client=client;
}
Program: 96687
Project: 96687
Buggy source:
public PortalSession(String username,String remoteIP,int remotePort,DragonetServer dServer,BaseTranslator translator){
  super(dServer,translator);
}

Fixed version (ground truth):
public PortalSession(String username,String remoteIP,int remotePort,DragonetServer dServer,BaseTranslator translator){
  super(dServer,translator,"String_Node_Str" + remoteIP + "String_Node_Str"+ remotePort);
}
Program: 96688
Project: 96688
Buggy source:
public PluginAdapter(GlowServer server) throws IllegalStateException {
  this.server=server;
  dataFolder=new File(server.getDragonetServer().getPluginFolder(),this.getName());
  if (dataFolder.isFile()) {
    server.getLogger().warning("String_Node_Str" + getName() + "String_Node_Str");
    throw new IllegalStateException("String_Node_Str" + getName() + "String_Node_Str");
  }
  config=new YamlConfiguration();
  try {
    config.load(new File(dataFolder,"String_Node_Str"));
  }
 catch (  IOException ex) {
  }
catch (  InvalidConfigurationException ex) {
  }
}

Fixed version (ground truth):
public PluginAdapter(GlowServer server,String name) throws IllegalStateException {
  this.name=name;
  this.server=server;
  dataFolder=new File(server.getDragonetServer().getPluginFolder(),this.getName().replace("String_Node_Str","String_Node_Str").concat("String_Node_Str"));
  if (dataFolder.isFile()) {
    server.getLogger().warning("String_Node_Str" + getName() + "String_Node_Str");
    throw new IllegalStateException("String_Node_Str" + getName() + "String_Node_Str");
  }
  config=new YamlConfiguration();
  try {
    config.load(new File(dataFolder,"String_Node_Str"));
  }
 catch (  IOException|InvalidConfigurationException ex) {
  }
  logger=new PluginLogger(this);
}
Program: 96689
Project: 96689
Buggy source:
public Script(GlowServer server,File scriptFile){
  super(server);
  name=scriptFile.getName();
  System.out.println((scriptFile == null) + "String_Node_Str");
  System.out.println((scriptFile.getName() == null) + "String_Node_Str");
  context=new ContextFactory().enterContext();
  scope=context.initStandardObjects();
  Functions.defineFunctions(context,scope);
  fullFilePath=scriptFile.getAbsolutePath();
  file=scriptFile;
  UID=findScriptUID();
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException e) {
  }
  try {
    context.evaluateReader(scope,script,getName(),1,null);
  }
 catch (  IOException e) {
    System.out.println(Arrays.toString(e.getStackTrace()));
  }
}

Fixed version (ground truth):
public Script(GlowServer server,File scriptFile){
  super(server,scriptFile.getName());
  context=new ContextFactory().enterContext();
  scope=context.initStandardObjects();
  Functions.defineFunctions(context,scope);
  fullFilePath=scriptFile.getAbsolutePath();
  file=scriptFile;
  UID=findScriptUID();
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException e) {
  }
  try {
    context.evaluateReader(scope,script,getName(),1,null);
  }
 catch (  IOException e) {
    System.out.println(Arrays.toString(e.getStackTrace()));
  }
}
Program: 96690
Project: 96690
Buggy source:
private String findScriptUID(){
  Object name=runFunction("String_Node_Str",new Object[]{});
  try {
    if ((String)name == null) {
      throw new ClassCastException();
    }
    return (String)name;
  }
 catch (  ClassCastException e) {
    DragonetServer.instance().getLogger().warn("String_Node_Str" + this.name + "String_Node_Str");
    DragonetServer.instance().getLogger().warn("String_Node_Str");
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
private String findScriptUID(){
  Object name=runFunction("String_Node_Str",new Object[]{});
  try {
    if ((String)name == null) {
      throw new ClassCastException();
    }
    return (String)name;
  }
 catch (  ClassCastException e) {
    DragonetServer.instance().getLogger().warn("String_Node_Str" + this.getName() + "String_Node_Str");
    DragonetServer.instance().getLogger().warn("String_Node_Str");
    return "String_Node_Str";
  }
}
Program: 96691
Project: 96691
Buggy source:
@JSFunction public static void registerCommand(final Script script,final String commandName){
  DragonetServer.instance().getServer().getCommandMap().register(commandName,"String_Node_Str" + script.getName() + "String_Node_Str"+ commandName+ "String_Node_Str",new Command(commandName){
    @Override public boolean execute(    CommandSender cs,    String alias,    String[] args){
      return script.onCommand(cs,this,alias,args);
    }
  }
);
}

Fixed version (ground truth):
@JSFunction public static boolean registerCommand(final Object script,final String commandName){
  if (!Script.class.isInstance(script)) {
    return false;
  }
  DragonetServer.instance().getServer().getCommandMap().register(commandName,"String_Node_Str" + ((Script)script).getName() + "String_Node_Str"+ commandName+ "String_Node_Str",new Command(commandName){
    @Override public boolean execute(    CommandSender cs,    String alias,    String[] args){
      return ((Script)script).onCommand(cs,this,alias,args);
    }
  }
);
  return true;
}
Program: 96692
Project: 96692
Buggy source:
@Override public boolean execute(CommandSender cs,String alias,String[] args){
  return script.onCommand(cs,this,alias,args);
}

Fixed version (ground truth):
@Override public boolean execute(CommandSender cs,String alias,String[] args){
  return ((Script)script).onCommand(cs,this,alias,args);
}
Program: 96693
Project: 96693
Buggy source:
@Override public PEPacket[] handleSpecific(EntityEquipmentMessage packet){
  if (!(this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id) instanceof Player)) {
    return null;
  }
switch (packet.slot) {
case 0:
    PlayerEquipmentPacket pkEquipment=new PlayerEquipmentPacket();
  pkEquipment.eid=packet.id;
if (packet.stack != null) {
  pkEquipment.item=(short)(packet.stack.getTypeId() & 0xFFFF);
  pkEquipment.meta=(short)(packet.stack.getDurability() & 0xFFFF);
}
 else {
  pkEquipment.item=0;
  pkEquipment.meta=0;
}
pkEquipment.slot=(byte)0;
return new PEPacket[]{pkEquipment};
}
return null;
}

Fixed version (ground truth):
@Override public PEPacket[] handleSpecific(EntityEquipmentMessage packet){
  if (this.getSession().getPlayer() == null)   return null;
  if (!(this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.id) instanceof Player)) {
    return null;
  }
switch (packet.slot) {
case 0:
    PlayerEquipmentPacket pkEquipment=new PlayerEquipmentPacket();
  pkEquipment.eid=packet.id;
if (packet.stack != null) {
  pkEquipment.item=(short)(packet.stack.getTypeId() & 0xFFFF);
  pkEquipment.meta=(short)(packet.stack.getDurability() & 0xFFFF);
}
 else {
  pkEquipment.item=0;
  pkEquipment.meta=0;
}
pkEquipment.slot=(byte)0;
return new PEPacket[]{pkEquipment};
}
return null;
}
Program: 96697
Project: 96697
Buggy source:
@Override public void encode(){
}

Fixed version (ground truth):
@Override public void encode(){
  try {
    ByteArrayOutputStream packetCombiner=new ByteArrayOutputStream();
    for (    PEPacket pk : packets) {
      pk.encode();
      packetCombiner.write(pk.getData());
    }
    Deflater def=new Deflater(7);
    def.reset();
    def.setInput(packetCombiner.toByteArray());
    def.finish();
    byte[] deflateBuffer=new byte[65535];
    int size=def.deflate(deflateBuffer);
    deflateBuffer=Arrays.copyOfRange(deflateBuffer,0,size);
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(deflateBuffer.length);
    writer.write(deflateBuffer);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}
Program: 96698
Project: 96698
Buggy source:
@Override public void decode(){
  try {
    packets=new ArrayList<>();
    PEBinaryReader reader=new PEBinaryReader(new ByteArrayInputStream(this.getData()));
    reader.readByte();
    int size=reader.readInt();
    System.out.println("String_Node_Str" + (this.getData().length - 5) + "String_Node_Str"+ size);
    byte[] payload=reader.read(size);
    Inflater inf=new Inflater();
    inf.setInput(payload);
    byte[] decompressedPayload=new byte[1024 * 1024 * 64];
    inf.end();
    int decompressedSize=0;
    try {
      decompressedSize=inf.inflate(decompressedPayload);
    }
 catch (    DataFormatException ex) {
      ex.printStackTrace();
      this.setLength(reader.totallyRead());
      return;
    }
    System.out.println("String_Node_Str" + decompressedSize);
    decompressedPayload=Arrays.copyOfRange(decompressedPayload,0,decompressedSize);
    int offset=0;
    while (offset < decompressedSize) {
      PEPacket pk=Protocol.decode(Arrays.copyOfRange(decompressedPayload,offset,decompressedSize));
      if (pk == null || pk.getLength() == 0) {
        packets.clear();
        return;
      }
      offset+=pk.getLength();
      packets.add(pk);
    }
    this.setLength(reader.totallyRead());
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void decode(){
  try {
    packets=new ArrayList<>();
    PEBinaryReader reader=new PEBinaryReader(new ByteArrayInputStream(this.getData()));
    reader.readByte();
    int size=reader.readInt();
    byte[] payload=reader.read(size);
    Inflater inf=new Inflater();
    inf.setInput(payload);
    byte[] decompressedPayload=new byte[1024 * 1024 * 64];
    int decompressedSize=0;
    try {
      decompressedSize=inf.inflate(decompressedPayload);
    }
 catch (    DataFormatException ex) {
      this.setLength(reader.totallyRead());
      return;
    }
    inf.end();
    int offset=0;
    while (offset < decompressedSize) {
      PEPacket pk=Protocol.decode(Arrays.copyOfRange(decompressedPayload,offset,decompressedSize));
      if (pk == null || pk.getLength() == 0) {
        packets.clear();
        return;
      }
      offset+=pk.getLength();
      packets.add(pk);
    }
    this.setLength(reader.totallyRead());
  }
 catch (  IOException e) {
  }
}
Program: 96699
Project: 96699
Buggy source:
@Override public void encode(){
  try {
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.write(this.compressedData);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void encode(){
  try {
    ByteArrayOutputStream bos=new ByteArrayOutputStream();
    PEBinaryWriter writer=new PEBinaryWriter(bos);
    writer.writeByte((byte)(this.pid() & 0xFF));
    writer.writeInt(chunkX);
    writer.writeInt(chunkZ);
    writer.writeInt(chunkData.length);
    writer.write(chunkData);
    this.setData(bos.toByteArray());
  }
 catch (  IOException e) {
  }
}
Program: 96700
Project: 96700
Buggy source:
@Override public PEPacket[] translateToPE(Message message){
  if (mapToPE.containsKey(message.getClass())) {
    return mapToPE.get(message.getClass()).handle(message);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override public PEPacket[] translateToPE(Message message){
  if (mapToPE.containsKey(message.getClass())) {
    return mapToPE.get(message.getClass()).handle(message);
  }
 else {
    System.out.println("String_Node_Str" + message.getClass().getSimpleName());
    return null;
  }
}
Program: 96701
Project: 96701
Buggy source:
@Override public Message[] translateToPC(PEPacket packet){
  if (packet instanceof BatchPacket) {
    BatchPacket pkBatch=(BatchPacket)packet;
    if (pkBatch.packets == null || pkBatch.packets.isEmpty()) {
      return null;
    }
    ArrayList<Message> msgs=new ArrayList<>();
    for (    PEPacket subPacket : pkBatch.packets) {
      Message[] ret=this.translateToPC(subPacket);
      if (ret != null) {
        msgs.addAll(Arrays.asList(ret));
      }
    }
    return msgs.toArray(new Message[0]);
  }
  if (mapToPC.containsKey(packet.getClass())) {
    return mapToPC.get(packet.getClass()).handle(packet);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Override public Message[] translateToPC(PEPacket packet){
  if (mapToPC.containsKey(packet.getClass())) {
    return mapToPC.get(packet.getClass()).handle(packet);
  }
 else {
    System.out.println("String_Node_Str" + packet.getClass().getSimpleName());
    return null;
  }
}
Program: 96702
Project: 96702
Buggy source:
public String readString(int lenLen) throws IOException {
  falloc(lenLen);
  int length=(int)readNat(lenLen);
  falloc(length);
  this.totallyRead+=length;
  return new String(read(length),"String_Node_Str");
}

Fixed version (ground truth):
public String readString(int lenLen) throws IOException {
  falloc(lenLen);
  int length=(int)readNat(lenLen);
  falloc(length);
  return new String(read(length),"String_Node_Str");
}
Program: 96703
Project: 96703
Buggy source:
public long readNat(int length) throws IOException {
  falloc(length);
  this.totallyRead+=length;
  return PEBinaryUtils.read(read(length),0,length,endianness);
}

Fixed version (ground truth):
public long readNat(int length) throws IOException {
  falloc(length);
  return PEBinaryUtils.read(read(length),0,length,endianness);
}
Program: 96704
Project: 96704
Buggy source:
public long readLong() throws IOException {
  falloc(8);
  this.totallyRead+=8;
  return readNat(8);
}

Fixed version (ground truth):
public long readLong() throws IOException {
  falloc(8);
  return readNat(8);
}
Program: 96705
Project: 96705
Buggy source:
public short readShort() throws IOException {
  falloc(2);
  this.totallyRead+=2;
  return (short)(readNat(2) & 0xFFFF);
}

Fixed version (ground truth):
public short readShort() throws IOException {
  falloc(2);
  return (short)(readNat(2) & 0xFFFF);
}
Program: 96706
Project: 96706
Buggy source:
public double readDouble() throws IOException {
  falloc(8);
  this.totallyRead+=8;
  ByteBuffer bb=ByteBuffer.wrap(read(8));
  return bb.getDouble();
}

Fixed version (ground truth):
public double readDouble() throws IOException {
  falloc(8);
  ByteBuffer bb=ByteBuffer.wrap(read(8));
  return bb.getDouble();
}
Program: 96707
Project: 96707
Buggy source:
public float readFloat() throws IOException {
  falloc(4);
  this.totallyRead+=4;
  ByteBuffer bb=ByteBuffer.wrap(read(4));
  return bb.getFloat();
}

Fixed version (ground truth):
public float readFloat() throws IOException {
  falloc(4);
  ByteBuffer bb=ByteBuffer.wrap(read(4));
  return bb.getFloat();
}
Program: 96708
Project: 96708
Buggy source:
public byte readByte() throws IOException {
  falloc(1);
  this.totallyRead+=1;
  return (byte)is.read();
}

Fixed version (ground truth):
public byte readByte() throws IOException {
  falloc(1);
  totallyRead+=1;
  return (byte)is.read();
}
Program: 96709
Project: 96709
Buggy source:
public int readInt() throws IOException {
  falloc(4);
  this.totallyRead+=4;
  return (int)(readNat(4) & 0xFFFFFFFF);
}

Fixed version (ground truth):
public int readInt() throws IOException {
  falloc(4);
  return (int)(readNat(4) & 0xFFFFFFFF);
}
Program: 96710
Project: 96710
Buggy source:
public int readTriad() throws IOException {
  falloc(3);
  this.totallyRead+=3;
  this.endianness=!this.endianness;
  int triad=(int)(readNat(3) & 0xFFFFFF);
  this.endianness=!this.endianness;
  return triad;
}

Fixed version (ground truth):
public int readTriad() throws IOException {
  falloc(3);
  this.endianness=!this.endianness;
  int triad=(int)(readNat(3) & 0xFFFFFF);
  this.endianness=!this.endianness;
  return triad;
}
Program: 96711
Project: 96711
Buggy source:
public static BaseTranslator getByPEProtocolID(DragonetSession session,int protocolID){
switch (protocolID) {
case 24:
    return new Translator_v0_11(session);
default :
  return null;
}
}

Fixed version (ground truth):
public static BaseTranslator getByPEProtocolID(DragonetSession session,int protocolID){
switch (protocolID) {
case 23:
case 24:
    return new Translator_v0_11(session);
default :
  return null;
}
}
Program: 96714
Project: 96714
Buggy source:
public static void setArea(String worldName,int x1,int y1,int z1,int x2,int y2,int z2,String materialName,byte data){
  for (int x=x1; x < x2; x++) {
    for (int y=y1; y < y2; y++) {
      for (int z=z1; z < z2; z++) {
        setBlock.setBlock(worldName,x,y,z,materialName,data);
      }
    }
  }
}

Fixed version (ground truth):
public static void setArea(String worldName,int x1,int y1,int z1,int x2,int y2,int z2,String materialName,int tileData){
  for (int x=x1; x < x2; x++) {
    for (int y=y1; y < y2; y++) {
      for (int z=z1; z < z2; z++) {
        setBlock.setBlock(worldName,x,y,z,materialName,java.lang.Byte.parseByte(tileData + "String_Node_Str"));
      }
    }
  }
}
Program: 96715
Project: 96715
Buggy source:
public static void setBlock(String worldName,int x,int y,int z,String tileName,byte tileData){
  org.dragonet.DragonetServer.instance().getServer().getWorld(worldName).getBlockAt(x,y,z).setType(Material.getMaterial(tileName));
  org.dragonet.DragonetServer.instance().getServer().getWorld(worldName).getBlockAt(x,y,z).setData(tileData);
}

Fixed version (ground truth):
public static void setBlock(String worldName,int x,int y,int z,String tileName,int tileData){
  org.dragonet.DragonetServer.instance().getServer().getWorld(worldName).getBlockAt(x,y,z).setType(Material.getMaterial(tileName));
  org.dragonet.DragonetServer.instance().getServer().getWorld(worldName).getBlockAt(x,y,z).setData(java.lang.Byte.parseByte(tileData + "String_Node_Str"));
}
Program: 96716
Project: 96716
Buggy source:
public static void banPlayer(Player plr){
  if (!plr.isBanned()) {
    org.dragonet.DragonetServer.instance().getServer().getBanList(BanList.Type.NAME).addBan(plr.getName(),"String_Node_Str",null,null);
  }
 else {
    org.dragonet.DragonetServer.instance().getLogger().warn("String_Node_Str" + plr.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public static void banPlayer(Object player,String reason){
  Player plr=(Player)player;
  if (!plr.isBanned()) {
    org.dragonet.DragonetServer.instance().getServer().getBanList(BanList.Type.NAME).addBan(plr.getName(),reason,null,null);
  }
 else {
    org.dragonet.DragonetServer.instance().getLogger().warn("String_Node_Str" + plr.getName() + "String_Node_Str");
  }
}
Program: 96717
Project: 96717
Buggy source:
public static void clearInventory(Player plr){
  plr.getInventory().clear();
}

Fixed version (ground truth):
public static void clearInventory(Object plr){
  try {
    ((Player)plr).getInventory().clear();
  }
 catch (  ClassCastException cce) {
    org.dragonet.DragonetServer.instance().getLogger().warn("String_Node_Str");
  }
}
Program: 96718
Project: 96718
Buggy source:
public static void stopServer(){
  org.dragonet.DragonetServer.instance().getServer().savePlayers();
  for (  Player plr : org.dragonet.DragonetServer.instance().getServer().getOnlinePlayers()) {
    plr.kickPlayer("String_Node_Str");
  }
  org.dragonet.DragonetServer.instance().getServer().shutdown();
}

Fixed version (ground truth):
public static void stopServer(String msg){
  org.dragonet.DragonetServer.instance().getServer().savePlayers();
  for (  Player plr : org.dragonet.DragonetServer.instance().getServer().getOnlinePlayers()) {
    plr.kickPlayer(msg);
  }
  org.dragonet.DragonetServer.instance().getServer().shutdown();
}
Program: 96719
Project: 96719
Buggy source:
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name);
  }
}

Fixed version (ground truth):
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name + "String_Node_Str"+ s.fileContents+ "String_Node_Str");
  }
}
Program: 96720
Project: 96720
Buggy source:
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
  }
  finally {
    Context.exit();
  }
}

Fixed version (ground truth):
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
    System.out.println(Context.jsToJava(result,int.class));
  }
  finally {
    Context.exit();
  }
}
Program: 96721
Project: 96721
Buggy source:
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name + "String_Node_Str"+ s.fileContents+ "String_Node_Str");
  }
}

Fixed version (ground truth):
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name);
  }
}
Program: 96722
Project: 96722
Buggy source:
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
    System.out.println(Context.jsToJava(result,int.class));
  }
  finally {
    Context.exit();
  }
}

Fixed version (ground truth):
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
  }
  finally {
    Context.exit();
  }
}
Program: 96723
Project: 96723
Buggy source:
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name + "String_Node_Str"+ s.fileContents+ "String_Node_Str");
  }
}

Fixed version (ground truth):
public void startJSInterpreter(){
  Scripts=loadJSFiles();
  for (  Script s : Scripts) {
    System.out.println("String_Node_Str" + s.name);
  }
}
Program: 96724
Project: 96724
Buggy source:
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
    System.out.println(Context.jsToJava(result,int.class));
  }
  finally {
    Context.exit();
  }
}

Fixed version (ground truth):
public void runFunction(String func){
  BufferedReader script=null;
  try {
    script=new BufferedReader(new FileReader(this.getFile()));
  }
 catch (  IOException IOe) {
    System.out.println(Arrays.toString(IOe.getStackTrace()));
  }
  Context context=Context.enter();
  try {
    ScriptableObject scope=context.initStandardObjects();
    try {
      context.evaluateReader(scope,script,"String_Node_Str",1,null);
    }
 catch (    IOException IOe) {
      System.out.println(Arrays.toString(IOe.getStackTrace()));
    }
    Function fct=(Function)scope.get(func,scope);
    Object result=fct.call(context,scope,scope,new Object[]{2,3});
  }
  finally {
    Context.exit();
  }
}
Program: 96725
Project: 96725
Buggy source:
public ItemTranslator_v0_10_0(){
  itemMap_PC_to_PE.put(1,1);
  itemMap_PC_to_PE.put(2,2);
  itemMap_PC_to_PE.put(3,3);
  for (int i=8; i <= 11; i++) {
    itemMap_PC_to_PE.put(i,i);
  }
}

Fixed version (ground truth):
public ItemTranslator_v0_10_0(){
  itemMap_PC_to_PE.put(8,8);
  itemMap_PC_to_PE.put(9,9);
  itemMap_PC_to_PE.put(10,10);
  itemMap_PC_to_PE.put(11,11);
}
Program: 96727
Project: 96727
Buggy source:
/** 
 * Trigger a chunk tick update
 */
public void onTick(){
  this.autoPrepareChunks();
  this.unloadFarChunks();
  this.sendChunks();
}

Fixed version (ground truth):
/** 
 * Trigger a chunk tick update
 */
public void onTick(){
  if (this.getSession().getPlayer() == null) {
    return;
  }
  if (this.lastWorld == null) {
    this.lastWorld=this.getSession().getPlayer().getWorld().getName();
  }
  if (!this.lastWorld.equalsIgnoreCase(this.getSession().getPlayer().getWorld().getName())) {
    for (    ChunkLocation loc : this.chunksLoaded) {
      this.unloadChunk(loc.getX(),loc.getZ());
    }
    this.chunksLoaded.clear();
    this.chunksQueue.clear();
  }
  this.autoPrepareChunks();
  this.unloadFarChunks();
  this.sendChunks();
}
Program: 96728
Project: 96728
Buggy source:
/** 
 * Unload the chunks that distance > 8
 */
public synchronized void unloadFarChunks(){
  if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
    return;
  }
  ChunkLocation playerChunk=new ChunkLocation(this.getSession().getPlayer().getLocation().getBlockX() / 16,this.getSession().getPlayer().getLocation().getBlockZ() / 16);
  ArrayList<ChunkLocation> toUnload=new ArrayList<>();
  for (  ChunkLocation loc : this.chunksLoaded) {
    if (loc.distanceTo(playerChunk) > 16) {
      toUnload.add(loc);
      System.out.println("String_Node_Str" + playerChunk.toString() + "String_Node_Str"+ loc.toString()+ "String_Node_Str"+ loc.distanceTo(playerChunk));
    }
  }
  UnloadChunkPacket pkUnloadChunk;
  for (  ChunkLocation locUnload : toUnload) {
    pkUnloadChunk=new UnloadChunkPacket();
    pkUnloadChunk.x=locUnload.getX();
    pkUnloadChunk.z=locUnload.getZ();
    this.getSession().send(pkUnloadChunk);
  }
  this.chunksLoaded.removeAll(toUnload);
}

Fixed version (ground truth):
/** 
 * Unload the chunks that distance > 8
 */
public synchronized void unloadFarChunks(){
  if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
    return;
  }
  ChunkLocation playerChunk=new ChunkLocation(this.getSession().getPlayer().getLocation().getBlockX() / 16,this.getSession().getPlayer().getLocation().getBlockZ() / 16);
  ArrayList<ChunkLocation> toUnload=new ArrayList<>();
  for (  ChunkLocation loc : this.chunksLoaded) {
    if (loc.distanceTo(playerChunk) > 16) {
      toUnload.add(loc);
      System.out.println("String_Node_Str" + playerChunk.toString() + "String_Node_Str"+ loc.toString()+ "String_Node_Str"+ loc.distanceTo(playerChunk));
    }
  }
  for (  ChunkLocation locUnload : toUnload) {
    this.unloadChunk(locUnload.getX(),locUnload.getZ());
  }
  this.chunksLoaded.removeAll(toUnload);
}