nus-yam/ex-repair huggingface dataset:
Program: 91340
Project: 91340
Buggy source:
/** 
 * Dirties all entries with a modification time newer than   {@code timeStamp} ( inclusive )<p/> This functionality is used to publish recently modified entries to a new remote node as it connects
 * @param timeStamp the timestamp ( up to and including ) from which all entries should be dirty
 */
void dirtyEntries(long timeStamp);

Fixed version (ground truth):
void dirtyEntries(long timeStamp,EntryModifiableCallback entryModifiableCallback);
Program: 91342
Project: 91342
Buggy source:
@Override public void accept(int hash,int pos){
  final long offset=offsetFromPos(pos);
  final NativeBytes entry=entry(offset);
  long keyLen=entry.readStopBit();
  entry.skip(keyLen);
  final long entryTimestamp=entry.readLong();
  if (entryTimestamp >= timeStamp && entry.readByte() == VanillaSharedReplicatedHashMap.this.getIdentifier())   entryModifiableCallback.set(index,pos);
}

Fixed version (ground truth):
@Override public void accept(int hash,int pos){
  final NativeBytes entry=entry(offsetFromPos(pos));
  long keyLen=entry.readStopBit();
  entry.skip(keyLen);
  final long entryTimestamp=entry.readLong();
  if (entryTimestamp >= timeStamp && entry.readByte() == VanillaSharedReplicatedHashMap.this.getIdentifier())   entryModifiableCallback.set(index,pos);
}
Program: 91343
Project: 91343
Buggy source:
/** 
 * {@inheritDoc}
 */
public void writeExternalEntry(@NotNull NativeBytes entry,@NotNull Bytes destination){
  final long limt=entry.limit();
  final long keyLen=entry.readStopBit();
  final long keyPosition=entry.position();
  entry.skip(keyLen);
  final long keyLimit=entry.position();
  final long timeStamp=entry.readLong();
  final byte identifier=entry.readByte();
  if (identifier != localIdentifier) {
    return;
  }
  final boolean isDeleted=entry.readBoolean();
  long valueLen=isDeleted ? 0 : entry.readStopBit();
  final long position=entry.position();
  destination.writeStopBit(keyLen);
  destination.writeStopBit(valueLen);
  destination.writeStopBit(timeStamp);
  if (isDeleted)   destination.writeByte(-identifier);
 else   destination.writeByte(identifier);
  entry.limit(keyLimit);
  entry.position(keyPosition);
  destination.write(entry);
  if (isDeleted || valueLen == 0)   return;
  entry.limit(limt);
  entry.position(position);
  alignment.alignPositionAddr(entry);
  entry.limit(entry.position() + valueLen);
  destination.write(entry);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void writeExternalEntry(@NotNull NativeBytes entry,@NotNull Bytes destination){
  final long limt=entry.limit();
  final long keyLen=entry.readStopBit();
  final long keyPosition=entry.position();
  entry.skip(keyLen);
  final long keyLimit=entry.position();
  final long timeStamp=entry.readLong();
  final byte identifier=entry.readByte();
  if (identifier != localIdentifier) {
    return;
  }
  final boolean isDeleted=entry.readBoolean();
  long valueLen=isDeleted ? 0 : entry.readStopBit();
  final long position=entry.position();
  destination.writeStopBit(keyLen);
  destination.writeStopBit(valueLen);
  destination.writeStopBit(timeStamp);
  if (isDeleted)   destination.writeByte(-identifier);
 else   destination.writeByte(identifier);
  entry.limit(keyLimit);
  entry.position(keyPosition);
  destination.write(entry);
  String message=null;
  if (LOG.isDebugEnabled()) {
    if (isDeleted || valueLen == 0)     LOG.debug("String_Node_Str" + localIdentifier + "String_Node_Str"+ ByteUtils.toCharSequence(entry).trim()+ "String_Node_Str");
 else     message="String_Node_Str" + localIdentifier + "String_Node_Str"+ ByteUtils.toCharSequence(entry).trim()+ "String_Node_Str";
  }
  if (isDeleted || valueLen == 0)   return;
  entry.limit(limt);
  entry.position(position);
  alignment.alignPositionAddr(entry);
  entry.limit(entry.position() + valueLen);
  destination.write(entry);
  if (LOG.isDebugEnabled()) {
    LOG.debug(message + "String_Node_Str" + ByteUtils.toCharSequence(entry).trim()+ "String_Node_Str");
  }
}
Program: 91344
Project: 91344
Buggy source:
@Override public void dirtyEntries(long timeStamp){
  for (  final Segment segment : (Segment[])segments) {
    segment.dirtyNewerEntries(timeStamp,entryModifiableCallback);
  }
}

Fixed version (ground truth):
@Override public void dirtyEntries(long timeStamp){
  for (  final Segment segment : (Segment[])segments) {
    segment.dirtyEntries(timeStamp,entryModifiableCallback);
  }
}
Program: 91348
Project: 91348
Buggy source:
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  final long start=bytes.position();
  for (; ; ) {
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == start)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == start))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.clear();
      bytes.clear();
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
      bytes.limit(bytes.capacity());
      byteBuffer.limit(byteBuffer.capacity());
    }
    return;
  }
}

