Program: 1306
Project: 1306
Buggy source:
/** 
 * Loads a specified chunk from the cache or queues a new chunk for generation. NOTE: This method ALWAYS returns a valid chunk since new chunks are generated if none of the present chunks fit. TODO: Chunks should be saved to and loaded from the hard disk!
 * @param x X-coordinate of the chunk
 * @param z Z-coordinate of the chunk
 * @return The chunk
 */
private Chunk loadOrCreateChunk(int x,int z){
  Chunk c=getChunk(x,0,z);
  if (c != null) {
    if (c.getPosition().x != x || c.getPosition().y != 0 || c.getPosition().z != z) {
synchronized (_chunkCache) {
        c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
      }
    }
  }
  if (c != null) {
    return c;
  }
 else {
  }
synchronized (_chunkCache) {
    if (_chunkCache.size() >= 1024) {
      ArrayList<Chunk> sortedChunks=new ArrayList<Chunk>(_chunkCache.values());
      Collections.sort(sortedChunks);
      Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
      for (int i=0; i < 256; i++) {
        int indexToDelete=sortedChunks.size() - i;
        if (indexToDelete >= 0 && indexToDelete < sortedChunks.size()) {
          Chunk cc=sortedChunks.get(indexToDelete);
          _chunkCache.remove(Helper.getInstance().cantorize((int)cc.getPosition().x,(int)cc.getPosition().z));
        }
      }
      Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
    }
  }
  ArrayList<Generator> gs=new ArrayList<Generator>();
  gs.add(_generatorTerrain);
  gs.add(_generatorForest);
  c=new Chunk(this,new Vector3f(x,0,z),gs);
synchronized (_chunkCache) {
    _chunkCache.put(Helper.getInstance().cantorize(x,z),c);
  }
  return c;
}

Fixed version (ground truth):
/** 
 * Loads a specified chunk from the cache or queues a new chunk for generation. NOTE: This method ALWAYS returns a valid chunk since new chunks are generated if none of the present chunks fit. TODO: Chunks should be saved to and loaded from the hard disk!
 * @param x X-coordinate of the chunk
 * @param z Z-coordinate of the chunk
 * @return The chunk
 */
private synchronized Chunk loadOrCreateChunk(int x,int z){
  Chunk c=getChunk(x,0,z);
  if (c != null) {
    if (c.getPosition().x != x || c.getPosition().y != 0 || c.getPosition().z != z) {
      c=_chunkCache.get(Helper.getInstance().cantorize(x,z));
    }
  }
  if (c != null) {
    return c;
  }
 else {
  }
  if (_chunkCache.size() >= 1024) {
    ArrayList<Chunk> sortedChunks=new ArrayList<Chunk>(_chunkCache.values());
    Collections.sort(sortedChunks);
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
    for (int i=0; i < 256; i++) {
      int indexToDelete=sortedChunks.size() - i;
      if (indexToDelete >= 0 && indexToDelete < sortedChunks.size()) {
        Chunk cc=sortedChunks.get(indexToDelete);
        _chunkCache.remove(Helper.getInstance().cantorize((int)cc.getPosition().x,(int)cc.getPosition().z));
      }
    }
    Logger.getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str");
  }
  ArrayList<Generator> gs=new ArrayList<Generator>();
  gs.add(_generatorTerrain);
  gs.add(_generatorForest);
  c=new Chunk(this,new Vector3f(x,0,z),gs);
  _chunkCache.put(Helper.getInstance().cantorize(x,z),c);
  return c;
}