nus-yam/ex-repair huggingface dataset:
Program: 162922
Project: 162922
Buggy source:
/** 
 * {@inheritDoc}<p>Example: if keys in your set(s) are English words in   {@link String} form, average Englishword length is 5.1, configure average key size of 6: <pre> {@code ChronicleSet<String> uniqueWords = ChronicleSetBuilder.of(String.class) .entries(50000) .averageKeySize(6) .create();}</pre> <p>(Note that 6 is chosen as average key size in bytes despite strings in Java are UTF-16 encoded (and each character takes 2 bytes on-heap), because default off-heap   {@link String}encoding is UTF-8 in   {@code ChronicleSet}.)
 * @see #constantKeySizeBySample(Object)
 * @see #actualChunkSize(int)
 * @param averageKeySize
 */
@Override public ChronicleSetBuilder<K> averageKeySize(double averageKeySize){
  chronicleMapBuilder.averageKeySize(averageKeySize);
  return this;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}<p>Example: if keys in your set(s) are English words in   {@link String} form, average Englishword length is 5.1, configure average key size of 6: <pre> {@code ChronicleSet<String> uniqueWords = ChronicleSetBuilder.of(String.class) .entries(50000) .averageKeySize(6) .create();}</pre> <p>(Note that 6 is chosen as average key size in bytes despite strings in Java are UTF-16 encoded (and each character takes 2 bytes on-heap), because default off-heap   {@link String}encoding is UTF-8 in   {@code ChronicleSet}.)
 * @see #constantKeySizeBySample(Object)
 * @see #actualChunkSize(int)
 * @param averageKeySize   the average size in bytes of the key
 */
@Override public ChronicleSetBuilder<K> averageKeySize(double averageKeySize){
  chronicleMapBuilder.averageKeySize(averageKeySize);
  return this;
}
Program: 162923
Project: 162923
Buggy source:
default int mapHashCode(){
  int[] h=new int[1];
  forEach((k,v) -> h[0]+=k.hashCode() ^ v.hashCode());
  return h[0];
}

Fixed version (ground truth):
default int mapHashCode(){
  int[] h=new int[1];
  forEach((k,v) -> h[0]+=hashCode(k) ^ hashCode(v));
  return h[0];
}
Program: 162924
Project: 162924
Buggy source:
default boolean mapEquals(Object o){
  if (o == this)   return true;
  if (!(o instanceof Map))   return false;
  Map<?,?> m=(Map<?,?>)o;
  if ((m instanceof ChronicleMap ? ((ChronicleMap)m).longSize() : m.size()) != longSize())   return false;
  try {
    return forEachEntryWhile(c -> c.get().equals(m.get(c.key())));
  }
 catch (  ClassCastException unused) {
    return false;
  }
catch (  NullPointerException unused) {
    return false;
  }
}

Fixed version (ground truth):
default boolean mapEquals(Object o){
  if (o == this)   return true;
  if (!(o instanceof Map))   return false;
  Map<?,?> m=(Map<?,?>)o;
  if ((m instanceof ChronicleMap ? ((ChronicleMap)m).longSize() : m.size()) != longSize())   return false;
  try {
    return forEachEntryWhile(c -> {
      K k=c.key();
      V v=(V)m.get(k instanceof CharSequence ? k.toString() : k);
      return v != null && c.valueEqualTo(v);
    }
);
  }
 catch (  ClassCastException unused) {
    return false;
  }
catch (  NullPointerException unused) {
    return false;
  }
}
Program: 162926
Project: 162926
Buggy source:
public ClientWiredStatelessChronicleMap(@NotNull final ClientWiredChronicleMapStatelessClientBuilder config,@NotNull final Class kClass,@NotNull final Class vClass,short channelID){
  this.channelID=channelID;
  hub=config.hub;
  this.putReturnsNull=config.putReturnsNull();
  this.removeReturnsNull=config.removeReturnsNull();
  this.kClass=kClass;
  this.vClass=vClass;
}

Fixed version (ground truth):
public ClientWiredStatelessChronicleMap(@NotNull final ClientWiredChronicleMapStatelessBuilder config,@NotNull final Class kClass,@NotNull final Class vClass,short channelID){
  this.channelID=channelID;
  hub=config.hub;
  this.putReturnsNull=config.putReturnsNull();
  this.removeReturnsNull=config.removeReturnsNull();
  this.kClass=kClass;
  this.vClass=vClass;
}
Program: 162927
Project: 162927
Buggy source:
private void writeChunked(long transactionId,@NotNull final Function<Map,Iterator<byte[]>> function,@NotNull final Consumer<Iterator<byte[]>> c){
  final BytesChronicleMap m=bytesMap(channelId);
  final Iterator<byte[]> iterator=function.apply(m);
  out=() -> {
    outWire.write(TRANSACTION_ID).int64(transactionId);
    write(map -> {
      boolean hasNext=iterator.hasNext();
      outWire.write(HAS_NEXT).bool(hasNext);
      if (hasNext)       c.accept(iterator);
 else       out=null;
    }
);
  }
;
  out.run();
}

Fixed version (ground truth):
private void writeChunked(long transactionId,@NotNull final Function<BytesChronicleMap,Iterator> function,@NotNull final Consumer<Iterator<byte[]>> c){
  final BytesChronicleMap m=bytesMap(channelId);
  final Iterator<byte[]> iterator=function.apply(m);
  out=() -> {
    outWire.write(TRANSACTION_ID).int64(transactionId);
    write(map -> {
      boolean hasNext=iterator.hasNext();
      outWire.write(HAS_NEXT).bool(hasNext);
      if (hasNext)       c.accept(iterator);
 else       out=null;
    }
);
  }
;
  out.run();
}
Program: 162929
Project: 162929
Buggy source:
void initRemoveDependencies(){
  initSegment();
  initLocks();
  checkUpdateLocked();
}

Fixed version (ground truth):
void initRemoveDependencies(){
  initSegment();
  initLocks();
  updateLockIfNeeded();
}
Program: 162931
Project: 162931
Buggy source:
void initPutDependencies(){
  initLocks();
  checkUpdateLocked();
  initKeySearch();
  initValueModel();
  initKeyModel();
}