Fixed version (ground truth):
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  final long start=bytes.position();
  if (bytes.position() > 0)   writeBytes(socketChannel);
  for (; ; ) {
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == start)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == start))     continue;
    writeBytes(socketChannel);
    return;
  }
}
Program: 91350
Project: 91350
Buggy source:
@Test public void test3() throws IOException, InterruptedException {
  map3.put(5,"String_Node_Str");
  waitTillEqual(5000000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertEquals(new TreeMap(map3),new TreeMap(map2));
  assertTrue(!map1.isEmpty());
}

Fixed version (ground truth):
@Test public void test3() throws IOException, InterruptedException {
  map3.put(5,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertEquals(new TreeMap(map3),new TreeMap(map2));
  assertTrue(!map1.isEmpty());
}
Program: 91352
Project: 91352
Buggy source:
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    map1.put(i,"String_Node_Str");
  }
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    map1.put(i,"String_Node_Str");
  }
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map2.isEmpty());
}
Program: 91353
Project: 91353
Buggy source:
Entry<K,V> nextSegmentEntry(){
  while (segmentIndex >= 0) {
    if (segmentPositions.isEmpty()) {
      switchToNextSegment();
    }
 else {
      Segment segment=segments[segmentIndex];
      while (!segmentPositions.isEmpty()) {
        Entry<K,V> entry=segment.getEntry(segmentPositions.removeFirst());
        if (entry != null) {
          return entry;
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
Entry<K,V> nextSegmentEntry(){
  while (segmentIndex >= 0) {
    if (segmentPositions.isEmpty()) {
      switchToNextSegment();
    }
 else {
      final Segment segment=segments[segmentIndex];
      segment.lock();
      try {
        while (!segmentPositions.isEmpty()) {
          Entry<K,V> entry=segment.getEntry(segmentPositions.removeFirst());
          if (entry != null) {
            return entry;
          }
        }
      }
  finally {
        segment.unlock();
      }
    }
  }
  return null;
}
Program: 91354
Project: 91354
Buggy source:
private void switchToNextSegment(){
  segmentPositions.clear();
  segmentIndex--;
  if (segmentIndex >= 0) {
    segments[segmentIndex].visit(this);
  }
}

Fixed version (ground truth):
private void switchToNextSegment(){
  segmentPositions.clear();
  segmentIndex--;
  if (segmentIndex >= 0) {
    final Segment segment=segments[segmentIndex];
    segment.lock();
    try {
      segments[segmentIndex].visit(this);
    }
  finally {
      segment.unlock();
    }
  }
}
Program: 91357
Project: 91357
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91358
Project: 91358
Buggy source:
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079,new ClientPort(8078,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"));
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079,new ClientPort(8078,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
}
Program: 91359
Project: 91359
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map1.put(2,"String_Node_Str");
  map1.put(3,"String_Node_Str");
  map2.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map1.remove(2);
  map2.remove(3);
  map1.remove(3);
  map2.put(5,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map1.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map1.put(2,"String_Node_Str");
  map1.put(3,"String_Node_Str");
  map2.put(5,"String_Node_Str");
  map2.put(6,"String_Node_Str");
  map1.remove(2);
  map2.remove(3);
  map1.remove(3);
  map2.put(5,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map1.isEmpty());
}
Program: 91362
Project: 91362
Buggy source:
@Override public void close() throws IOException {
  isClosed.set(true);
  final SocketChannel socketChannel=socketChannelRef.get();
  if (socketChannel != null)   socketChannel.close();
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  final SocketChannel socketChannel=socketChannelRef.get();
  if (socketChannel != null)   socketChannel.close();
}
Program: 91364
Project: 91364
Buggy source:
Bootstrap readWelcomeMessage(SocketChannel channel) throws IOException {
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
  while (bytes.remaining() < 9) {
    channel.read(byteBuffer);
    bytes.limit(byteBuffer.position());
  }
  return new Bootstrap(bytes.readByte(),bytes.readLong());
}

Fixed version (ground truth):
Bootstrap readWelcomeMessage(SocketChannel channel) throws IOException {
  while (bytes.remaining() < 9) {
    channel.read(byteBuffer);
    bytes.limit(byteBuffer.position());
  }
  return new Bootstrap(bytes.readByte(),bytes.readLong());
}
Program: 91365
Project: 91365
Buggy source:
public SocketChannelEntryReader(int entrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.entrySize0=entrySize;
  byteBuffer=ByteBuffer.allocate(entrySize0 * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
}

Fixed version (ground truth):
public SocketChannelEntryReader(int entrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.entrySize0=entrySize;
  byteBuffer=ByteBuffer.allocate(entrySize0 * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  bytes.limit(0);
  byteBuffer.clear();
}
Program: 91366
Project: 91366
Buggy source:
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  for (; ; ) {
    byteBuffer.limit(byteBuffer.capacity());
    boolean wasDataRead=false;
    try {
      wasDataRead=modificationIterator.nextEntry(entryCallback);
    }
 catch (    IndexOutOfBoundsException e) {
      e.printStackTrace();
      int i=1;
    }
    if (!wasDataRead && bytes.position() == 0)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == 0))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.position(0);
      byteBuffer.limit(0);
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
    }
    bytes.position(byteBuffer.limit());
    bytes.limit(bytes.capacity());
    return;
  }
}

Fixed version (ground truth):
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  final long start=bytes.position();
  for (; ; ) {
    if (start != 0)     Log.info("String_Node_Str");
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == start)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == start))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.clear();
      bytes.clear();
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
      bytes.limit(bytes.capacity());
      byteBuffer.limit(byteBuffer.capacity());
    }
    return;
  }
}
Program: 91367
Project: 91367
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91368
Project: 91368
Buggy source:
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079,new ClientPort(8078,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"),new ClientPort(8076,"String_Node_Str"));
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079);
}
Program: 91370
Project: 91370
Buggy source:
@After public void tearDown(){
  for (  final Closeable closeable : new Closeable[]{map1,map2,map3,map4}) {
    try {
      closeable.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@After public void tearDown() throws InterruptedException {
  for (  final Closeable closeable : new Closeable[]{map1,map2,map3,map4}) {
    try {
      closeable.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  Thread.sleep(100);
}
Program: 91373
Project: 91373
Buggy source:
/** 
 * @return the maximum size that an entry can be, this includes over sized entries
 */
int maxEntrySize(){
  return entrySize * 2;
}

Fixed version (ground truth):
/** 
 * @return the maximum size that an entry can be, this includes over sized entries
 */
int maxEntrySize(){
  return entrySize * bufferAllocationFactor;
}
Program: 91374
Project: 91374
Buggy source:
/** 
 * set the bit related to   {@code segment} and {@code pos}
 * @param segment the segment relating to the bit to set
 * @param pos     the position relating to the bit to set
 */
void set(SharedSegment segment,int pos);

Fixed version (ground truth):
/** 
 * set the bit related to   {@code segment} and {@code pos}
 * @param segmentIndex the segment relating to the bit to set
 * @param pos     the position relating to the bit to set
 */
void set(int segmentIndex,int pos);
Program: 91375
Project: 91375
Buggy source:
/** 
 * {@inheritDoc}
 */
public void dirtyNewerEntries(final long timeStamp,final EntryModifiableCallback entryModifiableCallback){
  this.lock();
  try {
    hashLookupLiveAndDeleted.forEach(new IntIntMultiMap.EntryConsumer(){
      @Override public void accept(      int hash,      int pos){
        final long offset=offsetFromPos(pos);
        final NativeBytes entry=entry(offset);
        if (isNewer(entry,timeStamp))         entryModifiableCallback.set(Segment.this,pos);
      }
    }
);
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void dirtyNewerEntries(final long timeStamp,final EntryModifiableCallback entryModifiableCallback){
  this.lock();
  try {
    final int index=Segment.this.getIndex();
    hashLookupLiveAndDeleted.forEach(new IntIntMultiMap.EntryConsumer(){
      @Override public void accept(      int hash,      int pos){
        final long offset=offsetFromPos(pos);
        final NativeBytes entry=entry(offset);
        if (isNewer(entry,timeStamp))         entryModifiableCallback.set(index,pos);
      }
    }
);
  }
  finally {
    unlock();
  }
}
Program: 91376
Project: 91376
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public ModificationIterator acquireModificationIterator(byte remoteIdentifier) throws IOException {
  if (!canReplicate)   throw new UnsupportedOperationException();
  final ModificationIterator modificationIterator=modificationIterators.get(remoteIdentifier);
  if (modificationIterator != null)   return modificationIterator;
  final File modificationIteratorFile=new File(file().getAbsolutePath() + '-' + remoteIdentifier+ "String_Node_Str");
synchronized (modificationIterators) {
    final MappedStore mappedStore=new MappedStore(modificationIteratorFile,FileChannel.MapMode.READ_WRITE,modIterBitSetSizeInBytes());
    final ModificationIterator newEventListener=new ModificationIterator(modificationIteratorNotifier,modificationIteratorWatchList,mappedStore.bytes(),eventListener);
    final boolean success=modificationIterators.compareAndSet(remoteIdentifier,null,newEventListener);
    return (success) ? (ModificationIterator)(eventListener=newEventListener) : acquireModificationIterator(remoteIdentifier);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public ModificationIterator acquireModificationIterator(byte remoteIdentifier) throws IOException {
  if (!canReplicate)   throw new UnsupportedOperationException();
  final ModificationIterator modificationIterator=modificationIterators.get(remoteIdentifier);
  if (modificationIterator != null)   return modificationIterator;
synchronized (modificationIterators) {
    final ModificationIterator modificationIterator0=modificationIterators.get(remoteIdentifier);
    if (modificationIterator0 != null)     return modificationIterator0;
    final File modificationIteratorFile=new File(file().getAbsolutePath() + '-' + remoteIdentifier+ "String_Node_Str");
    final MappedStore mappedStore=new MappedStore(modificationIteratorFile,FileChannel.MapMode.READ_WRITE,modIterBitSetSizeInBytes());
    final ModificationIterator newEventListener=new ModificationIterator(modificationIteratorNotifier,modificationIteratorWatchList,mappedStore.bytes(),eventListener);
    modificationIterators.set(remoteIdentifier,newEventListener);
    eventListener=newEventListener;
    return newEventListener;
  }
}
Program: 91377
Project: 91377
Buggy source:
@Override public int maxEntrySize(){
  return super.maxEntrySize();
}

Fixed version (ground truth):
@Override public int maxEntrySize(){
  return super.maxEntrySize() + 128;
}
Program: 91378
Project: 91378
Buggy source:
@Override public void accept(int hash,int pos){
  final long offset=offsetFromPos(pos);
  final NativeBytes entry=entry(offset);
  if (isNewer(entry,timeStamp))   entryModifiableCallback.set(Segment.this,pos);
}

Fixed version (ground truth):
@Override public void accept(int hash,int pos){
  final long offset=offsetFromPos(pos);
  final NativeBytes entry=entry(offset);
  if (isNewer(entry,timeStamp))   entryModifiableCallback.set(index,pos);
}
Program: 91379
Project: 91379
Buggy source:
public void set(SharedSegment segment,int pos){
  System.out.println("String_Node_Str" + segment.getIndex() + "String_Node_Str"+ pos);
  changes.set(combine(segment.getIndex(),pos));
}

Fixed version (ground truth):
@Override public synchronized void set(int segmentIndex,int pos){
  changes.set(combine(segmentIndex,pos));
}
Program: 91381
Project: 91381
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(1000);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(500);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91383
Project: 91383
Buggy source:
/** 
 * @return the maximum size that an entry can be, this includes over sized entries
 */
int maxEntrySize(){
  return entrySize * 2;
}

Fixed version (ground truth):
/** 
 * @return the maximum size that an entry can be, this includes over sized entries
 */
int maxEntrySize(){
  return entrySize;
}
Program: 91384
Project: 91384
Buggy source:
/** 
 * {@inheritDoc}
 */
public void dirtyNewerEntries(final long timeStamp,final EntryModifiableCallback entryModifiableCallback){
  this.lock();
  try {
    final int index=Segment.this.getIndex();
    hashLookupLiveAndDeleted.forEach(new IntIntMultiMap.EntryConsumer(){
      @Override public void accept(      int hash,      int pos){
        final long offset=offsetFromPos(pos);
        final NativeBytes entry=entry(offset);
        if (isNewer(entry,timeStamp))         entryModifiableCallback.set(index,pos);
      }
    }
);
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void dirtyNewerEntries(final long timeStamp,final EntryModifiableCallback entryModifiableCallback){
  this.lock();
  try {
    final int index=Segment.this.getIndex();
    hashLookupLiveAndDeleted.forEach(new IntIntMultiMap.EntryConsumer(){
      @Override public void accept(      int hash,      int pos){
        final long offset=offsetFromPos(pos);
        final NativeBytes entry=entry(offset);
        if (isNewer(entry,timeStamp)) {
          entryModifiableCallback.set(index,pos);
        }
      }
    }
);
  }
  finally {
    unlock();
  }
}
Program: 91385
Project: 91385
Buggy source:
@Override public void accept(int hash,int pos){
  final long offset=offsetFromPos(pos);
  final NativeBytes entry=entry(offset);
  if (isNewer(entry,timeStamp))   entryModifiableCallback.set(index,pos);
}

Fixed version (ground truth):
@Override public void accept(int hash,int pos){
  final long offset=offsetFromPos(pos);
  final NativeBytes entry=entry(offset);
  if (isNewer(entry,timeStamp)) {
    entryModifiableCallback.set(index,pos);
  }
}
Program: 91386
Project: 91386
Buggy source:
@Override public synchronized void set(int segmentIndex,int pos){
  changes.set(combine(segmentIndex,pos));
}

Fixed version (ground truth):
@Override public synchronized void set(int segmentIndex,int pos){
  final long combine=combine(segmentIndex,pos);
  System.out.println("String_Node_Str" + combine);
  changes.set(combine);
}
Program: 91390
Project: 91390
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(500);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(500);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91391
Project: 91391
Buggy source:
/** 
 * reads entries from the socket till it is empty
 * @param socketChannel
 * @throws IOException
 * @throws InterruptedException
 */
void readAll(@NotNull final SocketChannel socketChannel) throws IOException, InterruptedException {
  if (sizeOfNextEntry == Long.MIN_VALUE) {
    if (bytes.remaining() < 8) {
      socketChannel.read(byteBuffer);
      bytes.limit(byteBuffer.position());
      if (bytes.remaining() < 8)       return;
    }
    sizeOfNextEntry=bytes.readUnsignedShort();
  }
  if (sizeOfNextEntry <= 0)   throw new IllegalStateException("String_Node_Str" + sizeOfNextEntry);
  if (bytes.remaining() < sizeOfNextEntry) {
    socketChannel.read(byteBuffer);
    bytes.limit(byteBuffer.position());
    if (bytes.remaining() < sizeOfNextEntry)     return;
  }
  final long limit=bytes.position() + sizeOfNextEntry;
  bytes.limit(limit);
  externalizable.readExternalEntry(bytes);
  bytes.position(limit);
  if (byteBuffer.position() > 0 && byteBuffer.remaining() <= entrySize0) {
    byteBuffer.compact();
    bytes.position(0);
  }
  bytes.limit(byteBuffer.position());
  sizeOfNextEntry=Long.MIN_VALUE;
}

Fixed version (ground truth):
/** 
 * reads entries from the socket till it is empty
 * @param socketChannel
 * @throws IOException
 * @throws InterruptedException
 */
void readAll(@NotNull final SocketChannel socketChannel) throws IOException, InterruptedException {
  for (; ; ) {
    if (sizeOfNextEntry == Long.MIN_VALUE) {
      if (bytes.remaining() < 8) {
        socketChannel.read(byteBuffer);
        bytes.limit(byteBuffer.position());
        if (bytes.remaining() < 8)         return;
      }
      sizeOfNextEntry=bytes.readUnsignedShort();
    }
    if (sizeOfNextEntry <= 0)     throw new IllegalStateException("String_Node_Str" + sizeOfNextEntry);
    if (bytes.remaining() < sizeOfNextEntry) {
      socketChannel.read(byteBuffer);
      bytes.limit(byteBuffer.position());
      if (bytes.remaining() < sizeOfNextEntry)       return;
    }
    final long limit=bytes.position() + sizeOfNextEntry;
    bytes.limit(limit);
    externalizable.readExternalEntry(bytes);
    bytes.position(limit);
    if (byteBuffer.position() > 0 && byteBuffer.remaining() <= entrySize0) {
      byteBuffer.compact();
      bytes.position(0);
    }
    bytes.limit(byteBuffer.position());
    sizeOfNextEntry=Long.MIN_VALUE;
  }
}
Program: 91392
Project: 91392
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(500);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map3.remove(2);
  map3.put(3,"String_Node_Str");
  map4.put(4,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91393
Project: 91393
Buggy source:
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079);
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  map1=newSocketShmIntString((byte)1,8076,new ClientPort(8077,"String_Node_Str"),new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map2=newSocketShmIntString((byte)2,8077,new ClientPort(8078,"String_Node_Str"),new ClientPort(8079,"String_Node_Str"));
  map3=newSocketShmIntString((byte)3,8078,new ClientPort(8079,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"));
  map4=newSocketShmIntString((byte)4,8079,new ClientPort(8078,"String_Node_Str"),new ClientPort(8077,"String_Node_Str"));
}
Program: 91394
Project: 91394
Buggy source:
@Test @Ignore public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map1.put(2,"String_Node_Str");
  map1.put(3,"String_Node_Str");
  map2.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map1.remove(2);
  map2.remove(3);
  map1.remove(3);
  map2.put(5,"String_Node_Str");
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map1.isEmpty());
}
Program: 91395
Project: 91395
Buggy source:
@Test public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    map1.put(i,"String_Node_Str");
  }
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map2.isEmpty());
}

Fixed version (ground truth):
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    map1.put(i,"String_Node_Str");
  }
  waitTillEqual(5000);
  assertEquals(new TreeMap(map1),new TreeMap(map2));
  assertTrue(!map2.isEmpty());
}
Program: 91399
Project: 91399
Buggy source:
WelcomeMessage readWelcomeMessage(SocketChannel channel) throws IOException {
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
  while (bytes.remaining() < 9) {
    channel.read(byteBuffer);
    bytes.limit(byteBuffer.position());
  }
  return new WelcomeMessage(bytes.readByte(),bytes.readLong());
}

Fixed version (ground truth):
Bootstrap readWelcomeMessage(SocketChannel channel) throws IOException {
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
  while (bytes.remaining() < 9) {
    channel.read(byteBuffer);
    bytes.limit(byteBuffer.position());
  }
  return new Bootstrap(bytes.readByte(),bytes.readLong());
}
Program: 91400
Project: 91400
Buggy source:
public SocketChannelEntryReader(int entrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.entrySize0=entrySize + 128;
  byteBuffer=ByteBuffer.allocate(entrySize0 * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
}

Fixed version (ground truth):
public SocketChannelEntryReader(int entrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.entrySize0=entrySize;
  byteBuffer=ByteBuffer.allocate(entrySize0 * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  byteBuffer.clear();
  bytes.limit(0);
  bytes.position(0);
}
Program: 91401
Project: 91401
Buggy source:
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  for (; ; ) {
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == 0)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == 0))     continue;
    bytes.flip();
    final ByteBuffer byteBuffer=bytes.buffer();
    byteBuffer.limit((int)bytes.limit());
    byteBuffer.position((int)bytes.position());
    socketChannel.write(byteBuffer);
    bytes.clear();
    byteBuffer.clear();
    return;
  }
}

Fixed version (ground truth):
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  for (; ; ) {
    byteBuffer.limit(byteBuffer.capacity());
    boolean wasDataRead=false;
    try {
      wasDataRead=modificationIterator.nextEntry(entryCallback);
    }
 catch (    IndexOutOfBoundsException e) {
      e.printStackTrace();
      int i=1;
    }
    if (!wasDataRead && bytes.position() == 0)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == 0))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.position(0);
      byteBuffer.limit(0);
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
    }
    bytes.position(byteBuffer.limit());
    bytes.limit(bytes.capacity());
    return;
  }
}
Program: 91402
Project: 91402
Buggy source:
public void sendWelcomeMessage(@NotNull final SocketChannel socketChannel,final long timeStampOfLastMessage,final int localIdentifier1) throws IOException {
  bytes.clear();
  byteBuffer.clear();
  bytes.writeByte(localIdentifier1);
  bytes.writeLong(timeStampOfLastMessage);
  byteBuffer.limit((int)bytes.position());
  socketChannel.write(byteBuffer);
  bytes.clear();
  byteBuffer.clear();
}

