nus-yam/ex-repair huggingface dataset:
Program: 177445
Project: 177445
Buggy source:
@UnsafeMethod public synchronized void enablePlugin(Plugin paramPlugin){
  if (!CommonPlugin.class.isAssignableFrom(paramPlugin.getClass())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!paramPlugin.isEnabled()) {
    CommonPlugin cp=(CommonPlugin)paramPlugin;
    String name=cp.getDescription().getName();
    if (!loaders.containsKey(name)) {
      loaders.put(name,(CommonClassLoader)cp.getClassLoader());
    }
    try {
      cp.setEnabled(true);
      cp.onEnable();
    }
 catch (    Throwable e) {
      game.getLogger().log(Level.SEVERE,new StringBuilder().append("String_Node_Str").append(paramPlugin.getDescription().getFullName()).append("String_Node_Str").append(e.getMessage()).toString(),e);
    }
  }
}

Fixed version (ground truth):
@UnsafeMethod public synchronized void enablePlugin(Plugin paramPlugin){
  if (!CommonPlugin.class.isAssignableFrom(paramPlugin.getClass())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!paramPlugin.isEnabled()) {
    CommonPlugin cp=(CommonPlugin)paramPlugin;
    String name=cp.getDescription().getName();
    if (!loaders.containsKey(name)) {
      loaders.put(name,(CommonClassLoader)cp.getClassLoader());
    }
    try {
      cp.setEnabled(true);
      cp.onEnable();
    }
 catch (    Throwable e) {
      engine.getLogger().log(Level.SEVERE,new StringBuilder().append("String_Node_Str").append(paramPlugin.getDescription().getFullName()).append("String_Node_Str").append(e.getMessage()).toString(),e);
    }
  }
}
Program: 177446
Project: 177446
Buggy source:
@UnsafeMethod public synchronized void disablePlugin(Plugin paramPlugin){
  if (!CommonPlugin.class.isAssignableFrom(paramPlugin.getClass())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (paramPlugin.isEnabled()) {
    CommonPlugin cp=(CommonPlugin)paramPlugin;
    String name=cp.getDescription().getName();
    if (!loaders.containsKey(name)) {
      loaders.put(name,(CommonClassLoader)cp.getClassLoader());
    }
    try {
      cp.setEnabled(false);
      cp.onDisable();
    }
 catch (    Throwable t) {
      game.getLogger().log(Level.SEVERE,new StringBuilder().append("String_Node_Str").append(paramPlugin.getDescription().getFullName()).append("String_Node_Str").append(t.getMessage()).toString(),t);
    }
  }
}

Fixed version (ground truth):
@UnsafeMethod public synchronized void disablePlugin(Plugin paramPlugin){
  if (!CommonPlugin.class.isAssignableFrom(paramPlugin.getClass())) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (paramPlugin.isEnabled()) {
    CommonPlugin cp=(CommonPlugin)paramPlugin;
    String name=cp.getDescription().getName();
    if (!loaders.containsKey(name)) {
      loaders.put(name,(CommonClassLoader)cp.getClassLoader());
    }
    try {
      cp.setEnabled(false);
      cp.onDisable();
    }
 catch (    Throwable t) {
      engine.getLogger().log(Level.SEVERE,new StringBuilder().append("String_Node_Str").append(paramPlugin.getDescription().getFullName()).append("String_Node_Str").append(t.getMessage()).toString(),t);
    }
  }
}
Program: 177447
Project: 177447
Buggy source:
protected Class<?> getClassByName(final String name){
  Class<?> cached=classes.get(name);
  if (cached != null) {
    return cached;
  }
  for (  String current : loaders.keySet()) {
    CommonClassLoader loader=loaders.get(current);
    try {
      cached=loader.findClass(name,false);
    }
 catch (    ClassNotFoundException cnfe) {
    }
    if (cached != null) {
      return cached;
    }
  }
  return null;
}

Fixed version (ground truth):
protected Class<?> getClassByName(final String name){
  for (  String current : loaders.keySet()) {
    CommonClassLoader loader=loaders.get(current);
    try {
      Class<?> clazz=loader.findClass(name,false);
      if (clazz != null) {
        return clazz;
      }
    }
 catch (    ClassNotFoundException ignored) {
    }
  }
  return null;
}
Program: 177448
Project: 177448
Buggy source:
public synchronized Plugin loadPlugin(File paramFile,boolean ignoresoftdepends) throws InvalidPluginException, InvalidPluginException, UnknownDependencyException, InvalidDescriptionFileException {
  CommonPlugin result=null;
  PluginDescriptionFile desc=null;
  desc=getDescription(paramFile);
  File dataFolder=new File(paramFile.getParentFile(),desc.getName());
  processDependencies(desc);
  if (!ignoresoftdepends) {
    processSoftDependencies(desc);
  }
  try {
    loader.addURL(paramFile.toURI().toURL());
    Class<?> main=Class.forName(desc.getMain(),true,loader);
    Class<? extends CommonPlugin> plugin=main.asSubclass(CommonPlugin.class);
    boolean locked=manager.lock(key);
    Constructor<? extends CommonPlugin> constructor=plugin.getConstructor();
    result=constructor.newInstance();
    result.initialize(this,game,desc,dataFolder,paramFile,loader);
    if (!locked) {
      manager.unlock(key);
    }
  }
 catch (  Exception e) {
    throw new InvalidPluginException(e);
  }
  loaders.put(desc.getName(),loader);
  return result;
}

Fixed version (ground truth):
public synchronized Plugin loadPlugin(File paramFile,boolean ignoresoftdepends) throws InvalidPluginException, InvalidPluginException, UnknownDependencyException, InvalidDescriptionFileException {
  CommonPlugin result=null;
  PluginDescriptionFile desc=null;
  CommonClassLoader loader;
  desc=getDescription(paramFile);
  File dataFolder=new File(paramFile.getParentFile(),desc.getName());
  processDependencies(desc);
  if (!ignoresoftdepends) {
    processSoftDependencies(desc);
  }
  try {
    if (engine.getPlatform() == Platform.CLIENT) {
      loader=new ClientClassLoader(this,this.getClass().getClassLoader());
    }
 else {
      loader=new CommonClassLoader(this,this.getClass().getClassLoader());
    }
    loader.addURL(paramFile.toURI().toURL());
    Class<?> main=Class.forName(desc.getMain(),true,loader);
    Class<? extends CommonPlugin> plugin=main.asSubclass(CommonPlugin.class);
    boolean locked=manager.lock(key);
    Constructor<? extends CommonPlugin> constructor=plugin.getConstructor();
    result=constructor.newInstance();
    result.initialize(this,engine,desc,dataFolder,paramFile,loader);
    if (!locked) {
      manager.unlock(key);
    }
  }
 catch (  Exception e) {
    throw new InvalidPluginException(e);
  }
  loaders.put(desc.getName(),loader);
  return result;
}
Program: 177449
Project: 177449
Buggy source:
/** 
 * @param paramFile Plugin file object
 * @return The current plugin's description element.
 * @throws InvalidPluginException
 * @throws InvalidDescriptionFileException
 */
protected synchronized PluginDescriptionFile getDescription(File paramFile) throws InvalidPluginException, InvalidDescriptionFileException {
  if (!paramFile.exists()) {
    throw new InvalidPluginException(new StringBuilder().append(paramFile.getName()).append("String_Node_Str").toString());
  }
  PluginDescriptionFile desc=null;
  JarFile jar=null;
  InputStream in=null;
  try {
    jar=new JarFile(paramFile);
    JarEntry entry=jar.getJarEntry(YAML_SPOUT);
    if (entry == null) {
      entry=jar.getJarEntry(YAML_OTHER);
    }
    if (entry == null) {
      throw new InvalidPluginException("String_Node_Str");
    }
    in=jar.getInputStream(entry);
    desc=new PluginDescriptionFile(in);
  }
 catch (  IOException e) {
    throw new InvalidPluginException(e);
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      IOException e) {
        game.getLogger().log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (jar != null) {
      try {
        jar.close();
      }
 catch (      IOException e) {
        game.getLogger().log(Level.WARNING,"String_Node_Str",e);
      }
    }
  }
  return desc;
}

Fixed version (ground truth):
/** 
 * @param paramFile Plugin file object
 * @return The current plugin's description element.
 * @throws InvalidPluginException
 * @throws InvalidDescriptionFileException
 */
protected synchronized PluginDescriptionFile getDescription(File paramFile) throws InvalidPluginException, InvalidDescriptionFileException {
  if (!paramFile.exists()) {
    throw new InvalidPluginException(new StringBuilder().append(paramFile.getName()).append("String_Node_Str").toString());
  }
  PluginDescriptionFile desc=null;
  JarFile jar=null;
  InputStream in=null;
  try {
    jar=new JarFile(paramFile);
    JarEntry entry=jar.getJarEntry(YAML_SPOUT);
    if (entry == null) {
      entry=jar.getJarEntry(YAML_OTHER);
    }
    if (entry == null) {
      throw new InvalidPluginException("String_Node_Str");
    }
    in=jar.getInputStream(entry);
    desc=new PluginDescriptionFile(in);
  }
 catch (  IOException e) {
    throw new InvalidPluginException(e);
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      IOException e) {
        engine.getLogger().log(Level.WARNING,"String_Node_Str",e);
      }
    }
    if (jar != null) {
      try {
        jar.close();
      }
 catch (      IOException e) {
        engine.getLogger().log(Level.WARNING,"String_Node_Str",e);
      }
    }
  }
  return desc;
}
Program: 177450
Project: 177450
Buggy source:
public CommonPluginLoader(final Engine game,final CommonSecurityManager manager,final double key){
  this.game=game;
  this.manager=manager;
  this.key=key;
  patterns=new Pattern[]{Pattern.compile("String_Node_Str")};
  loader=game.getPlatform() == Platform.CLIENT ? new ClientClassLoader(this,getClass().getClassLoader()) : new CommonClassLoader(this,getClass().getClassLoader());
}

