Program: 178617
Project: 178617
Buggy source:
public void run(){
  CompressionManager cm=new CompressionManager(this,ptc,fm,out);
  Packet packet=new Packet();
  Packet packetBackup=packet;
  while (!killed()) {
    try {
      packet=in.getPacket(packet);
      if (packet == null) {
        ptc.printLogMessage("String_Node_Str");
        kill();
        continue;
      }
    }
 catch (    EOFException e) {
      ptc.printLogMessage("String_Node_Str");
      kill();
      continue;
    }
catch (    IOException e) {
      System.out.println("String_Node_Str");
      kill();
      continue;
    }
catch (    IllegalStateException ise) {
      kill();
      ptc.printLogMessage("String_Node_Str");
      ptc.printLogMessage(packetBackup + "String_Node_Str");
      ptc.printLogMessage("String_Node_Str" + oldPacketIds);
      continue;
    }
    while (!ptc.messageQueue.isEmpty()) {
      String message=ptc.messageQueue.poll();
      if (message != null) {
        Packet03Chat chat=new Packet03Chat(message);
        try {
          fm.addPacketToHighQueue(out,chat,this);
        }
 catch (        IOException e) {
          kill();
          continue;
        }
      }
    }
    if (packet.start < packet.end) {
      boolean dontSend=false;
      int packetId=packet.getByte(0) & 0xFF;
      if (packetId == 0x32) {
        int x=packet.getInt(1);
        int z=packet.getInt(5);
        boolean mode=packet.getByte(9) != 0;
        if (mode) {
          if (!ptc.connectionInfo.addChunk(x,z)) {
            ptc.printLogMessage("String_Node_Str" + x + "String_Node_Str"+ z);
          }
        }
 else {
          if (!ptc.connectionInfo.removeChunk(x,z)) {
            ptc.printLogMessage("String_Node_Str" + x + "String_Node_Str"+ z);
          }
        }
      }
 else       if (packetId == 0x33 || packetId == 0x51) {
        int x=(packet.getInt(1) >> 4);
        int z=(packet.getInt(5) >> 4);
        if (!ptc.connectionInfo.containsChunk(x,z)) {
          if (Globals.showUnallocatedChunkWarning()) {
            ptc.printLogMessage("String_Node_Str" + Integer.toHexString(packetId) + "String_Node_Str"+ x+ "String_Node_Str"+ z+ "String_Node_Str");
          }
          Packet fakeInit=new Packet32PreChunk(x,z,true);
          ptc.connectionInfo.addChunk(x,z);
          cm.addToQueue(fakeInit);
        }
      }
      int clientPlayerId=ptc.connectionInfo.clientPlayerId;
      int serverPlayerId=ptc.connectionInfo.serverPlayerId;
      Set<Integer> activeEntityIds=ptc.connectionInfo.activeEntities;
      int[] entityIdArray=EntityMap.entityIds[packetId];
      if (entityIdArray != null) {
        for (        int pos : entityIdArray) {
          int id=packet.getInt(pos);
          if (id == clientPlayerId) {
            packet.setInt(pos,serverPlayerId);
            updateEntityId(ptc,activeEntityIds,packetId,serverPlayerId);
          }
 else           if (id == serverPlayerId) {
            packet.setInt(pos,clientPlayerId);
            updateEntityId(ptc,activeEntityIds,packetId,clientPlayerId);
          }
 else {
            updateEntityId(ptc,activeEntityIds,packetId,id);
          }
        }
      }
      if (((packetId >= 0x32 && packetId < 0x36) || packetId == 0x82) || (packetId == 0x51)) {
        cm.addToQueue(packet);
        dontSend=true;
      }
      oldPacketIds.add(packet.buffer[packet.start & packet.mask]);
      if (this.oldPacketIds.size() > 20) {
        oldPacketIds.remove();
      }
      if (!dontSend) {
        ptc.connectionInfo.uploaded.addAndGet(packet.end - packet.start);
        if (!ptc.connectionInfo.forwardConnection && packetId == 0xFF) {
          String message=packet.getString16(1);
          String newHostname=redirectDetected(message,ptc);
          ptc.printLogMessage("String_Node_Str" + newHostname);
          ptc.connectionInfo.setHostname(newHostname);
          if (newHostname != null) {
            ptc.connectionInfo.redirect=true;
            Packet09Respawn normalPacket=new Packet09Respawn((byte)0,(byte)2,(byte)0,(short)128,0L,"String_Node_Str");
            Packet09Respawn netherPacket=new Packet09Respawn((byte)-1,(byte)2,(byte)0,(short)128,0L,"String_Node_Str");
            try {
              fm.addPacketToHighQueue(out,normalPacket,this);
              fm.addPacketToHighQueue(out,netherPacket,this);
            }
 catch (            IOException ioe) {
              kill();
              continue;
            }
            Packet packetBed=new Packet46Bed(2,0);
            try {
              fm.addPacketToHighQueue(out,packetBed,this);
            }
 catch (            IOException ioe) {
              kill();
              continue;
            }
            cm.killTimerAndJoin();
            List<Integer> entityIds=ptc.connectionInfo.clearEntities();
            for (            int id : entityIds) {
              if (id != clientPlayerId) {
                Packet destroy=new Packet1DDestroyEntity(id);
                try {
                  fm.addPacketToHighQueue(out,destroy,this);
                }
 catch (                IOException ioe) {
                  kill();
                  continue;
                }
              }
            }
            List<Long> activeChunks=ptc.connectionInfo.clearChunks();
            for (            Long chunk : activeChunks) {
              int x=ConnectionInfo.getX(chunk);
              int z=ConnectionInfo.getZ(chunk);
              Packet unload=new Packet32PreChunk(x,z,false);
              try {
                fm.addPacketToHighQueue(out,unload,this);
              }
 catch (              IOException ioe) {
                kill();
                continue;
              }
            }
            kill();
            continue;
          }
        }
        try {
          fm.addPacketToHighQueue(out,packet,this);
        }
 catch (        IOException ioe) {
          kill();
          continue;
        }
      }
    }
  }
  cm.killTimerAndJoin();
synchronized (out) {
    try {
      out.flush();
    }
 catch (    IOException e) {
      ptc.printLogMessage("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void run(){
  CompressionManager cm=new CompressionManager(this,ptc,fm,out);
  Packet packet=new Packet();
  Packet packetBackup=packet;
  while (!killed()) {
    try {
      packet=in.getPacket(packet);
      if (packet == null) {
        ptc.printLogMessage("String_Node_Str");
        kill();
        continue;
      }
    }
 catch (    EOFException e) {
      ptc.printLogMessage("String_Node_Str");
      kill();
      continue;
    }
catch (    IOException e) {
      System.out.println("String_Node_Str");
      kill();
      continue;
    }
catch (    IllegalStateException ise) {
      kill();
      ptc.printLogMessage("String_Node_Str");
      ptc.printLogMessage(packetBackup + "String_Node_Str");
      ptc.printLogMessage("String_Node_Str" + oldPacketIds);
      continue;
    }
    while (!ptc.messageQueue.isEmpty()) {
      String message=ptc.messageQueue.poll();
      if (message != null) {
        Packet03Chat chat=new Packet03Chat(message);
        try {
          fm.addPacketToHighQueue(out,chat,this);
        }
 catch (        IOException e) {
          kill();
          continue;
        }
      }
    }
    if (packet.start < packet.end) {
      boolean dontSend=false;
      int packetId=packet.getByte(0) & 0xFF;
      if (packetId == 0x32) {
        int x=packet.getInt(1);
        int z=packet.getInt(5);
        boolean mode=packet.getByte(9) != 0;
        if (mode) {
          if (!ptc.connectionInfo.addChunk(x,z)) {
            ptc.printLogMessage("String_Node_Str" + x + "String_Node_Str"+ z);
          }
        }
 else {
          if (!ptc.connectionInfo.removeChunk(x,z)) {
            ptc.printLogMessage("String_Node_Str" + x + "String_Node_Str"+ z);
          }
        }
      }
 else       if (packetId == 0x33 || packetId == 0x51) {
        int x=(packet.getInt(1) >> 4);
        int z=(packet.getInt(5) >> 4);
        if (!ptc.connectionInfo.containsChunk(x,z)) {
          if (Globals.showUnallocatedChunkWarning()) {
            ptc.printLogMessage("String_Node_Str" + Integer.toHexString(packetId) + "String_Node_Str"+ x+ "String_Node_Str"+ z+ "String_Node_Str");
          }
          Packet fakeInit=new Packet32PreChunk(x,z,true);
          ptc.connectionInfo.addChunk(x,z);
          cm.addToQueue(fakeInit);
        }
      }
      int clientPlayerId=ptc.connectionInfo.clientPlayerId;
      int serverPlayerId=ptc.connectionInfo.serverPlayerId;
      Set<Integer> activeEntityIds=ptc.connectionInfo.activeEntities;
      int[] entityIdArray=EntityMap.entityIds[packetId];
      if (entityIdArray != null) {
        for (        int pos : entityIdArray) {
          int id=packet.getInt(pos);
          if (id == clientPlayerId) {
            packet.setInt(pos,serverPlayerId);
            updateEntityId(ptc,activeEntityIds,packetId,serverPlayerId);
          }
 else           if (id == serverPlayerId) {
            packet.setInt(pos,clientPlayerId);
            updateEntityId(ptc,activeEntityIds,packetId,clientPlayerId);
          }
 else {
            updateEntityId(ptc,activeEntityIds,packetId,id);
          }
        }
      }
      if (((packetId >= 0x32 && packetId < 0x36) || packetId == 0x82) || (packetId == 0x51)) {
        cm.addToQueue(packet);
        dontSend=true;
      }
      oldPacketIds.add(packet.buffer[packet.start & packet.mask]);
      if (this.oldPacketIds.size() > 20) {
        oldPacketIds.remove();
      }
      if (!dontSend) {
        ptc.connectionInfo.uploaded.addAndGet(packet.end - packet.start);
        if (!ptc.connectionInfo.forwardConnection && packetId == 0xFF) {
          String message=packet.getString16(1);
          String newHostname=redirectDetected(message,ptc);
          ptc.printLogMessage("String_Node_Str" + newHostname);
          ptc.connectionInfo.setHostname(newHostname);
          if (newHostname != null) {
            ptc.connectionInfo.redirect=true;
            Packet09Respawn normalPacket=new Packet09Respawn((int)0,(byte)2,(byte)0,(short)Globals.getMaxWorldHeight(),"String_Node_Str");
            Packet09Respawn netherPacket=new Packet09Respawn((int)-1,(byte)2,(byte)0,(short)Globals.getMaxWorldHeight(),"String_Node_Str");
            try {
              fm.addPacketToHighQueue(out,normalPacket,this);
              fm.addPacketToHighQueue(out,netherPacket,this);
            }
 catch (            IOException ioe) {
              kill();
              continue;
            }
            Packet packetBed=new Packet46Bed(2,0);
            try {
              fm.addPacketToHighQueue(out,packetBed,this);
            }
 catch (            IOException ioe) {
              kill();
              continue;
            }
            cm.killTimerAndJoin();
            List<Integer> entityIds=ptc.connectionInfo.clearEntities();
            for (            int id : entityIds) {
              if (id != clientPlayerId) {
                Packet destroy=new Packet1DDestroyEntity(id);
                try {
                  fm.addPacketToHighQueue(out,destroy,this);
                }
 catch (                IOException ioe) {
                  kill();
                  continue;
                }
              }
            }
            List<Long> activeChunks=ptc.connectionInfo.clearChunks();
            for (            Long chunk : activeChunks) {
              int x=ConnectionInfo.getX(chunk);
              int z=ConnectionInfo.getZ(chunk);
              Packet unload=new Packet32PreChunk(x,z,false);
              try {
                fm.addPacketToHighQueue(out,unload,this);
              }
 catch (              IOException ioe) {
                kill();
                continue;
              }
            }
            kill();
            continue;
          }
        }
        try {
          fm.addPacketToHighQueue(out,packet,this);
        }
 catch (        IOException ioe) {
          kill();
          continue;
        }
      }
    }
  }
  cm.killTimerAndJoin();
synchronized (out) {
    try {
      out.flush();
    }
 catch (    IOException e) {
      ptc.printLogMessage("String_Node_Str");
    }
  }
}