Fixed version (ground truth):
public void sendWelcomeMessage(@NotNull final SocketChannel socketChannel,final long timeStampOfLastMessage,final int localIdentifier1) throws IOException {
  bytes.clear();
  byteBuffer.clear();
  bytes.writeByte(localIdentifier1);
  bytes.writeLong(timeStampOfLastMessage);
  byteBuffer.limit((int)bytes.position());
  socketChannel.write(byteBuffer);
  if (byteBuffer.remaining() == 0) {
    byteBuffer.position(0);
    byteBuffer.limit(0);
  }
 else {
    byteBuffer.compact();
    byteBuffer.flip();
  }
  bytes.position(byteBuffer.limit());
  bytes.limit(bytes.capacity());
}
Program: 91404
Project: 91404
Buggy source:
@Before public void setup() throws IOException {
  map1=TCPSocketReplication4WayMapTest.newSocketShmIntString((byte)1,8076,new ClientTcpSocketReplicator.ClientPort(8077,"String_Node_Str"));
  map2=TCPSocketReplication4WayMapTest.newSocketShmIntString((byte)2,8077);
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  map1=TCPSocketReplication4WayMapTest.newSocketShmIntString((byte)1,8076);
  map2=TCPSocketReplication4WayMapTest.newSocketShmIntString((byte)2,8077,new ClientPort(8076,"String_Node_Str"));
}
Program: 91405
Project: 91405
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  Thread.sleep(1000);
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map4.remove(3);
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  map1.put(1,"String_Node_Str");
  map2.put(2,"String_Node_Str");
  map3.put(3,"String_Node_Str");
  map4.remove(3);
  waitTillEqual(1000);
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map2));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map3));
  assertEquals("String_Node_Str",new TreeMap(map1),new TreeMap(map4));
  assertTrue("String_Node_Str",!map2.isEmpty());
}
Program: 91409
Project: 91409
Buggy source:
public ServerTcpSocketReplicator(@NotNull final ReplicatedSharedHashMap map,@NotNull final EntryExternalizable externalizable,int port,@NotNull final SocketChannelEntryWriter socketChannelEntryWriter) throws IOException {
  this.externalizable=externalizable;
  this.map=map;
  this.port=port;
  this.serverChannel=ServerSocketChannel.open();
  this.localIdentifier=map.getIdentifier();
  this.socketChannelEntryWriter=socketChannelEntryWriter;
  this.entrySize=map.maxEntrySize();
  newSingleThreadExecutor(new NamedThreadFactory("String_Node_Str" + localIdentifier,true)).execute(new Runnable(){
    @Override public void run(){
      try {
        process();
      }
 catch (      Exception e) {
        LOG.log(Level.SEVERE,"String_Node_Str",e);
      }
    }
  }
);
}