Fixed version (ground truth):
public CommonPluginLoader(final Engine engine,final CommonSecurityManager manager,final double key){
  this.engine=engine;
  this.manager=manager;
  this.key=key;
  patterns=new Pattern[]{Pattern.compile("String_Node_Str")};
}
Program: 177451
Project: 177451
Buggy source:
/** 
 * Adds a task to this executor's queue
 * @param task the runnable to execute
 */
public Future<?> addToQueue(ManagementTask task) throws InterruptedException ;

Fixed version (ground truth):
/** 
 * Adds a task to this executor's queue
 * @param task the runnable to execute
 */
public void addToQueue(ManagementRunnable task) throws InterruptedException ;
Program: 177452
Project: 177452
Buggy source:
public Managed(AsyncManager manager){
  manager.addManaged(this);
  this.manager=manager;
}

Fixed version (ground truth):
public Managed(AsyncManager manager){
  this.manager=manager;
}
Program: 177453
Project: 177453
Buggy source:
public SpoutRegion(SpoutWorld world,float x,float y,float z,RegionSource source,LoadOption loadopt){
  super(world,x * Region.BLOCKS.SIZE,y * Region.BLOCKS.SIZE,z * Region.BLOCKS.SIZE);
  this.source=source;
  manager=new SpoutRegionManager(this,2,new ThreadAsyncExecutor(this.toString() + "String_Node_Str"),world.getEngine());
  AsyncExecutor ae=manager.getExecutor();
  if (ae instanceof Thread) {
    executionThread=(Thread)ae;
  }
 else {
    executionThread=null;
  }
  for (int dx=0; dx < CHUNKS.SIZE; dx++) {
    for (int dy=0; dy < CHUNKS.SIZE; dy++) {
      for (int dz=0; dz < CHUNKS.SIZE; dz++) {
        chunks[dx][dy][dz]=new AtomicReference<SpoutChunk>(loadopt.loadIfNeeded() ? getChunk(dx,dy,dz,loadopt) : null);
      }
    }
  }
  File worldDirectory=world.getDirectory();
  File regionDirectory=new File(worldDirectory,"String_Node_Str");
  regionDirectory.mkdirs();
  File regionFile=new File(regionDirectory,"String_Node_Str" + getX() + "String_Node_Str"+ getY()+ "String_Node_Str"+ getZ()+ "String_Node_Str");
  this.chunkStore=new BAAWrapper(regionFile,SEGMENT_SIZE,CHUNKS.VOLUME,TIMEOUT);
  Thread t;
  AsyncExecutor e=manager.getExecutor();
  if (e instanceof Thread) {
    t=(Thread)e;
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
  taskManager=new SpoutTaskManager(world.getEngine().getScheduler(),false,t,world.getAge());
}

Fixed version (ground truth):
public SpoutRegion(SpoutWorld world,float x,float y,float z,RegionSource source,LoadOption loadopt){
  super(world,x * Region.BLOCKS.SIZE,y * Region.BLOCKS.SIZE,z * Region.BLOCKS.SIZE);
  this.source=source;
  manager=new SpoutRegionManager(this,2,new ThreadAsyncExecutor(this.toString() + "String_Node_Str"),world.getEngine());
  AsyncExecutor ae=manager.getExecutor();
  if (ae instanceof Thread) {
    executionThread=(Thread)ae;
  }
 else {
    executionThread=null;
  }
  dynamicBlockTree=new DynamicBlockUpdateTree(this);
  for (int dx=0; dx < CHUNKS.SIZE; dx++) {
    for (int dy=0; dy < CHUNKS.SIZE; dy++) {
      for (int dz=0; dz < CHUNKS.SIZE; dz++) {
        chunks[dx][dy][dz]=new AtomicReference<SpoutChunk>(loadopt.loadIfNeeded() ? getChunk(dx,dy,dz,loadopt) : null);
      }
    }
  }
  File worldDirectory=world.getDirectory();
  File regionDirectory=new File(worldDirectory,"String_Node_Str");
  regionDirectory.mkdirs();
  File regionFile=new File(regionDirectory,"String_Node_Str" + getX() + "String_Node_Str"+ getY()+ "String_Node_Str"+ getZ()+ "String_Node_Str");
  this.chunkStore=new BAAWrapper(regionFile,SEGMENT_SIZE,CHUNKS.VOLUME,TIMEOUT);
  Thread t;
  AsyncExecutor e=manager.getExecutor();
  if (e instanceof Thread) {
    t=(Thread)e;
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
  taskManager=new SpoutTaskManager(world.getEngine().getScheduler(),false,t,world.getAge());
}
Program: 177454
Project: 177454
Buggy source:
public DynamicBlockUpdate getNextUpdate(long currentTime){
  if (queuedUpdates.isEmpty()) {
    return null;
  }
 else {
    DynamicBlockUpdate first=queuedUpdates.first();
    if (first == null) {
      return null;
    }
 else {
      if (first.getNextUpdate() <= currentTime) {
        if (!remove(first)) {
          throw new IllegalStateException("String_Node_Str");
        }
 else {
          return first;
        }
      }
 else {
        return null;
      }
    }
  }
}

Fixed version (ground truth):
public DynamicBlockUpdate getNextUpdate(long currentTime){
  TickStage.checkStage(TickStage.FINALIZE,regionThread);
  if (queuedUpdates.isEmpty()) {
    return null;
  }
 else {
    DynamicBlockUpdate first=queuedUpdates.first();
    if (first == null) {
      return null;
    }
 else {
      if (first.getNextUpdate() <= currentTime) {
        if (!remove(first)) {
          throw new IllegalStateException("String_Node_Str");
        }
 else {
          return first;
        }
      }
 else {
        return null;
      }
    }
  }
}
Program: 177455
Project: 177455
Buggy source:
public boolean removeDynamicBlockUpdates(Chunk c){
  TickStage.checkStage(TickStage.SNAPSHOT);
  Set<DynamicBlockUpdate> toRemove=getDynamicBlockUpdates(c);
  if (toRemove != null && toRemove.size() > 0) {
    List<DynamicBlockUpdate> list=new ArrayList<DynamicBlockUpdate>(toRemove);
    for (    DynamicBlockUpdate dm : list) {
      remove(dm);
    }
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
public boolean removeDynamicBlockUpdates(Chunk c){
  TickStage.checkStage(TickStage.SNAPSHOT,regionThread);
  Set<DynamicBlockUpdate> toRemove=getDynamicBlockUpdates(c);
  if (toRemove != null && toRemove.size() > 0) {
    List<DynamicBlockUpdate> list=new ArrayList<DynamicBlockUpdate>(toRemove);
    for (    DynamicBlockUpdate dm : list) {
      if (!remove(dm)) {
        throw new IllegalStateException("String_Node_Str" + c);
      }
    }
    return false;
  }
 else {
    return true;
  }
}
Program: 177456
Project: 177456
Buggy source:
/** 
 * Removes a specific update
 * @param update the update to remove
 * @return true if the update was removed
 */
private boolean remove(DynamicBlockUpdate update){
  boolean removed=false;
  DynamicBlockUpdate previous=blockToUpdateMap.remove(update.getPacked());
  while (previous != null) {
    if (previous != update) {
      previous=previous.getNext();
      continue;
    }
    removed=true;
    if (!queuedUpdates.remove(previous)) {
      throw new IllegalStateException("String_Node_Str");
    }
    int previousPacked=previous.getChunkPacked();
    HashSet<DynamicBlockUpdate> chunkSet=chunkToUpdateMap.get(previousPacked);
    if (chunkSet == null || !chunkSet.remove(previous)) {
      throw new IllegalStateException("String_Node_Str");
    }
 else {
      if (chunkSet.size() == 0) {
        if (chunkToUpdateMap.remove(previousPacked) == null) {
          throw new IllegalStateException("String_Node_Str");
        }
      }
    }
    previous=previous.getNext();
  }
  return removed;
}

Fixed version (ground truth):
/** 
 * Removes a specific update
 * @param update the update to remove
 * @return true if the update was removed
 */
private boolean remove(DynamicBlockUpdate update){
  boolean removed=false;
  int packedKey=update.getPacked();
  DynamicBlockUpdate root=blockToUpdateMap.get(packedKey);
  DynamicBlockUpdate current=root;
  DynamicBlockUpdate previous=null;
  boolean rootChanged=false;
  while (current != null) {
    if (current != update) {
      previous=current;
      current=current.getNext();
      continue;
    }
    removed=true;
    if (!queuedUpdates.remove(current)) {
      throw new IllegalStateException("String_Node_Str");
    }
    int currentPacked=current.getChunkPacked();
    HashSet<DynamicBlockUpdate> chunkSet=chunkToUpdateMap.get(currentPacked);
    if (chunkSet == null || !chunkSet.remove(current)) {
      throw new IllegalStateException("String_Node_Str");
    }
 else {
      if (chunkSet.size() == 0) {
        if (chunkToUpdateMap.remove(currentPacked) == null) {
          throw new IllegalStateException("String_Node_Str");
        }
      }
    }
    if (current == root) {
      root=current.getNext();
      current=root;
      rootChanged=true;
    }
 else {
      if (previous.remove(current) != previous) {
        throw new IllegalStateException("String_Node_Str");
      }
      current=previous.getNext();
    }
  }
  if (rootChanged) {
    if (root != null) {
      blockToUpdateMap.put(packedKey,root);
    }
 else {
      blockToUpdateMap.remove(packedKey);
    }
  }
  return removed;
}
Program: 177457
Project: 177457
Buggy source:
public DynamicBlockUpdateTree(SpoutRegion region){
  this.region=region;
}

Fixed version (ground truth):
public DynamicBlockUpdateTree(SpoutRegion region){
  this.region=region;
  this.regionThread=region.getExceutionThread();
}
Program: 177459
Project: 177459
Buggy source:
public void commitPending(long currentTime){
  TickStage.checkStage(TickStage.FINALIZE);
  List<DynamicBlockUpdate> l;
  while ((l=pendingLists.poll()) != null) {
    for (    DynamicBlockUpdate update : l) {
      add(update);
    }
  }
  processed.clear();
  PointAlone p;
  while ((p=resetPending.poll()) != null) {
    int packed=DynamicBlockUpdate.getPointPacked(p);
    if (!processed.add(packed)) {
      continue;
    }
    int bx=p.getBlockX() & Region.BLOCKS.MASK;
    int by=p.getBlockY() & Region.BLOCKS.MASK;
    int bz=p.getBlockZ() & Region.BLOCKS.MASK;
    removeAll(DynamicBlockUpdate.getBlockPacked(bx,by,bz));
    Chunk c=region.getChunkFromBlock(bx,by,bz,LoadOption.NO_LOAD);
    if (c == null) {
      continue;
    }
    Block b=c.getBlock(bx,by,bz);
    Material m=b.getMaterial();
    if (m instanceof DynamicMaterial) {
      DynamicMaterial dm=(DynamicMaterial)m;
      long nextUpdate=dm.onPlacement(b,region,currentTime);
      if (nextUpdate > 0) {
        add(new DynamicBlockUpdate(bx,by,bz,nextUpdate,currentTime,null));
      }
    }
  }
  while ((p=pending.poll()) != null) {
    int packed=DynamicBlockUpdate.getPointPacked(p);
    if (!processed.add(packed)) {
      continue;
    }
    int bx=p.getBlockX() & Region.BLOCKS.MASK;
    int by=p.getBlockY() & Region.BLOCKS.MASK;
    int bz=p.getBlockZ() & Region.BLOCKS.MASK;
    Object hint=p.getHint();
    long updateTime=p.getUpdateTime();
    add(new DynamicBlockUpdate(bx,by,bz,updateTime,currentTime,hint));
  }
  processed.clear();
}

Fixed version (ground truth):
public void commitPending(long currentTime){
  TickStage.checkStage(TickStage.FINALIZE,regionThread);
  List<DynamicBlockUpdate> l;
  while ((l=pendingLists.poll()) != null) {
    for (    DynamicBlockUpdate update : l) {
      add(update);
    }
  }
  processed.clear();
  PointAlone p;
  while ((p=resetPending.poll()) != null) {
    int packed=DynamicBlockUpdate.getPointPacked(p);
    if (!processed.add(packed)) {
      continue;
    }
    int bx=p.getBlockX() & Region.BLOCKS.MASK;
    int by=p.getBlockY() & Region.BLOCKS.MASK;
    int bz=p.getBlockZ() & Region.BLOCKS.MASK;
    removeAll(DynamicBlockUpdate.getBlockPacked(bx,by,bz));
    Chunk c=region.getChunkFromBlock(bx,by,bz,LoadOption.NO_LOAD);
    if (c == null) {
      continue;
    }
    Block b=c.getBlock(bx,by,bz);
    Material m=b.getMaterial();
    if (m instanceof DynamicMaterial) {
      DynamicMaterial dm=(DynamicMaterial)m;
      long nextUpdate=dm.onPlacement(b,region,currentTime);
      if (nextUpdate > 0) {
        add(new DynamicBlockUpdate(bx,by,bz,nextUpdate,currentTime,null));
      }
    }
  }
  while ((p=pending.poll()) != null) {
    int packed=DynamicBlockUpdate.getPointPacked(p);
    if (!processed.add(packed)) {
      continue;
    }
    int bx=p.getBlockX() & Region.BLOCKS.MASK;
    int by=p.getBlockY() & Region.BLOCKS.MASK;
    int bz=p.getBlockZ() & Region.BLOCKS.MASK;
    Object hint=p.getHint();
    long updateTime=p.getUpdateTime();
    add(new DynamicBlockUpdate(bx,by,bz,updateTime,currentTime,hint));
  }
  processed.clear();
}
Program: 177460
Project: 177460
Buggy source:
private void checkStoreCompressed(){
  double loadFactor=(double)store.getEntries() / (double)store.getSize();
  System.out.println("String_Node_Str" + store.getEntries() + "String_Node_Str"+ store.getSize()+ "String_Node_Str"+ loadFactor+ "String_Node_Str");
  System.out.println();
  assertTrue("String_Node_Str" + loadFactor,loadFactor > 0.37 && loadFactor < 0.76);
}

Fixed version (ground truth):
private void checkStoreCompressed(){
  if (store.getSize() <= 3 && store.getEntries() <= 3) {
    return;
  }
  double loadFactor=(double)store.getEntries() / (double)store.getSize();
  System.out.println("String_Node_Str" + store.getEntries() + "String_Node_Str"+ store.getSize()+ "String_Node_Str"+ loadFactor+ "String_Node_Str");
  System.out.println();
  assertTrue("String_Node_Str" + loadFactor,loadFactor > 0.37 && loadFactor < 0.76);
}
Program: 177461
Project: 177461
Buggy source:
private boolean remove(DynamicBlockUpdate update){
  int packed=update.getPacked();
  DynamicBlockUpdate previous=blockToUpdateMap.remove(packed);
  if (previous != null) {
    if (!queuedUpdates.remove(previous)) {
      throw new IllegalStateException("String_Node_Str");
    }
    HashSet<DynamicBlockUpdate> chunkSet=chunkToUpdateMap.get(previous.getChunkPacked());
    if (chunkSet == null || !chunkSet.remove(update)) {
      throw new IllegalStateException("String_Node_Str");
    }
 else {
      if (chunkSet.size() == 0) {
        if (chunkToUpdateMap.remove(previous.getChunkPacked()) == null) {
          throw new IllegalStateException("String_Node_Str");
        }
      }
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean remove(DynamicBlockUpdate update){
  int packed=update.getPacked();
  DynamicBlockUpdate previous=blockToUpdateMap.remove(packed);
  if (previous != null) {
    if (!queuedUpdates.remove(previous)) {
      throw new IllegalStateException("String_Node_Str");
    }
    int previousPacked=previous.getChunkPacked();
    HashSet<DynamicBlockUpdate> chunkSet=chunkToUpdateMap.get(previousPacked);
    if (chunkSet == null || !chunkSet.remove(previous)) {
      throw new IllegalStateException("String_Node_Str");
    }
 else {
      if (chunkSet.size() == 0) {
        if (chunkToUpdateMap.remove(previousPacked) == null) {
          throw new IllegalStateException("String_Node_Str");
        }
      }
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 177464
Project: 177464
Buggy source:
private static void loadEntities(SpoutRegion r,CompoundMap map){
  if (r != null && map != null) {
    for (    Tag tag : map) {
      loadEntity(r,(CompoundTag)tag);
    }
  }
}

Fixed version (ground truth):
private static void loadEntities(SpoutRegion r,CompoundMap map,List<SpoutEntity> loadedEntities){
  if (r != null && map != null) {
    for (    Tag tag : map) {
      loadedEntities.add(loadEntity(r,(CompoundTag)tag));
    }
  }
}
Program: 177465
Project: 177465
Buggy source:
@Override @LiveRead public SpoutChunk getChunk(int x,int y,int z,LoadGenerateOption loadopt){
  if (x < Region.REGION_SIZE && x >= 0 && y < Region.REGION_SIZE && y >= 0 && z < Region.REGION_SIZE && z >= 0) {
    SpoutChunk chunk=chunks[x][y][z].get();
    if (chunk != null || (!loadopt.loadIfNeeded())) {
      return chunk;
    }
    AtomicReference<SpoutChunk> ref=chunks[x][y][z];
    boolean success=false;
    SpoutChunk newChunk=WorldFiles.loadChunk(this,x,y,z,this.getChunkInputStream(x,y,z));
    if (newChunk == null) {
      if (!loadopt.generateIfNeeded()) {
        return null;
      }
      newChunk=generateChunk(x,y,z);
    }
    while (!success) {
      success=ref.compareAndSet(null,newChunk);
      if (success) {
        newChunk.notifyColumn();
        numberActiveChunks.incrementAndGet();
        if (!newChunk.isPopulated()) {
          nonPopulatedChunks.add(newChunk);
        }
        runningChunksQueue.add(newChunk);
        return newChunk;
      }
 else {
        newChunk.deregisterFromColumn(false);
        SpoutChunk oldChunk=ref.get();
        if (oldChunk != null) {
          return oldChunk;
        }
      }
    }
  }
  throw new IndexOutOfBoundsException("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ z+ "String_Node_Str");
}

Fixed version (ground truth):
@Override @LiveRead public SpoutChunk getChunk(int x,int y,int z,LoadGenerateOption loadopt){
  if (x < Region.REGION_SIZE && x >= 0 && y < Region.REGION_SIZE && y >= 0 && z < Region.REGION_SIZE && z >= 0) {
    SpoutChunk chunk=chunks[x][y][z].get();
    if (chunk != null || (!loadopt.loadIfNeeded())) {
      return chunk;
    }
    AtomicReference<SpoutChunk> ref=chunks[x][y][z];
    boolean success=false;
    List<SpoutEntity> newEntities=new ArrayList<SpoutEntity>(100);
    SpoutChunk newChunk=WorldFiles.loadChunk(this,x,y,z,this.getChunkInputStream(x,y,z),newEntities);
    if (newChunk == null) {
      if (!loadopt.generateIfNeeded()) {
        return null;
      }
      newChunk=generateChunk(x,y,z);
    }
    while (!success) {
      success=ref.compareAndSet(null,newChunk);
      if (success) {
        newChunk.notifyColumn();
        numberActiveChunks.incrementAndGet();
        if (!newChunk.isPopulated()) {
          nonPopulatedChunks.add(newChunk);
        }
        for (        SpoutEntity entity : newEntities) {
          entity.setupInitialChunk(entity.getTransform());
          addEntity(entity);
        }
        runningChunksQueue.add(newChunk);
        return newChunk;
      }
 else {
        newChunk.deregisterFromColumn(false);
        SpoutChunk oldChunk=ref.get();
        if (oldChunk != null) {
          return oldChunk;
        }
      }
    }
  }
  throw new IndexOutOfBoundsException("String_Node_Str" + x + "String_Node_Str"+ y+ "String_Node_Str"+ z+ "String_Node_Str");
}
Program: 177466
Project: 177466
Buggy source:
public void onDeath(){
  death=true;
  entity=null;
  for (  Point p : initializedChunks) {
    removeObserver(p);
  }
}

Fixed version (ground truth):
public void onDeath(){
  TickStage.checkStage(TickStage.FINALIZE);
  death=true;
  entity=null;
  for (  Point p : initializedChunks) {
    removeObserver(p);
  }
}
Program: 177467
Project: 177467
Buggy source:
private void removeObserver(){
  if (controllerLive.get() instanceof PlayerController) {
    return;
  }
  for (  SpoutChunk chunk : observingChunks) {
    if (chunk.isLoaded()) {
      chunk.removeObserver(this);
    }
  }
  observingChunks.clear();
}

Fixed version (ground truth):
private void removeObserver(){
  if (controllerLive.get() instanceof PlayerController) {
    Player p=((PlayerController)controllerLive.get()).getPlayer();
    p.getNetworkSynchronizer().onDeath();
    return;
  }
  for (  SpoutChunk chunk : observingChunks) {
    if (chunk.isLoaded()) {
      chunk.removeObserver(this);
    }
  }
  observingChunks.clear();
}
Program: 177468
Project: 177468
Buggy source:
/** 
 * Creates a new task scheduler.
 */
public SpoutScheduler(Engine server){
  this.server=server;
  mainThread=new MainThread();
  renderThread=new RenderThread();
  taskManager=new SpoutTaskManager(this,true,mainThread);
  parallelTaskManager=(SpoutParallelTaskManager)server.getParallelTaskManager();
}

Fixed version (ground truth):
/** 
 * Creates a new task scheduler.
 */
public SpoutScheduler(Engine engine){
  this.engine=engine;
  mainThread=new MainThread();
  renderThread=new RenderThread();
  taskManager=new SpoutTaskManager(this,true,mainThread);
}
Program: 177469
Project: 177469
Buggy source:
/** 
 * Adds new tasks and updates existing tasks, removing them if necessary.
 */
private boolean tick(long delta) throws InterruptedException {
  TickStage.setStage(TickStage.TICKSTART);
  asyncExecutors.copySnapshot();
  taskManager.heartbeat(delta);
  parallelTaskManager.heartbeat(delta);
  List<AsyncExecutor> executors=asyncExecutors.get();
  int stage=0;
  boolean allStagesComplete=false;
  boolean joined=false;
  TickStage.setStage(TickStage.STAGE1);
  while (!allStagesComplete) {
    if (stage == 0) {
      TickStage.setStage(TickStage.STAGE1);
    }
 else {
      TickStage.setStage(TickStage.STAGE2P);
    }
    allStagesComplete=true;
    for (    AsyncExecutor e : executors) {
      if (stage < e.getManager().getStages()) {
        allStagesComplete=false;
        if (!e.startTick(stage,delta)) {
          return false;
        }
      }
 else {
        continue;
      }
    }
    joined=false;
    while (!joined) {
      try {
        AsyncExecutorUtils.pulseJoinAll(executors,(PULSE_EVERY << 4));
        joined=true;
      }
 catch (      TimeoutException e) {
        if (((SpoutEngine)Spout.getEngine()).isSetupComplete()) {
          server.getLogger().info("String_Node_Str" + (PULSE_EVERY << 4) + "String_Node_Str");
          AsyncExecutorUtils.dumpAllStacks();
          AsyncExecutorUtils.checkForDeadlocks();
        }
      }
    }
    stage++;
  }
  copySnapshot(executors);
  return true;
}

Fixed version (ground truth):
/** 
 * Adds new tasks and updates existing tasks, removing them if necessary.
 */
private boolean tick(long delta) throws InterruptedException {
  TickStage.setStage(TickStage.TICKSTART);
  asyncExecutors.copySnapshot();
  taskManager.heartbeat(delta);
  ((SpoutParallelTaskManager)engine.getParallelTaskManager()).heartbeat(delta);
  List<AsyncExecutor> executors=asyncExecutors.get();
  int stage=0;
  boolean allStagesComplete=false;
  boolean joined=false;
  TickStage.setStage(TickStage.STAGE1);
  while (!allStagesComplete) {
    if (stage == 0) {
      TickStage.setStage(TickStage.STAGE1);
    }
 else {
      TickStage.setStage(TickStage.STAGE2P);
    }
    allStagesComplete=true;
    for (    AsyncExecutor e : executors) {
      if (stage < e.getManager().getStages()) {
        allStagesComplete=false;
        if (!e.startTick(stage,delta)) {
          return false;
        }
      }
 else {
        continue;
      }
    }
    joined=false;
    while (!joined) {
      try {
        AsyncExecutorUtils.pulseJoinAll(executors,(PULSE_EVERY << 4));
        joined=true;
      }
 catch (      TimeoutException e) {
        if (((SpoutEngine)Spout.getEngine()).isSetupComplete()) {
          engine.getLogger().info("String_Node_Str" + (PULSE_EVERY << 4) + "String_Node_Str");
          AsyncExecutorUtils.dumpAllStacks();
          AsyncExecutorUtils.checkForDeadlocks();
        }
      }
    }
    stage++;
  }
  copySnapshot(executors);
  return true;
}
Program: 177470
Project: 177470
Buggy source:
private void lockSnapshotLock(){
  int delay=500;
  int threshold=50;
  long startTime=System.currentTimeMillis();
  boolean success=false;
  while (!success) {
    success=snapshotLock.writeLock(delay);
    if (!success) {
      delay*=1.5;
      List<Plugin> violatingPlugins=snapshotLock.getLockingPlugins(threshold);
      server.getLogger().info("String_Node_Str" + (System.currentTimeMillis() - startTime) + "String_Node_Str");
      for (      Plugin p : violatingPlugins) {
        server.getLogFile().indexOf(p.getDescription().getName() + "String_Node_Str" + threshold+ "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
private void lockSnapshotLock(){
  int delay=500;
  int threshold=50;
  long startTime=System.currentTimeMillis();
  boolean success=false;
  while (!success) {
    success=snapshotLock.writeLock(delay);
    if (!success) {
      delay*=1.5;
      List<Plugin> violatingPlugins=snapshotLock.getLockingPlugins(threshold);
      engine.getLogger().info("String_Node_Str" + (System.currentTimeMillis() - startTime) + "String_Node_Str");
      for (      Plugin p : violatingPlugins) {
        engine.getLogFile().indexOf(p.getDescription().getName() + "String_Node_Str" + threshold+ "String_Node_Str");
      }
    }
  }
}
Program: 177472
Project: 177472
Buggy source:
/** 
 * Stops the scheduler and waits for all tasks to complete
 * @param timeout the time in ms, after the main thread completes, to wait for all the tasks to stop
 */
public void stop(long timeout){
  shutdown=true;
  try {
    mainThread.join(timeout);
    if (renderThread != null) {
      renderThread.join(timeout);
    }
  }
 catch (  InterruptedException e) {
    server.getLogger().info("String_Node_Str");
  }
  if (timeout > 0) {
    taskManager.shutdown(timeout);
  }
 else {
    taskManager.shutdown(1L);
  }
}

Fixed version (ground truth):
/** 
 * Stops the scheduler and waits for all tasks to complete
 * @param timeout the time in ms, after the main thread completes, to wait for all the tasks to stop
 */
public void stop(long timeout){
  shutdown=true;
  try {
    mainThread.join(timeout);
    if (renderThread != null) {
      renderThread.join(timeout);
    }
  }
 catch (  InterruptedException e) {
    engine.getLogger().info("String_Node_Str");
  }
  if (timeout > 0) {
    taskManager.shutdown(timeout);
  }
 else {
    taskManager.shutdown(1L);
  }
}
Program: 177473
Project: 177473
Buggy source:
/** 
 * Deallocates the id for an entity.
 * @param entity The entity.
 */
public void deallocate(SpoutEntity entity){
  EntityDespawnEvent event=new EntityDespawnEvent(entity);
  Spout.getEngine().getEventManager().callEvent(event);
  if (event.isCancelled()) {
    return;
  }
  entities.remove(entity.getId());
  Controller controller=entity.getController();
  if (controller != null) {
    getRawAll(entity.getController().getClass()).remove(entity);
  }
}

Fixed version (ground truth):
/** 
 * Deallocates the id for an entity.
 * @param entity The entity.
 */
public void deallocate(SpoutEntity entity){
  entities.remove(entity.getId());
  Controller controller=entity.getController();
  if (controller != null) {
    getRawAll(entity.getController().getClass()).remove(entity);
  }
}
Program: 177474
Project: 177474
Buggy source:
@Override public void onTick(float dt){
  if (this.transform != null && this.transform.getPosition() != null && this.transform.getPosition().getWorld() != null && this.transform.getRotation() != null && this.transform.getScale() != null) {
    if (lastTransform != this.transform) {
      chunkLive.set(transform.getPosition().getWorld().getChunkFromBlock(transform.getPosition()));
      entityManagerLive.set(((SpoutRegion)chunkLive.get().getRegion()).getEntityManager());
    }
    lastTransform=transform.copy();
  }
  if (controllerLive.get() != null && controllerLive.get().getParent() != null) {
    controllerLive.get().onTick(dt);
  }
  if (controllerLive.get() instanceof PlayerController) {
    Player player=((PlayerController)controllerLive.get()).getPlayer();
    if (player != null && player.getSession() != null) {
      ((SpoutSession)player.getSession()).pulse();
    }
  }
}

Fixed version (ground truth):
@Override public void onTick(float dt){
  if (this.transform.getPosition() != null && this.transform.getPosition().getWorld() != null) {
    chunkLive.set(transform.getPosition().getWorld().getChunkFromBlock(transform.getPosition()));
    entityManagerLive.set(((SpoutRegion)chunkLive.get().getRegion()).getEntityManager());
    lastTransform=transform.copy();
  }
  if (controllerLive.get() != null && controllerLive.get().getParent() != null) {
    controllerLive.get().onTick(dt);
  }
  if (controllerLive.get() instanceof PlayerController) {
    Player player=((PlayerController)controllerLive.get()).getPlayer();
    if (player != null && player.getSession() != null) {
      ((SpoutSession)player.getSession()).pulse();
    }
  }
}
Program: 177476
Project: 177476
Buggy source:
@Override public boolean isDead(){
  return id.get() != NOTSPAWNEDID && (transform == null || chunkLive.get() == null || entityManagerLive.get() == null);
}

Fixed version (ground truth):
@Override public boolean isDead(){
  return id.get() != NOTSPAWNEDID && (chunkLive.get() == null || entityManagerLive.get() == null);
}
Program: 177477
Project: 177477
Buggy source:
public void setOwningThread(Thread thread){
  this.owningThread=thread;
}

Fixed version (ground truth):
public void setOwningThread(Thread thread){
  if (getController() instanceof PlayerController)   System.out.println("String_Node_Str" + owningThread + "String_Node_Str"+ thread+ "String_Node_Str");
  this.owningThread=thread;
}
Program: 177479
Project: 177479
Buggy source:
@Override public boolean kill(){
  if (transform == null || transform.getPosition() == null || chunkLive.get() == null || entityManagerLive.get() == null) {
    return false;
  }
  transform.set(null);
  chunkLive.set(null);
  entityManagerLive.set(null);
  return true;
}

Fixed version (ground truth):
@Override public boolean kill(){
  chunkLive.set(null);
  entityManagerLive.set(null);
  return true;
}
Program: 177481
Project: 177481
Buggy source:
private static CompoundMap saveEntities(SpoutChunk c){
  Set<Entity> entities=c.getLiveEntities();
  CompoundMap tagMap=new CompoundMap();
  for (  Entity e : entities) {
    tagMap.put(saveEntity((SpoutEntity)e));
    e.kill();
  }
  return tagMap;
}

Fixed version (ground truth):
private static CompoundMap saveEntities(SpoutChunk c){
  Set<Entity> entities=c.getLiveEntities();
  CompoundMap tagMap=new CompoundMap();
  for (  Entity e : entities) {
    Tag tag=saveEntity((SpoutEntity)e);
    if (tag != null) {
      tagMap.put(tag);
    }
  }
  return tagMap;
}
Program: 177483
Project: 177483
Buggy source:
public void addEntity(Entity e){
  Controller controller=e.getController();
  if (controller instanceof BlockController) {
    Point pos=e.getPosition();
    setBlockController(pos.getBlockX(),pos.getBlockY(),pos.getBlockZ(),(BlockController)controller);
  }
  if (spawnQueue.contains(e)) {
    return;
  }
  if (removeQueue.contains(e)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  spawnQueue.add(e);
}

Fixed version (ground truth):
public void addEntity(Entity e){
  Controller controller=e.getController();
  if (controller instanceof BlockController) {
    Point pos=e.getPosition();
    setBlockController(pos.getBlockX(),pos.getBlockY(),pos.getBlockZ(),(BlockController)controller);
  }
  this.allocate((SpoutEntity)e);
}
Program: 177484
Project: 177484
Buggy source:
/** 
 * Removes a chunk from the region and indicates if the region is empty
 * @param c the chunk to remove
 * @return true if the region is now empty
 */
public boolean removeChunk(Chunk c){
  if (c.getRegion() != this) {
    return false;
  }
  int cx=c.getX() & Region.REGION_SIZE - 1;
  int cy=c.getY() & Region.REGION_SIZE - 1;
  int cz=c.getZ() & Region.REGION_SIZE - 1;
  AtomicReference<SpoutChunk> current=chunks[cx][cy][cz];
  SpoutChunk currentChunk=current.get();
  if (currentChunk != c) {
    return false;
  }
  boolean success=current.compareAndSet(currentChunk,null);
  if (success) {
    int num=numberActiveChunks.decrementAndGet();
    ((SpoutChunk)currentChunk).setUnloaded();
    if (num == 0) {
      return true;
    }
 else     if (num < 0) {
      throw new IllegalStateException("String_Node_Str");
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Removes a chunk from the region and indicates if the region is empty
 * @param c the chunk to remove
 * @return true if the region is now empty
 */
public boolean removeChunk(Chunk c){
  if (c.getRegion() != this) {
    return false;
  }
  int cx=c.getX() & Region.REGION_SIZE - 1;
  int cy=c.getY() & Region.REGION_SIZE - 1;
  int cz=c.getZ() & Region.REGION_SIZE - 1;
  AtomicReference<SpoutChunk> current=chunks[cx][cy][cz];
  SpoutChunk currentChunk=current.get();
  if (currentChunk != c) {
    return false;
  }
  boolean success=current.compareAndSet(currentChunk,null);
  if (success) {
    int num=numberActiveChunks.decrementAndGet();
    for (    Entity e : currentChunk.getLiveEntities()) {
      e.kill();
    }
    ((SpoutChunk)currentChunk).setUnloaded();
    if (num == 0) {
      return true;
    }
 else     if (num < 0) {
      throw new IllegalStateException("String_Node_Str");
    }
  }
  return false;
}
Program: 177486
Project: 177486
Buggy source:
public void removeEntity(Entity e){
  Vector3 pos=e.getPosition().floor();
  if (blockControllers.containsKey(pos)) {
    blockControllers.remove(pos);
  }
  if (removeQueue.contains(e)) {
    return;
  }
  if (spawnQueue.contains(e)) {
    spawnQueue.remove(e);
    return;
  }
  removeQueue.add(e);
}

Fixed version (ground truth):
public void removeEntity(Entity e){
  Vector3 pos=e.getPosition().floor();
  if (blockControllers.containsKey(pos)) {
    blockControllers.remove(pos);
  }
  this.deallocate((SpoutEntity)e);
}
Program: 177487
Project: 177487
Buggy source:
@Override public int scheduleAsyncDelayedTask(Object plugin,Runnable task){
  return scheduleAsyncRepeatingTask(plugin,task,0,-1);
}

Fixed version (ground truth):
@Override public int scheduleAsyncDelayedTask(Object plugin,Runnable task){
  return scheduleAsyncRepeatingTaskInternal(plugin,task,0,-1);
}
Program: 177488
Project: 177488
Buggy source:
@Override public int scheduleAsyncRepeatingTask(Object plugin,Runnable task,long delay,long period){
  return schedule(new SpoutTask(plugin,task,false,delay,period));
}

Fixed version (ground truth):
@Override public int scheduleAsyncRepeatingTask(Object plugin,Runnable task,long delay,long period){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 177489
Project: 177489
Buggy source:
@Override public DataInputStream getInputStream(int i) throws IOException {
  if (i < 0 || i > entries) {
    throw new SRFException("String_Node_Str");
  }
  refreshAccess();
  Lock lock=blockLock[i].readLock();
  lock.lock();
  if (this.isClosed()) {
    throw new SRFClosedException("String_Node_Str");
  }
  try {
    int start=blockSegmentStart[i].get() << segmentSize;
    int actualLength=blockActualLength[i].get();
    byte[] result=new byte[actualLength];
synchronized (file) {
      file.seek(start);
      file.readFully(result);
    }
    return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(result)));
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
@Override public DataInputStream getInputStream(int i) throws IOException {
  if (i < 0 || i > entries) {
    throw new SRFException("String_Node_Str");
  }
  refreshAccess();
  Lock lock=blockLock[i].readLock();
  lock.lock();
  try {
    if (this.isClosed()) {
      throw new SRFClosedException("String_Node_Str");
    }
    if (blockActualLength[i].get() == 0) {
      return null;
    }
    int start=blockSegmentStart[i].get() << segmentSize;
    int actualLength=blockActualLength[i].get();
    byte[] result=new byte[actualLength];
synchronized (file) {
      file.seek(start);
      file.readFully(result);
    }
    return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(result)));
  }
  finally {
    lock.unlock();
  }
}
Program: 177490
Project: 177490
Buggy source:
public void writeInt(int i) throws IOException {
  writeCacheByte((byte)(i >> 24));
  writeCacheByte((byte)(i >> 16));
  writeCacheByte((byte)(i >> 8));
  writeCacheByte((byte)(i >> 0));
}

Fixed version (ground truth):
public void writeInt(int i) throws IOException {
  timeStart();
  try {
    writeCacheByte((byte)(i >> 24));
    writeCacheByte((byte)(i >> 16));
    writeCacheByte((byte)(i >> 8));
    writeCacheByte((byte)(i >> 0));
  }
  finally {
    timeEnd();
  }
}
Program: 177491
Project: 177491
Buggy source:
public CachedRandomAccessFile(File filePath,String permissions) throws FileNotFoundException {
  this.file=new RandomAccessFile(filePath,permissions);
}

Fixed version (ground truth):
public CachedRandomAccessFile(File filePath,String permissions,int pageShift) throws FileNotFoundException {
  this.file=new RandomAccessFile(filePath,permissions);
  this.PAGE_SHIFT=pageShift;
  PAGE_SIZE=(1 << PAGE_SHIFT);
  PAGE_MASK=PAGE_SIZE - 1;
}
Program: 177492
Project: 177492
Buggy source:
private byte[] getPage(int pageIndex) throws IOException {
  while (pageIndex >= pages.size()) {
    pages.add(null);
  }
  byte[] page=pages.get(pageIndex);
  if (page == null) {
    long oldPos=pos;
    long pagePosition=pageIndex << PAGE_SHIFT;
    file.seek(pagePosition);
    page=new byte[PAGE_SIZE];
    long len=Math.min(file.length() - pos,page.length);
    if (len > 0) {
      file.readFully(page,0,(int)len);
    }
    pages.set(pageIndex,page);
    pos=oldPos;
  }
  return page;
}

Fixed version (ground truth):
private byte[] getPage(int pageIndex) throws IOException {
  while (pageIndex >= pages.size()) {
    pages.add(null);
  }
  byte[] page=pages.get(pageIndex);
  if (page == null) {
    long oldPos=pos;
    long pagePosition=pageIndex << PAGE_SHIFT;
    file.seek(pagePosition);
    page=new byte[PAGE_SIZE];
    long len=Math.min(file.length() - pagePosition,page.length);
    if (len > 0) {
      file.readFully(page,0,(int)len);
    }
    pages.set(pageIndex,page);
    pos=oldPos;
    posDirty=true;
  }
  return page;
}
Program: 177493
Project: 177493
Buggy source:
public void readFully(byte[] b) throws IOException {
  int pageIndex=(int)(pos >> PAGE_SHIFT);
  int offset=(int)(pos & PAGE_MASK);
  int endPageOne=Math.min(b.length + offset,PAGE_SIZE);
  byte[] page=getPage(pageIndex);
  int j=0;
  for (int i=offset; i < endPageOne; i++) {
    b[j++]=page[i];
  }
  while (b.length > j) {
    pageIndex++;
    page=getPage(pageIndex);
    if (b.length - j > PAGE_SIZE) {
      for (int i=0; i < PAGE_SIZE; i++) {
        b[j++]=page[i];
      }
    }
 else {
      for (int i=0; j < b.length; i++) {
        b[j++]=page[i];
      }
    }
  }
  pos+=b.length;
}

Fixed version (ground truth):
public void readFully(byte[] b) throws IOException {
  timeStart();
  try {
    int pageIndex=(int)(pos >> PAGE_SHIFT);
    int offset=(int)(pos & PAGE_MASK);
    int endPageOne=Math.min(b.length + offset,PAGE_SIZE);
    byte[] page=getPage(pageIndex);
    int j=0;
    for (int i=offset; i < endPageOne; i++) {
      b[j++]=page[i];
    }
    while (b.length > j) {
      pageIndex++;
      page=getPage(pageIndex);
      if (b.length - j > PAGE_SIZE) {
        for (int i=0; i < PAGE_SIZE; i++) {
          b[j++]=page[i];
        }
      }
 else {
        for (int i=0; j < b.length; i++) {
          b[j++]=page[i];
        }
      }
    }
    pos+=b.length;
    posDirty=true;
  }
  finally {
    timeEnd();
  }
}
Program: 177494
Project: 177494
Buggy source:
public byte readCacheByte() throws IOException {
  int pageIndex=(int)(pos >> PAGE_SHIFT);
  int offset=(int)(pos & PAGE_MASK);
  byte[] page=getPage(pageIndex);
  pos++;
  return page[offset];
}

Fixed version (ground truth):
private byte readCacheByte() throws IOException {
  int pageIndex=(int)(pos >> PAGE_SHIFT);
  int offset=(int)(pos & PAGE_MASK);
  byte[] page=getPage(pageIndex);
  pos++;
  posDirty=true;
  return page[offset];
}
Program: 177495
Project: 177495
Buggy source:
public long length() throws IOException {
  return file.length();
}

Fixed version (ground truth):
public long length() throws IOException {
  timeStart();
  try {
    return file.length();
  }
  finally {
    timeEnd();
  }
}