Fixed version (ground truth):
void initPutDependencies(){
  initLocks();
  updateLockIfNeeded();
  initKeySearch();
  initValueModel();
  initKeyModel();
}
Program: 162932
Project: 162932
Buggy source:
@Override public boolean remove(long hash,long pos){
  c.pos=pos;
  c.initKeyFromPos();
  try {
    if (!c.containsKey())     return false;
    shouldBreak=predicate.test(c);
    while (c.writeLockCount > 0) {
      c.writeLock().unlock();
    }
    if (!c.isUpdateLocked()) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return c.state == DELETED && !(c instanceof ReplicatedContext);
  }
  finally {
    c.closeKeySearch();
  }
}

Fixed version (ground truth):
@Override public boolean remove(long hash,long pos){
  c.pos=pos;
  c.initKeyFromPos();
  try {
    if (!c.containsKey())     return false;
    shouldBreak=!predicate.test(c);
    c.closeKey0();
    while (c.writeLockCount > 0) {
      c.writeLock().unlock();
    }
    if (!c.isUpdateLocked()) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return c.state == DELETED && !(c instanceof ReplicatedContext);
  }
  finally {
    c.closeKeySearch();
  }
}
Program: 162933
Project: 162933
Buggy source:
private void fillEntryBuffer(){
  if (!entryBuffer.isEmpty())   return;
  while (true) {
    if (segmentIndex < 0)     return;
    try (VanillaContext<K,?,?,V,?,?> c=mapContext()){
      context=c;
      c.segmentIndex=segmentIndex;
      segmentIndex--;
      if (c.size() == 0)       continue;
      c.updateLock().lock();
      c.initSegment();
      c.hashLookup.forEach(this);
    }
  finally {
      context=null;
    }
  }
}