Fixed version (ground truth):
public ServerTcpSocketReplicator(@NotNull final ReplicatedSharedHashMap map,@NotNull final EntryExternalizable externalizable,int port,@NotNull final SocketChannelEntryWriter socketChannelEntryWriter) throws IOException {
  this.externalizable=externalizable;
  this.map=map;
  this.port=port;
  this.serverChannel=ServerSocketChannel.open();
  this.localIdentifier=map.getIdentifier();
  this.socketChannelEntryWriter=socketChannelEntryWriter;
  this.maxEntrySize=map.maxEntrySize();
  newSingleThreadExecutor(new NamedThreadFactory("String_Node_Str" + localIdentifier,true)).execute(new Runnable(){
    @Override public void run(){
      try {
        process();
      }
 catch (      Exception e) {
        LOG.log(Level.SEVERE,"String_Node_Str",e);
      }
    }
  }
);
}
Program: 91410
Project: 91410
Buggy source:
/** 
 * reads entries from the socket till it is empty
 * @param socketChannel
 * @throws IOException
 * @throws InterruptedException
 */
void readAll(@NotNull final SocketChannel socketChannel) throws IOException, InterruptedException {
  for (; ; ) {
    if (sizeOfNextEntry == Long.MIN_VALUE) {
      if (bytes.remaining() < 8) {
        socketChannel.read(byteBuffer);
        bytes.limit(byteBuffer.position());
        if (bytes.remaining() < 8)         return;
      }
      sizeOfNextEntry=bytes.readUnsignedShort();
    }
    if (sizeOfNextEntry <= 0)     throw new IllegalStateException("String_Node_Str" + sizeOfNextEntry);
    if (bytes.remaining() < sizeOfNextEntry) {
      socketChannel.read(byteBuffer);
      bytes.limit(byteBuffer.position());
      if (bytes.remaining() < sizeOfNextEntry)       return;
    }
    final long limit=bytes.position() + sizeOfNextEntry;
    bytes.limit(limit);
    externalizable.readExternalEntry(bytes);
    bytes.position(limit);
    if (byteBuffer.position() > 0 && byteBuffer.remaining() <= entrySize0) {
      byteBuffer.compact();
      bytes.position(0);
    }
    bytes.limit(byteBuffer.position());
    sizeOfNextEntry=Long.MIN_VALUE;
  }
}

Fixed version (ground truth):
/** 
 * reads entries from the socket till it is empty
 * @param socketChannel
 * @throws IOException
 * @throws InterruptedException
 */
void readAll(@NotNull final SocketChannel socketChannel) throws IOException, InterruptedException {
  for (; ; ) {
    if (sizeOfNextEntry == Long.MIN_VALUE) {
      if (bytes.remaining() < SIZE_OF_UNSIGNED_SHORT) {
        socketChannel.read(byteBuffer);
        bytes.limit(byteBuffer.position());
        if (bytes.remaining() < SIZE_OF_UNSIGNED_SHORT)         return;
      }
      sizeOfNextEntry=bytes.readUnsignedShort();
    }
    if (sizeOfNextEntry <= 0)     throw new IllegalStateException("String_Node_Str" + sizeOfNextEntry);
    if (bytes.remaining() < sizeOfNextEntry) {
      socketChannel.read(byteBuffer);
      bytes.limit(byteBuffer.position());
      if (bytes.remaining() < sizeOfNextEntry)       return;
    }
    final long limit=bytes.position() + sizeOfNextEntry;
    bytes.limit(limit);
    externalizable.readExternalEntry(bytes);
    bytes.position(limit);
    if (byteBuffer.position() > 0 && byteBuffer.remaining() <= maxEntrySize + SIZE_OF_UNSIGNED_SHORT) {
      byteBuffer.compact();
      bytes.position(0);
    }
    bytes.limit(byteBuffer.position());
    sizeOfNextEntry=Long.MIN_VALUE;
  }
}
Program: 91411
Project: 91411
Buggy source:
public SocketChannelEntryReader(int entrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.entrySize0=entrySize;
  byteBuffer=ByteBuffer.allocate(entrySize0 * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  bytes.limit(0);
  byteBuffer.clear();
}

Fixed version (ground truth):
public SocketChannelEntryReader(int maxEntrySize,ReplicatedSharedHashMap.EntryExternalizable externalizable){
  this.maxEntrySize=maxEntrySize;
  byteBuffer=ByteBuffer.allocate(this.maxEntrySize * MAX_NUMBER_OF_ENTRIES_PER_BUFFER);
  this.externalizable=externalizable;
  bytes=new ByteBufferBytes(byteBuffer);
  bytes.limit(0);
  byteBuffer.clear();
}
Program: 91412
Project: 91412
Buggy source:
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  final long start=bytes.position();
  for (; ; ) {
    if (start != 0)     Log.info("String_Node_Str");
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == start)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == start))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.clear();
      bytes.clear();
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
      bytes.limit(bytes.capacity());
      byteBuffer.limit(byteBuffer.capacity());
    }
    return;
  }
}

Fixed version (ground truth):
/** 
 * writes all the entries that have changed, to the tcp socket
 * @param socketChannel
 * @param modificationIterator
 * @throws InterruptedException
 * @throws java.io.IOException
 */
void writeAll(@NotNull final SocketChannel socketChannel,final ReplicatedSharedHashMap.ModificationIterator modificationIterator) throws InterruptedException, IOException {
  final long start=bytes.position();
  for (; ; ) {
    final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
    if (!wasDataRead && bytes.position() == start)     return;
    if (bytes.remaining() > entryMaxSize && (wasDataRead || bytes.position() == start))     continue;
    byteBuffer.limit((int)bytes.position());
    socketChannel.write(byteBuffer);
    if (byteBuffer.remaining() == 0) {
      byteBuffer.clear();
      bytes.clear();
    }
 else {
      byteBuffer.compact();
      byteBuffer.flip();
      bytes.limit(bytes.capacity());
      byteBuffer.limit(byteBuffer.capacity());
    }
    return;
  }
}