Fixed version (ground truth):
private void fillEntryBuffer(){
  if (!entryBuffer.isEmpty())   return;
  while (true) {
    if (segmentIndex < 0)     return;
    try (VanillaContext<K,?,?,V,?,?> c=mapContext()){
      context=c;
      c.segmentIndex=segmentIndex;
      segmentIndex--;
      if (c.size() == 0)       continue;
      c.updateLock().lock();
      c.initSegment();
      c.hashLookup.forEach(this);
      return;
    }
  finally {
      context=null;
    }
  }
}
Program: 162934
Project: 162934
Buggy source:
@Nullable private Work replaceWithOldAndNew(Bytes reader,@NotNull TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation,long timestamp,byte id){
  try {
    writer.ensureBufferSize(1L);
    bytesMap.replace(reader,reader,reader);
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}

Fixed version (ground truth):
@Nullable private Work replaceWithOldAndNew(Bytes reader,@NotNull TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation,long timestamp,byte id){
  try {
    writer.ensureBufferSize(1L);
    writer.in().writeBoolean(bytesMap.replace(reader,reader,reader));
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}
Program: 162935
Project: 162935
Buggy source:
@Nullable private Work containsKey(Bytes reader,@NotNull TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation){
  try {
    writer.in().writeBoolean(map.containsKey(reader));
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}

Fixed version (ground truth):
@Nullable private Work containsKey(Bytes reader,@NotNull TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation){
  try {
    writer.in().writeBoolean(bytesMap.containsKey(reader));
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}
Program: 162936
Project: 162936
Buggy source:
@Nullable private Work get(Bytes reader,TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation,long transactionId){
  bytesMap.output=writer;
  try {
    map.get(reader);
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
 finally {
    bytesMap.output=null;
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}

Fixed version (ground truth):
@Nullable private Work get(Bytes reader,TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation,long transactionId){
  bytesMap.output=writer;
  try {
    bytesMap.get(reader);
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
 finally {
    bytesMap.output=null;
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}
Program: 162937
Project: 162937
Buggy source:
@Test(timeout=25000) public void persistedTest(){
  final File db=Paths.get(System.getProperty("String_Node_Str"),"String_Node_Str").toFile();
  try {
    test(new Function<ChronicleMapBuilder<Integer,Integer>,ChronicleMap<Integer,Integer>>(){
      @Override public ChronicleMap<Integer,Integer> apply(      ChronicleMapBuilder<Integer,Integer> builder){
        try {
          return builder.createPersistedTo(db);
        }
 catch (        IOException e) {
          throw new AssertionError(e);
        }
      }
    }
);
    System.out.println(MemoryUnit.BYTES.toMegabytes(db.length()) + "String_Node_Str");
    assertTrue("String_Node_Str",db.length() < MemoryUnit.MEGABYTES.toBytes(400));
  }
  finally {
    db.delete();
  }
}

Fixed version (ground truth):
@Test(timeout=25000) public void persistedTest(){
  final File db=Paths.get(System.getProperty("String_Node_Str"),"String_Node_Str").toFile();
  if (db.exists())   db.delete();
  try {
    test(new Function<ChronicleMapBuilder<Integer,Integer>,ChronicleMap<Integer,Integer>>(){
      @Override public ChronicleMap<Integer,Integer> apply(      ChronicleMapBuilder<Integer,Integer> builder){
        try {
          return builder.createPersistedTo(db);
        }
 catch (        IOException e) {
          throw new AssertionError(e);
        }
      }
    }
);
    System.out.println(MemoryUnit.BYTES.toMegabytes(db.length()) + "String_Node_Str");
    assertTrue("String_Node_Str",db.length() < MemoryUnit.MEGABYTES.toBytes(400));
  }
  finally {
    db.delete();
  }
}
Program: 162938
Project: 162938
Buggy source:
public <T extends ChronicleHash>T create(MapInstanceBuilder<CharSequence,CharSequence> config) throws IOException, TimeoutException, InterruptedException {
  int withChannelId=nextFreeChannel.incrementAndGet();
  try (MapKeyContext<MapInstanceBuilder> c=map.context(config.name)){
    MapInstanceBuilder value=config.replicatedViaChannel(replicationHub.createChannel(withChannelId));
    boolean added=!c.containsKey();
    c.put(value);
    if (added) {
      LOG.info("String_Node_Str" + value.name + "String_Node_Str"+ value.channel.channelId());
      try {
        toReplicatedViaChannel(value.mapBuilder,value.channel.channelId()).create();
      }
 catch (      IllegalStateException e) {
        LOG.debug("String_Node_Str" + value.name + "String_Node_Str"+ value.channel.channelId(),e);
      }
catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
   return (T)get(config.name).mapBuilder.create();
}

Fixed version (ground truth):
public <T extends ChronicleHash>T create(MapInstanceBuilder<CharSequence,CharSequence> config) throws IOException, TimeoutException, InterruptedException {
  int withChannelId=nextFreeChannel.incrementAndGet();
  try (MapKeyContext<MapInstanceBuilder> c=map.context(config.name)){
    c.updateLock().lock();
    MapInstanceBuilder value=config.replicatedViaChannel(replicationHub.createChannel(withChannelId));
    boolean added=!c.containsKey();
    c.put(value);
    if (added) {
      LOG.info("String_Node_Str" + value.name + "String_Node_Str"+ value.channel.channelId());
      try {
        toReplicatedViaChannel(value.mapBuilder,value.channel.channelId()).create();
      }
 catch (      IllegalStateException e) {
        LOG.debug("String_Node_Str" + value.name + "String_Node_Str"+ value.channel.channelId(),e);
      }
catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
   return (T)get(config.name).mapBuilder.create();
}
Program: 162939
Project: 162939
Buggy source:
@Override public void accept(long key,long pos){
  context.pos=pos;
  context.initKeyFromPos();
  if (!context.containsKey())   return;
  entryBuffer.add(new WriteThroughEntry(context.immutableKey(),context.getUsing(null)));
}

Fixed version (ground truth):
@Override public void accept(long hash,long pos){
  context.pos=pos;
  context.initKeyFromPos();
  try {
    if (!context.containsKey())     return;
    K key=context.immutableKey();
    V value=context.getUsing(null);
    entryBuffer.add(new WriteThroughEntry(key,value));
  }
  finally {
    context.closeKeySearch();
  }
}
Program: 162940
Project: 162940
Buggy source:
final void reuse(long pos){
  reuse(entry,pos);
}

Fixed version (ground truth):
final void reuse(long pos){
  entry=reuse(entryCache,pos);
}
Program: 162941
Project: 162941
Buggy source:
void closeLocks0(){
  if (rootContextOnThisSegment == this) {
    if (totalWriteLockCount > 0) {
      segmentHeader.writeUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
 else     if (totalUpdateLockCount > 0) {
      segmentHeader.updateUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
 else     if (totalReadLockCount > 0) {
      segmentHeader.readUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
  }
 else {
    if (writeLockCount > 0 && rootContextOnThisSegment.totalReadLockCount == writeLockCount) {
      if (shouldUpdateUnlock()) {
        if (shouldReadUnlock()) {
          segmentHeader.writeUnlock(segmentHeaderAddress);
          closeKeySearch();
        }
 else {
          segmentHeader.downgradeWriteToReadLock(segmentHeaderAddress);
        }
      }
 else {
        segmentHeader.downgradeWriteToUpdateLock(segmentHeaderAddress);
      }
    }
 else     if (shouldUpdateUnlock()) {
      if (shouldReadUnlock()) {
        segmentHeader.updateUnlock(segmentHeaderAddress);
        closeKeySearch();
      }
 else {
        segmentHeader.downgradeUpdateToReadLock(segmentHeaderAddress);
      }
    }
 else     if (shouldReadUnlock()) {
      segmentHeader.readUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
    rootContextOnThisSegment.totalReadLockCount-=readLockCount;
    rootContextOnThisSegment.totalUpdateLockCount-=updateLockCount;
    rootContextOnThisSegment.totalWriteLockCount-=writeLockCount;
  }
  rootContextOnThisSegment=null;
}

Fixed version (ground truth):
void closeLocks0(){
  if (rootContextOnThisSegment == this) {
    if (totalWriteLockCount > 0) {
      segmentHeader.writeUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
 else     if (totalUpdateLockCount > 0) {
      segmentHeader.updateUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
 else     if (totalReadLockCount > 0) {
      segmentHeader.readUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
  }
 else {
    if (writeLockCount > 0 && rootContextOnThisSegment.totalReadLockCount == writeLockCount) {
      if (shouldUpdateUnlock()) {
        if (shouldReadUnlock()) {
          segmentHeader.writeUnlock(segmentHeaderAddress);
          closeKeySearch();
        }
 else {
          segmentHeader.downgradeWriteToReadLock(segmentHeaderAddress);
        }
      }
 else {
        segmentHeader.downgradeWriteToUpdateLock(segmentHeaderAddress);
      }
    }
 else     if (shouldUpdateUnlock()) {
      if (shouldReadUnlock()) {
        segmentHeader.updateUnlock(segmentHeaderAddress);
        closeKeySearch();
      }
 else {
        segmentHeader.downgradeUpdateToReadLock(segmentHeaderAddress);
      }
    }
 else     if (shouldReadUnlock()) {
      segmentHeader.readUnlock(segmentHeaderAddress);
      closeKeySearch();
    }
  }
  rootContextOnThisSegment.totalReadLockCount-=readLockCount;
  rootContextOnThisSegment.totalUpdateLockCount-=updateLockCount;
  rootContextOnThisSegment.totalWriteLockCount-=writeLockCount;
  readLockCount=updateLockCount=writeLockCount=0;
  rootContextOnThisSegment=null;
}
Program: 162942
Project: 162942
Buggy source:
void writeNewValueAndSwitch(){
  metaValueInterop.write(valueInterop,entry,newValue);
  value=newValue;
  closeNewValue0();
}

Fixed version (ground truth):
void writeNewValueAndSwitch(){
  entry.position(valueOffset);
  metaValueInterop.write(valueInterop,entry,newValue);
  value=newValue;
  closeNewValue0();
}
Program: 162943
Project: 162943
Buggy source:
void closeKeySearch0(){
  state=null;
  hashLookup.closeSearch0();
}

Fixed version (ground truth):
void closeKeySearch0(){
  state=null;
  pos=-1;
  entry=null;
  hashLookup.closeSearch0();
}
Program: 162945
Project: 162945
Buggy source:
@Override public void replacePrevPos(SearchState searchState,long newValue){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  long oldEntry=bytes.readInt48(prevPos);
  long oldValue=value(oldEntry);
  checkValueForRemove(oldValue);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeInt48(prevPos,entry(searchState.searchHash,newValue));
}

Fixed version (ground truth):
@Override public void replacePrevPos(SearchState searchState,long newValue,boolean oldValueInPositions){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  if (oldValueInPositions) {
    long oldEntry=bytes.readInt48(prevPos);
    long oldValue=value(oldEntry);
    checkValueForRemove(oldValue);
    positions.clear(oldValue);
  }
  positions.set(newValue);
  bytes.writeInt48(prevPos,entry(searchState.searchHash,newValue));
}
Program: 162946
Project: 162946
Buggy source:
@Override public void replacePrevPos(SearchState searchState,long newValue){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  long oldEntry=bytes.readLong(prevPos);
  long oldValue=value(oldEntry);
  checkValueForRemove(oldValue);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeLong(prevPos,entry(searchState.searchHash,newValue));
}

Fixed version (ground truth):
@Override public void replacePrevPos(SearchState searchState,long newValue,boolean oldValueInPositions){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  if (oldValueInPositions) {
    long oldEntry=bytes.readLong(prevPos);
    long oldValue=value(oldEntry);
    checkValueForRemove(oldValue);
    positions.clear(oldValue);
  }
  positions.set(newValue);
  bytes.writeLong(prevPos,entry(searchState.searchHash,newValue));
}
Program: 162947
Project: 162947
Buggy source:
void replacePrevPos(SearchState searchState,long newValue);

Fixed version (ground truth):
void replacePrevPos(SearchState searchState,long newValue,boolean oldValueInPositions);
Program: 162949
Project: 162949
Buggy source:
@Override boolean isDeleted(long pos){
  bytes.position(offsetFromPos(pos) + metaDataBytes);
  long keySize=keySizeMarshaller.readSize(bytes);
  return bytes.readBoolean(bytes.position() + keySize + ADDITIONAL_ENTRY_BYTES - 1L);
}

Fixed version (ground truth):
@Override boolean isDeleted(Bytes entry,long keySize){
  return entry.readBoolean(entry.position() + keySize + ADDITIONAL_ENTRY_BYTES - 1L);
}
Program: 162950
Project: 162950
Buggy source:
@Override public void replacePrevPos(SearchState searchState,long newValue){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  int oldEntry=bytes.readInt(prevPos);
  long oldValue=value(oldEntry);
  checkValueForRemove(oldValue);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeInt(prevPos,entry(searchState.searchHash,newValue));
}

Fixed version (ground truth):
@Override public void replacePrevPos(SearchState searchState,long newValue,boolean oldValueInPositions){
  checkValueForPut(newValue);
  long prevPos=searchState.searchPos;
  if (!searchState.putAfterFailedSearch)   prevPos=stepBack(prevPos);
  if (oldValueInPositions) {
    int oldEntry=bytes.readInt(prevPos);
    long oldValue=value(oldEntry);
    checkValueForRemove(oldValue);
    positions.clear(oldValue);
  }
  positions.set(newValue);
  bytes.writeInt(prevPos,entry(searchState.searchHash,newValue));
}
Program: 162951
Project: 162951
Buggy source:
@Override public Entry<K,V> next(){
  checkSingleThreaded();
  fillEntryBuffer();
  if ((returned=entryBuffer.poll()) == null)   throw new NoSuchElementException();
  return returned;
}

Fixed version (ground truth):
@Override public Entry<K,V> next(){
  checkSingleThreaded();
  fillEntryBuffer();
  Entry<K,V> e;
  if ((e=entryBuffer.poll()) == null)   throw new NoSuchElementException();
  return returned=e;
}
Program: 162953
Project: 162953
Buggy source:
ChronicleMap<K,V> createWithFile(File file,SingleChronicleHashReplication singleHashReplication,ReplicationChannel channel) throws IOException {
  pushingToMapEventListener();
  for (int i=0; i < 10; i++) {
    if (file.exists() && file.length() > 0) {
      try (FileInputStream fis=new FileInputStream(file);ObjectInputStream ois=new ObjectInputStream(fis)){
        XStream xStream=new XStream(new SunLimitedUnsafeReflectionProvider());
        VanillaChronicleMap<K,?,?,V,?,?> map=(VanillaChronicleMap<K,?,?,V,?,?>)xStream.fromXML(ois);
        map.headerSize=roundUpMapHeaderSize(fis.getChannel().position());
        map.createMappedStoreAndSegments(file);
        return establishReplication(map,singleHashReplication,channel);
      }
     }
    if (file.createNewFile() || file.length() == 0) {
      break;
    }
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      throw new IOException(e);
    }
  }
  if (!file.exists())   throw new FileNotFoundException("String_Node_Str" + file);
  VanillaChronicleMap<K,?,?,V,?,?> map=newMap(singleHashReplication,channel);
  try (FileOutputStream fos=new FileOutputStream(file);ObjectOutputStream oos=new ObjectOutputStream(fos)){
    XStream xStream=new XStream(new SunLimitedUnsafeReflectionProvider());
    xStream.toXML(map,oos);
    oos.flush();
    map.headerSize=roundUpMapHeaderSize(fos.getChannel().position());
    map.createMappedStoreAndSegments(file);
  }
   return establishReplication(map,singleHashReplication,channel);
}

Fixed version (ground truth):
ChronicleMap<K,V> createWithFile(File file,SingleChronicleHashReplication singleHashReplication,ReplicationChannel channel) throws IOException {
  pushingToMapEventListener();
  for (int i=0; i < 10; i++) {
    if (file.exists() && file.length() > 0) {
      try (FileInputStream fis=new FileInputStream(file);ObjectInputStream ois=new ObjectInputStream(fis)){
        XStream xStream=new XStream(new SunLimitedUnsafeReflectionProvider());
        VanillaChronicleMap<K,?,?,V,?,?> map=(VanillaChronicleMap<K,?,?,V,?,?>)xStream.fromXML(ois);
        map.headerSize=roundUpMapHeaderSize(fis.getChannel().position());
        map.createMappedStoreAndSegments(file);
        preMapConstruction(singleHashReplication != null || channel != null);
        return establishReplication(map,singleHashReplication,channel);
      }
     }
    if (file.createNewFile() || file.length() == 0) {
      break;
    }
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      throw new IOException(e);
    }
  }
  if (!file.exists())   throw new FileNotFoundException("String_Node_Str" + file);
  VanillaChronicleMap<K,?,?,V,?,?> map=newMap(singleHashReplication,channel);
  try (FileOutputStream fos=new FileOutputStream(file);ObjectOutputStream oos=new ObjectOutputStream(fos)){
    XStream xStream=new XStream(new SunLimitedUnsafeReflectionProvider());
    xStream.toXML(map,oos);
    oos.flush();
    map.headerSize=roundUpMapHeaderSize(fos.getChannel().position());
    map.createMappedStoreAndSegments(file);
  }
   return establishReplication(map,singleHashReplication,channel);
}
Program: 162955
Project: 162955
Buggy source:
StatelessServerConnector(@NotNull VanillaChronicleMap<K,?,?,V,?,?> map,@NotNull final BufferResizer bufferResizer,int tcpBufferSize,final SerializationBuilder<K> keySerializationBuilder,final SerializationBuilder<V> valueSerializationBuilder){
  this.tcpBufferSize=tcpBufferSize;
  keyReaderWithSize=new ReaderWithSize<>(keySerializationBuilder);
  keyWriterWithSize=new WriterWithSize<>(keySerializationBuilder,bufferResizer);
  valueReaderWithSize=new ReaderWithSize<>(valueSerializationBuilder);
  valueWriterWithSize=new WriterWithSize<>(valueSerializationBuilder,bufferResizer);
  this.map=map;
}

Fixed version (ground truth):
StatelessServerConnector(@NotNull VanillaChronicleMap<K,?,?,V,?,?> map,@NotNull final BufferResizer bufferResizer,int tcpBufferSize,final SerializationBuilder<K> keySerializationBuilder,final SerializationBuilder<V> valueSerializationBuilder){
  this.tcpBufferSize=tcpBufferSize;
  this.keySerializationBuilder=keySerializationBuilder;
  this.valueSerializationBuilder=valueSerializationBuilder;
  keyReaderWithSize=new ReaderWithSize<>(keySerializationBuilder);
  keyWriterWithSize=new WriterWithSize<>(keySerializationBuilder,bufferResizer);
  valueReaderWithSize=new ReaderWithSize<>(valueSerializationBuilder);
  valueWriterWithSize=new WriterWithSize<>(valueSerializationBuilder,bufferResizer);
  this.map=map;
}
Program: 162957
Project: 162957
Buggy source:
@Ignore("String_Node_Str") @Test public void testByteArrayKeySizeBySample() throws IOException {
  TcpTransportAndNetworkConfig serverConfig=TcpTransportAndNetworkConfig.of(8877).name("String_Node_Str");
  File mapFile=getPersistenceFile();
  for (int i=0; i < 2; i++) {
    try (ChronicleMap server=ChronicleMapBuilder.of(byte[].class,byte[][].class).replication((byte)1,serverConfig).constantKeySizeBySample(new byte[14]).createPersistedTo(mapFile)){
      try (ChronicleMap<byte[],byte[][]> map2=ChronicleMapBuilder.of(byte[].class,byte[][].class).constantKeySizeBySample(new byte[14]).statelessClient(new InetSocketAddress("String_Node_Str",8877)).create()){
        byte[] key=new byte[14];
        System.arraycopy("String_Node_Str".getBytes(),0,key,0,"String_Node_Str".length());
        byte[][] value={new byte[11],new byte[11]};
        System.arraycopy("String_Node_Str".getBytes(),0,value[0],0,"String_Node_Str".length());
        System.arraycopy("String_Node_Str".getBytes(),0,value[1],0,"String_Node_Str".length());
        map2.put(key,value);
        Assert.assertNotNull(map2.get(key));
      }
     }
   }
}

Fixed version (ground truth):
@Test public void testByteArrayKeySizeBySample() throws IOException {
  TcpTransportAndNetworkConfig serverConfig=TcpTransportAndNetworkConfig.of(8877).name("String_Node_Str");
  File mapFile=getPersistenceFile();
  for (int i=0; i < 2; i++) {
    try (ChronicleMap server=ChronicleMapBuilder.of(byte[].class,byte[][].class).replication((byte)1,serverConfig).constantKeySizeBySample(new byte[14]).createPersistedTo(mapFile)){
      try (ChronicleMap<byte[],byte[][]> map2=ChronicleMapBuilder.of(byte[].class,byte[][].class).constantKeySizeBySample(new byte[14]).statelessClient(new InetSocketAddress("String_Node_Str",8877)).create()){
        byte[] key=new byte[14];
        System.arraycopy("String_Node_Str".getBytes(),0,key,0,"String_Node_Str".length());
        byte[][] value={new byte[11],new byte[11]};
        System.arraycopy("String_Node_Str".getBytes(),0,value[0],0,"String_Node_Str".length());
        System.arraycopy("String_Node_Str".getBytes(),0,value[1],0,"String_Node_Str".length());
        map2.put(key,value);
        Assert.assertNotNull(map2.get(key));
      }
     }
   }
}
Program: 162959
Project: 162959
Buggy source:
/** 
 * Returns value size, writes the entry (key, value, sizes) to the entry, after this method call entry positioned after value bytes written (i. e. at the end of entry), sets entry position (in segment) and value size position in the given segmentState
 */
final <KB,KBI,MKBI extends MetaBytesInterop<KB,? super KBI>,E,EW>long putEntry(SegmentState segmentState,MKBI metaKeyInterop,KBI keyInterop,KB key,long keySize,MetaBytesWriter<E,? super EW> metaElemWriter,EW elemWriter,E elem,MultiStoreBytes entry,boolean writeDefaultInitialReplicationValues){
  long valueSize=metaElemWriter.size(elemWriter,elem);
  long entrySize=entrySize(keySize,valueSize);
  long pos=alloc(inChunks(entrySize));
  segmentState.pos=pos;
  long offset=offsetFromPos(pos);
  clearMetaData(offset);
  reuse(entry,offset);
  keySizeMarshaller.writeSize(entry,keySize);
  metaKeyInterop.write(keyInterop,entry,key);
  manageReplicationBytes(entry,writeDefaultInitialReplicationValues,false);
  segmentState.valueSizePos=entry.position();
  valueSizeMarshaller.writeSize(entry,valueSize);
  alignment.alignPositionAddr(entry);
  metaElemWriter.write(elemWriter,entry,elem);
  hashLookup.putAfterFailedSearch(segmentState.searchState,pos);
  incrementSize();
  return valueSize;
}

Fixed version (ground truth):
/** 
 * Returns value size, writes the entry (key, value, sizes) to the entry, after this method call entry positioned after value bytes written (i. e. at the end of entry), sets entry position (in segment) and value size position in the given segmentState
 */
final <KB,KBI,MKBI extends MetaBytesInterop<KB,? super KBI>,E,EW>long putEntry(SegmentState segmentState,MKBI metaKeyInterop,KBI keyInterop,KB key,long keySize,MetaBytesWriter<E,? super EW> metaElemWriter,EW elemWriter,E elem,MultiStoreBytes entry,boolean writeDefaultInitialReplicationValues){
  long valueSize=metaElemWriter.size(elemWriter,elem);
  long entrySize=entrySize(keySize,valueSize);
  int allocatedChunks=inChunks(entrySize);
  long pos=alloc(allocatedChunks);
  segmentState.pos=pos;
  long offset=offsetFromPos(pos);
  clearMetaData(offset);
  reuse(entry,offset);
  keySizeMarshaller.writeSize(entry,keySize);
  metaKeyInterop.write(keyInterop,entry,key);
  manageReplicationBytes(entry,writeDefaultInitialReplicationValues,false);
  segmentState.valueSizePos=entry.position();
  valueSizeMarshaller.writeSize(entry,valueSize);
  alignment.alignPositionAddr(entry);
  metaElemWriter.write(elemWriter,entry,elem);
  freeExtraAllocatedChunks(pos,allocatedChunks,entry);
  hashLookup.putAfterFailedSearch(segmentState.searchState,pos);
  incrementSize();
  return valueSize;
}
Program: 162963
Project: 162963
Buggy source:
@Override public void close(){
  if (putOnClose) {
    long pos=segmentState.pos;
    long offset=segment.offsetFromPos(pos);
    MultiStoreBytes entry=segment.reuse(segmentState.tmpBytes,offset);
    long keySize=map.keySizeMarshaller.readSize(entry);
    entry.skip(keySize);
    segment.manageReplicationBytes(entry,true,false);
    long valueSizePos=entry.position();
    long valueSize=map.readValueSize(entry);
    long entryEndAddr=entry.positionAddr() + valueSize;
    VI valueInterop=map.valueInteropProvider.get(copies,map.originalValueInterop);
    V value=value();
    MVI metaValueInterop=map.metaValueInteropProvider.get(copies,map.originalMetaValueInterop,valueInterop,value);
    long newValueSize=metaValueInterop.size(valueInterop,value);
    segment.putValue(pos,offset,entry,valueSizePos,entryEndAddr,segmentState,metaValueInterop,valueInterop,value,newValueSize,segment.hashLookup());
    map.onPut(segment,segmentState.pos);
  }
  putOnClose=true;
  segmentState.close();
  segment.writeUnlock();
}

Fixed version (ground truth):
@Override public void close(){
  if (putOnClose) {
    long pos=segmentState.pos;
    long offset=segment.offsetFromPos(pos);
    MultiStoreBytes entry=segment.reuse(segmentState.tmpBytes,offset);
    long keySize=map.keySizeMarshaller.readSize(entry);
    entry.skip(keySize);
    segment.manageReplicationBytes(entry,true,false);
    long valueSizePos=entry.position();
    long valueSize=map.valueSizeMarshaller.readSize(entry);
    long sizeOfEverythingBeforeValue=entry.position();
    map.alignment.alignPositionAddr(entry);
    long entryEndAddr=entry.positionAddr() + valueSize;
    VI valueInterop=map.valueInteropProvider.get(copies,map.originalValueInterop);
    V value=value();
    MVI metaValueInterop=map.metaValueInteropProvider.get(copies,map.originalMetaValueInterop,valueInterop,value);
    long newValueSize=metaValueInterop.size(valueInterop,value);
    segment.putValue(pos,offset,entry,valueSizePos,entryEndAddr,segmentState,metaValueInterop,valueInterop,value,newValueSize,segment.hashLookup(),sizeOfEverythingBeforeValue);
    map.onPut(segment,segmentState.pos);
  }
  putOnClose=true;
  segmentState.close();
  segment.writeUnlock();
}
Program: 162964
Project: 162964
Buggy source:
final long entrySize(long keySize,long valueSize){
  long sizeOfEverythingBeforeValue=sizeOfEverythingBeforeValue(keySize,valueSize);
  if (constantlySizedEntry) {
    return alignment.alignAddr(sizeOfEverythingBeforeValue + valueSize);
  }
 else   if (couldNotDetermineAlignmentBeforeAllocation) {
    return sizeOfEverythingBeforeValue + worstAlignment + valueSize;
  }
 else {
    return alignment.alignAddr(sizeOfEverythingBeforeValue) + valueSize;
  }
}

Fixed version (ground truth):
final long entrySize(long keySize,long valueSize){
  long sizeOfEverythingBeforeValue=sizeOfEverythingBeforeValue(keySize,valueSize);
  return innerEntrySize(sizeOfEverythingBeforeValue,valueSize);
}
Program: 162965
Project: 162965
Buggy source:
@Override public Object unmarshal(HierarchicalStreamReader reader,UnmarshallingContext context){
  reader.moveDown();
  if (!"String_Node_Str".equals(reader.getNodeName()))   throw new ConversionException("String_Node_Str" + reader.getNodeName());
  while (reader.hasMoreChildren()) {
    reader.moveDown();
    final String nodeName0=reader.getNodeName();
    if (!nodeName0.equals("String_Node_Str"))     throw new ConversionException("String_Node_Str" + nodeName0);
    final K k;
    final V v;
    reader.moveDown();
    k=deserialize(context,reader);
    reader.moveUp();
    reader.moveDown();
    v=deserialize(context,reader);
    reader.moveUp();
    if (k != null)     map.put(k,v);
    reader.moveUp();
  }
  reader.moveUp();
  return null;
}

Fixed version (ground truth):
@Override public Object unmarshal(HierarchicalStreamReader reader,UnmarshallingContext context){
  if ("String_Node_Str".equals(reader.getValue()))   return null;
  if (!"String_Node_Str".equals(reader.getNodeName()))   throw new ConversionException("String_Node_Str");
  reader.moveDown();
  while (reader.hasMoreChildren()) {
    reader.moveDown();
    final String nodeName0=reader.getNodeName();
    if (!nodeName0.equals("String_Node_Str"))     throw new ConversionException("String_Node_Str" + nodeName0);
    final K k;
    final V v;
    reader.moveDown();
    k=deserialize(context,reader);
    reader.moveUp();
    reader.moveDown();
    v=deserialize(context,reader);
    reader.moveUp();
    if (k != null)     map.put(k,v);
    reader.moveUp();
  }
  reader.moveUp();
  return null;
}
Program: 162967
Project: 162967
Buggy source:
<KB,KBI,MKBI extends MetaBytesInterop<KB,? super KBI>,RV>RV acquireWithoutLock(@NotNull ThreadLocalCopies copies,@NotNull SegmentState segmentState,MKBI metaKeyInterop,KBI keyInterop,KB key,long keySize,InstanceOrBytesToInstance<KB,K> toKey,ReadValue<RV> readValue,RV usingValue,InstanceOrBytesToInstance<RV,V> toValue,long hash2,boolean create,MutableLockedEntry lock){
  MultiStoreBytes entry=segmentState.tmpBytes;
  MultiMap hashLookup=this.hashLookup;
  SearchState searchState=segmentState.searchState;
  hashLookup.startSearch(hash2,searchState);
  for (long pos; (pos=hashLookup.nextPos(searchState)) >= 0L; ) {
    long offset=offsetFromPos(pos);
    reuse(entry,offset);
    if (!keyEquals(keyInterop,metaKeyInterop,key,keySize,entry))     continue;
    entry.skip(keySize);
    return readValueAndNotifyGet(copies,key,keySize,toKey,readValue,usingValue,toValue,entry);
  }
  if (!create)   return readValue.readNull();
  RV result=createEntryOnAcquire(copies,segmentState,metaKeyInterop,keyInterop,key,keySize,toKey,readValue,usingValue,toValue,entry);
  if (lock instanceof WriteLocked)   ((WriteLocked)lock).created(true);
  return result;
}

Fixed version (ground truth):
<KB,KBI,MKBI extends MetaBytesInterop<KB,? super KBI>,RV>RV acquireWithoutLock(@NotNull ThreadLocalCopies copies,@NotNull SegmentState segmentState,MKBI metaKeyInterop,KBI keyInterop,KB key,long keySize,InstanceOrBytesToInstance<KB,K> toKey,ReadValue<RV> readValue,RV usingValue,InstanceOrBytesToInstance<RV,V> toValue,long hash2,boolean create,MutableLockedEntry lock){
  MultiStoreBytes entry=segmentState.tmpBytes;
  MultiMap hashLookup=this.hashLookup;
  SearchState searchState=segmentState.searchState;
  hashLookup.startSearch(hash2,searchState);
  for (long pos; (pos=hashLookup.nextPos(searchState)) >= 0L; ) {
    long offset=offsetFromPos(pos);
    reuse(entry,offset);
    if (!keyEquals(keyInterop,metaKeyInterop,key,keySize,entry))     continue;
    entry.skip(keySize);
    segmentState.pos=pos;
    return readValueAndNotifyGet(copies,key,keySize,toKey,readValue,usingValue,toValue,entry);
  }
  if (!create)   return readValue.readNull();
  RV result=createEntryOnAcquire(copies,segmentState,metaKeyInterop,keyInterop,key,keySize,toKey,readValue,usingValue,toValue,entry);
  if (lock instanceof WriteLocked)   ((WriteLocked)lock).created(true);
  return result;
}
Program: 162968
Project: 162968
Buggy source:
@Before public void setup() throws IOException {
  int port=s_port;
  ChronicleMapBuilder<Integer,CharSequence> map1Builder=newTcpSocketShmBuilder(Integer.class,CharSequence.class,(byte)1,port,new InetSocketAddress("String_Node_Str",port + 1));
  map1=map1Builder.averageValueSize(10).create();
  map2=newTcpSocketShmIntString((byte)2,port + 1);
  s_port+=2;
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  int port=s_port;
  ChronicleMapBuilder<Integer,CharSequence> map1Builder=newTcpSocketShmBuilder(Integer.class,CharSequence.class,(byte)1,port,new InetSocketAddress("String_Node_Str",port + 1));
  map1=map1Builder.entries(Builder.SIZE).averageValueSize(10).create();
  ChronicleMapBuilder<Integer,CharSequence> map2Builder=newTcpSocketShmBuilder(Integer.class,CharSequence.class,(byte)2,port + 1);
  map2=map2Builder.entries(Builder.SIZE).averageValueSize(10).create();
  s_port+=2;
}
Program: 162969
Project: 162969
Buggy source:
@Ignore("String_Node_Str") @Test public void testSetValue() throws IOException {
  if (typeOfMap == TypeOfMap.STATELESS)   return;
  ChronicleMapBuilder<String,Set<String>> builder=ChronicleMapBuilder.of(String.class,(Class<Set<String>>)(Class)Set.class).valueMarshaller(SetMarshaller.of(new StringMarshaller(8)));
  try (ChronicleMap<String,Set<String>> map=newInstance(builder)){
    map.put("String_Node_Str",Collections.<String>emptySet());
    map.put("String_Node_Str",new LinkedHashSet<String>(asList("String_Node_Str")));
    Set<String> list1=new LinkedHashSet<>();
    try (WriteContext wc=map.acquireUsingLocked("String_Node_Str",list1)){
      list1.add("String_Node_Str");
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str")),list1);
    }
     Set<String> list2=new LinkedHashSet<>();
    try (ReadContext rc=map.getUsingLocked("String_Node_Str",list2)){
      assertTrue(rc.present());
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str")),list2);
    }
     try (WriteContext wc=map.acquireUsingLocked("String_Node_Str",list1)){
      list1.add("String_Node_Str");
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str","String_Node_Str")),list1);
    }
     try (ReadContext rc=map.getUsingLocked("String_Node_Str",list2)){
      assertTrue(rc.present());
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str","String_Node_Str")),list2);
    }
     for (    Map.Entry<String,Set<String>> entry : map.entrySet()) {
      entry.getKey();
      entry.getValue();
    }
    mapChecks();
  }
 }

Fixed version (ground truth):
@Test public void testSetValue() throws IOException {
  if (typeOfMap == TypeOfMap.STATELESS)   return;
  ChronicleMapBuilder<String,Set<String>> builder=ChronicleMapBuilder.of(String.class,(Class<Set<String>>)(Class)Set.class).valueMarshaller(SetMarshaller.of(new StringMarshaller(8)));
  try (ChronicleMap<String,Set<String>> map=newInstance(builder)){
    map.put("String_Node_Str",Collections.<String>emptySet());
    map.put("String_Node_Str",new LinkedHashSet<String>(asList("String_Node_Str")));
    Set<String> list1=new LinkedHashSet<>();
    try (WriteContext wc=map.acquireUsingLocked("String_Node_Str",list1)){
      list1.add("String_Node_Str");
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str")),list1);
    }
     Set<String> list2=new LinkedHashSet<>();
    try (ReadContext rc=map.getUsingLocked("String_Node_Str",list2)){
      assertTrue(rc.present());
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str")),list2);
    }
     try (WriteContext wc=map.acquireUsingLocked("String_Node_Str",list1)){
      list1.add("String_Node_Str");
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str","String_Node_Str")),list1);
    }
     try (ReadContext rc=map.getUsingLocked("String_Node_Str",list2)){
      assertTrue(rc.present());
      assertEquals(new LinkedHashSet<String>(asList("String_Node_Str","String_Node_Str")),list2);
    }
     for (    Map.Entry<String,Set<String>> entry : map.entrySet()) {
      entry.getKey();
      entry.getValue();
    }
    mapChecks();
  }
 }
Program: 162971
Project: 162971
Buggy source:
@Nullable private Work remove(Bytes reader,@NotNull Bytes writer,final long sizeLocation,long timestamp,byte id){
  try {
    map.remove(reader,writer);
  }
 catch (  Throwable e) {
    return sendException(writer,sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer);
  return null;
}

Fixed version (ground truth):
@Nullable private Work remove(Bytes reader,TcpReplicator.TcpSocketChannelEntryWriter writer,final long sizeLocation,long timestamp,byte id){
  try {
    map.remove(reader,writer);
  }
 catch (  Throwable e) {
    return sendException(writer.in(),sizeLocation,e);
  }
  writeSizeAndFlags(sizeLocation,false,writer.in());
  return null;
}
Program: 162972
Project: 162972
Buggy source:
@Override public void startSearch(long key){
  key=maskUnsetKey(key);
  searchPos=pos(key);
  searchHash=key;
}

Fixed version (ground truth):
@Override public void startSearch(long key,SearchState searchStateToReuse){
  key=maskUnsetKey(key);
  searchStateToReuse.searchPos=pos(key);
  searchStateToReuse.searchHash=key;
}
Program: 162973
Project: 162973
Buggy source:
@Override public void replacePrevPos(long newValue){
  checkValueForPut(newValue);
  long prevPos=stepBack(searchPos);
  long oldEntry=bytes.readInt48(prevPos);
  long oldValue=value(oldEntry);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeInt48(prevPos,entry(searchHash,newValue));
}

Fixed version (ground truth):
@Override public void replacePrevPos(SearchState searchState,long newValue){
  checkValueForPut(newValue);
  long prevPos=stepBack(searchState.searchPos);
  long oldEntry=bytes.readInt48(prevPos);
  long oldValue=value(oldEntry);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeInt48(prevPos,entry(searchState.searchHash,newValue));
}
Program: 162974
Project: 162974
Buggy source:
@Override public void putAfterFailedSearch(long value){
  checkValueForPut(value);
  positions.set(value);
  bytes.writeInt48(searchPos,entry(searchHash,value));
}

Fixed version (ground truth):
@Override public void putAfterFailedSearch(SearchState searchState,long value){
  checkValueForPut(value);
  positions.set(value);
  bytes.writeInt48(searchState.searchPos,entry(searchState.searchHash,value));
}
Program: 162975
Project: 162975
Buggy source:
@Override public long nextPos(){
  long pos=searchPos;
  while (true) {
    long entry=bytes.readInt48(pos);
    if (entry == UNSET_ENTRY) {
      searchPos=pos;
      return -1L;
    }
    pos=step(pos);
    if (key(entry) == searchHash) {
      searchPos=pos;
      return value(entry);
    }
  }
}

Fixed version (ground truth):
@Override public long nextPos(SearchState searchState){
  long pos=searchState.searchPos;
  while (true) {
    long entry=bytes.readInt48(pos);
    if (entry == UNSET_ENTRY) {
      searchState.searchPos=pos;
      return -1L;
    }
    pos=step(pos);
    if (key(entry) == searchState.searchHash) {
      searchState.searchPos=pos;
      return value(entry);
    }
  }
}
Program: 162976
Project: 162976
Buggy source:
@Override public void removePrevPos(){
  long prevPos=stepBack(searchPos);
  long entry=bytes.readInt48(prevPos);
  positions.clear(value(entry));
  removePos(prevPos);
}

Fixed version (ground truth):
@Override public void removePrevPos(SearchState searchState){
  long prevPos=stepBack(searchState.searchPos);
  long entry=bytes.readInt48(prevPos);
  positions.clear(value(entry));
  removePos(prevPos);
}
Program: 162977
Project: 162977
Buggy source:
@Override public void startSearch(long key){
  key=maskUnsetKey(key);
  searchPos=pos(key);
  searchHash=key;
}

Fixed version (ground truth):
@Override public void startSearch(long key,SearchState searchStateToReuse){
  key=maskUnsetKey(key);
  searchStateToReuse.searchPos=pos(key);
  searchStateToReuse.searchHash=key;
}
Program: 162978
Project: 162978
Buggy source:
@Override public void replacePrevPos(long newValue){
  checkValueForPut(newValue);
  long prevPos=stepBack(searchPos);
  long oldEntry=bytes.readLong(prevPos);
  long oldValue=value(oldEntry);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeLong(prevPos,entry(searchHash,newValue));
}

Fixed version (ground truth):
@Override public void replacePrevPos(SearchState searchState,long newValue){
  checkValueForPut(newValue);
  long prevPos=stepBack(searchState.searchPos);
  long oldEntry=bytes.readLong(prevPos);
  long oldValue=value(oldEntry);
  positions.clear(oldValue);
  positions.set(newValue);
  bytes.writeLong(prevPos,entry(searchState.searchHash,newValue));
}
Program: 162979
Project: 162979
Buggy source:
@Override public void putAfterFailedSearch(long value){
  checkValueForPut(value);
  positions.set(value);
  bytes.writeLong(searchPos,entry(searchHash,value));
}

Fixed version (ground truth):
@Override public void putAfterFailedSearch(SearchState searchState,long value){
  checkValueForPut(value);
  positions.set(value);
  bytes.writeLong(searchState.searchPos,entry(searchState.searchHash,value));
}