nus-yam/ex-repair huggingface dataset:
Program: 91298
Project: 91298
Buggy source:
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    Thread.sleep(1000);
  }
}

Fixed version (ground truth):
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    Thread.sleep(1000);
    System.out.println("String_Node_Str" + map2);
  }
}
Program: 91299
Project: 91299
Buggy source:
@Before public void setup() throws IOException {
  final TcpReplicatorBuilder tcpReplicatorBuilder=new TcpReplicatorBuilder(8079).heartBeatInterval(1000);
  map2=new SharedHashMapBuilder().entries(1000).identifier((byte)2).tcpReplication(tcpReplicatorBuilder).entries(20000).create(getPersistenceFile(),Integer.class,CharSequence.class);
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  final TcpReplicatorBuilder tcpReplicatorBuilder=new TcpReplicatorBuilder(8079).heartBeatInterval(10000);
  map2=new SharedHashMapBuilder().entries(1000).identifier((byte)2).tcpReplication(tcpReplicatorBuilder).entries(20000).create(getPersistenceFile(),Integer.class,CharSequence.class);
}
Program: 91300
Project: 91300
Buggy source:
/** 
 * used to connect both client and server sockets
 * @param identifier
 * @param clientSocket a queue containing the SocketChannel as they become connected
 * @return
 */
private void asyncReconnect(final byte identifier,final Socket clientSocket){
  final InetSocketAddress inetSocketAddress=new InetSocketAddress(clientSocket.getInetAddress().getHostName(),clientSocket.getPort());
  final Integer lastAttempts=connectionAttempts.get(connectionAttempts);
  final Integer attempts=lastAttempts == null ? 1 : lastAttempts + 1;
  connectionAttempts.put(inetSocketAddress,attempts);
  int reconnectionInterval=(attempts * attempts) * 100;
  if (reconnectionInterval > 20 * 1000)   reconnectionInterval=20 * 1000;
  asyncConnect0(identifier,null,Collections.singleton(inetSocketAddress),reconnectionInterval);
}

Fixed version (ground truth):
/** 
 * used to connect both client and server sockets
 * @param identifier
 * @param clientSocket a queue containing the SocketChannel as they become connected
 * @return
 */
private void asyncReconnect(final byte identifier,final Socket clientSocket){
  final InetSocketAddress inetSocketAddress=new InetSocketAddress(clientSocket.getInetAddress().getHostName(),clientSocket.getPort());
  final Integer lastAttempts=connectionAttempts.get(inetSocketAddress);
  final Integer attempts=lastAttempts == null ? 1 : lastAttempts + 1;
  connectionAttempts.put(inetSocketAddress,attempts);
  int reconnectionInterval=(attempts * attempts) * 100;
  if (reconnectionInterval > 20 * 1000)   reconnectionInterval=20 * 1000;
  asyncConnect0(identifier,null,Collections.singleton(inetSocketAddress),reconnectionInterval);
}
Program: 91301
Project: 91301
Buggy source:
/** 
 * re register the 'write' on the selector if the throttleInterval has passed
 * @throws java.nio.channels.ClosedChannelException
 */
public void checkThrottleInterval() throws ClosedChannelException {
  final long time=System.currentTimeMillis();
  if (lastTime + throttleInterval >= time)   return;
  lastTime=time;
  byteWritten=0;
  for (  SelectableChannel selectableChannel : channels) {
    Object attachment=null;
    try {
      final SelectionKey selectionKey=selectableChannel.keyFor(selector);
      attachment=selectionKey.attachment();
      selectableChannel.register(selector,OP_WRITE,attachment);
    }
 catch (    IOException e) {
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str",e);
      try {
        if (attachment != null)         ((AbstractAttached)attachment).connector.connect();
      }
 catch (      Exception e1) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * re register the 'write' on the selector if the throttleInterval has passed
 * @throws java.nio.channels.ClosedChannelException
 */
public void checkThrottleInterval() throws ClosedChannelException {
  final long time=System.currentTimeMillis();
  if (lastTime + throttleInterval >= time)   return;
  lastTime=time;
  byteWritten=0;
  for (  SelectableChannel selectableChannel : channels) {
    Object attachment=null;
    try {
      final SelectionKey selectionKey=selectableChannel.keyFor(selector);
      if (selectionKey != null) {
        attachment=selectionKey.attachment();
        selectableChannel.register(selector,OP_WRITE,attachment);
      }
    }
 catch (    IOException e) {
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str",e);
      try {
        if (attachment != null)         ((AbstractAttached)attachment).connector.connect();
      }
 catch (      Exception e1) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
}
Program: 91302
Project: 91302
Buggy source:
private DatagramChannel connectClient(final int port) throws IOException {
  final DatagramChannel client=DatagramChannel.open();
  final InetSocketAddress hostAddress=new InetSocketAddress(port);
  client.configureBlocking(false);
synchronized (closeables) {
    client.bind(hostAddress);
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
    client.register(selector,OP_READ);
    closeables.add(client);
  }
  return client;
}

Fixed version (ground truth):
private DatagramChannel connectClient(final int port) throws IOException {
  final DatagramChannel client=DatagramChannel.open();
  final InetSocketAddress hostAddress=new InetSocketAddress(port);
  client.configureBlocking(false);
synchronized (closeables) {
    client.bind(hostAddress);
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
    closeables.add(client);
  }
  return client;
}
Program: 91303
Project: 91303
Buggy source:
@Before public void setup() throws IOException {
  map2=newUdpSocketShmIntString(2,1234);
  try {
    Thread.sleep(500);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Before public void setup() throws IOException {
  map2=newUdpSocketShmIntString(1,1234);
  try {
    Thread.sleep(500);
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
}
Program: 91304
Project: 91304
Buggy source:
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    Thread.sleep(1000);
    System.out.println("String_Node_Str" + map2);
  }
}

Fixed version (ground truth):
@Test @Ignore public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < 1024; i++) {
    Thread.sleep(5000);
    map2.put(i * 2,"String_Node_Str");
    System.out.println("String_Node_Str" + map2);
  }
}
Program: 91306
Project: 91306
Buggy source:
/** 
 * update that are throttled are rejected.
 * @param socketChannel             the socketChannel that we will write to
 * @param modificationIterator      modificationIterator that relates to this channel
 * @param throttleMegaBytesPer100ms mega bytes per 100ms
 * @throws InterruptedException
 * @throws IOException
 */
void writeAll(@NotNull final DatagramChannel socketChannel,@NotNull final ModificationIterator modificationIterator,final long throttleMegaBytesPer100ms) throws InterruptedException, IOException {
  out.clear();
  in.clear();
  in.skip(2);
  final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
  if (!wasDataRead)   return;
  in.writeShort(0,~(in.readUnsignedShort(2)));
  out.limit((int)in.position());
  try {
    if (throttleMegaBytesPer100ms == 0) {
      socketChannel.write(out);
      return;
    }
    if (byteWritten > throttleMegaBytesPer100ms) {
      final long currentTimeMillis=System.currentTimeMillis();
      if (time + 100 <= currentTimeMillis) {
        if (LOG.isDebugEnabled())         LOG.debug("String_Node_Str");
        return;
      }
      time=currentTimeMillis;
    }
    byteWritten+=socketChannel.write(out);
  }
 catch (  IOException e) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * update that are throttled are rejected.
 * @param socketChannel             the socketChannel that we will write to
 * @param modificationIterator      modificationIterator that relates to this channel
 * @param throttleMegaBytesPer100ms mega bytes per 100ms
 * @throws InterruptedException
 * @throws IOException
 */
void writeAll(@NotNull final DatagramChannel socketChannel,@NotNull final ModificationIterator modificationIterator,final long throttleMegaBytesPer100ms) throws InterruptedException, IOException {
  out.clear();
  in.clear();
  in.skip(2);
  final boolean wasDataRead=modificationIterator.nextEntry(entryCallback);
  if (!wasDataRead)   return;
  in.writeShort(0,~(in.readUnsignedShort(2)));
  out.limit((int)in.position());
  try {
    if (throttleMegaBytesPer100ms == 0) {
      socketChannel.write(out);
      return;
    }
    if (byteWritten + out.remaining() > throttleMegaBytesPer100ms) {
      final long currentTimeMillis=System.currentTimeMillis();
      if (time + 100 > currentTimeMillis) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("String_Node_Str");
        }
        out.clear();
        in.clear();
        byteWritten=0;
        return;
      }
      time=currentTimeMillis;
    }
    byteWritten+=socketChannel.write(out);
  }
 catch (  IOException e) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str",e);
  }
}
Program: 91307
Project: 91307
Buggy source:
public void run(){
  try {
    if (details.reconnectionInterval > 0)     Thread.sleep(details.reconnectionInterval);
    final SelectableChannel socketChannel=connect();
    if (socketChannel == null)     return;
    details.closeables.add(socketChannel);
    details.pendingRegistrations.add(socketChannel);
  }
 catch (  InterruptedException e) {
  }
catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    if (details.reconnectionInterval > 0)     Thread.sleep(details.reconnectionInterval);
synchronized (details.closeables) {
      final SelectableChannel socketChannel=connect();
      if (socketChannel == null)       return;
      details.closeables.add(socketChannel);
      details.pendingRegistrations.add(socketChannel);
    }
  }
 catch (  InterruptedException e) {
  }
catch (  IOException e) {
    LOG.error("String_Node_Str",e);
  }
}
Program: 91308
Project: 91308
Buggy source:
private void onRead(final ReplicatedSharedHashMap map,final SelectionKey key,final long approxTime) throws IOException, InterruptedException {
  final SocketChannel socketChannel=(SocketChannel)key.channel();
  final Attached attached=(Attached)key.attachment();
  if (attached.entryReader.readSocketToBuffer(socketChannel) <= 0)   return;
  attached.entryReader.lastHeartBeatReceived=approxTime;
  if (attached.isHandShakingComplete())   attached.entryReader.entriesFromBuffer();
 else   doHandShaking(map,attached);
}

Fixed version (ground truth):
private void onRead(final ReplicatedSharedHashMap map,final SelectionKey key,final long approxTime) throws IOException, InterruptedException {
  final SocketChannel socketChannel=(SocketChannel)key.channel();
  final Attached attached=(Attached)key.attachment();
  if (attached.entryReader.readSocketToBuffer(socketChannel,map.identifier(),this.pendingRegistrations,connector) <= 0)   return;
  attached.entryReader.lastHeartBeatReceived=approxTime;
  if (attached.isHandShakingComplete())   attached.entryReader.entriesFromBuffer();
 else   doHandShaking(map,attached);
}
Program: 91309
Project: 91309
Buggy source:
/** 
 * reads from the socket and writes the contents to the buffer
 * @param socketChannel the  socketChannel to read from
 * @return the number of bytes read
 * @throws IOException
 */
private int readSocketToBuffer(@NotNull final SocketChannel socketChannel) throws IOException {
  compactBuffer();
  final int len=socketChannel.read(in);
  out.limit(in.position());
  return len;
}

Fixed version (ground truth):
/** 
 * reads from the socket and writes the contents to the buffer
 * @param socketChannel        the  socketChannel to read from
 * @param identifier
 * @param pendingRegistrations
 * @param connector1
 * @return the number of bytes read
 * @throws IOException
 */
private int readSocketToBuffer(@NotNull final SocketChannel socketChannel,final byte identifier,final Queue<SelectableChannel> pendingRegistrations,final Connector connector1) throws IOException {
  compactBuffer();
  try {
    final int len=socketChannel.read(in);
    out.limit(in.position());
    return len;
  }
 catch (  IOException e) {
    connector1.asyncReconnect(identifier,socketChannel.socket(),pendingRegistrations);
    throw e;
  }
}
Program: 91310
Project: 91310
Buggy source:
@Override public void close() throws IOException {
  for (  Closeable closeable : this.closeables) {
    try {
      closeable.close();
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e);
    }
  }
  closeables.clear();
  executorService.shutdownNow();
  selector.close();
}

Fixed version (ground truth):
@Override public void close() throws IOException {
synchronized (this.closeables) {
    for (    Closeable closeable : this.closeables) {
      try {
        closeable.close();
      }
 catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
  closeables.clear();
  executorService.shutdownNow();
  selector.close();
}
Program: 91311
Project: 91311
Buggy source:
/** 
 * blocks until connected
 */
SelectableChannel connect() throws IOException, InterruptedException {
  boolean success=false;
  for (; ; ) {
    final SocketChannel socketChannel=SocketChannel.open();
    try {
      socketChannel.configureBlocking(false);
      socketChannel.socket().setReuseAddress(false);
      socketChannel.socket().setSoLinger(false,0);
      socketChannel.socket().setSoTimeout(0);
      socketChannel.socket().setTcpNoDelay(true);
      details.closeables.add(socketChannel.socket());
      socketChannel.connect(details.address);
      details.closeables.add(socketChannel);
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str",details.address,details.identifier);
      success=true;
      return socketChannel;
    }
 catch (    IOException e) {
      throw e;
    }
 finally {
      if (!success)       try {
        try {
          socketChannel.socket().close();
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
        }
        socketChannel.close();
      }
 catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * blocks until connected
 */
SelectableChannel connect() throws IOException, InterruptedException {
  boolean success=false;
  for (; ; ) {
    final SocketChannel socketChannel=SocketChannel.open();
    try {
      socketChannel.configureBlocking(false);
      socketChannel.socket().setReuseAddress(false);
      socketChannel.socket().setSoLinger(false,0);
      socketChannel.socket().setSoTimeout(0);
      socketChannel.socket().setTcpNoDelay(true);
synchronized (details.closeables) {
        details.closeables.add(socketChannel.socket());
        socketChannel.connect(details.address);
        details.closeables.add(socketChannel);
      }
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str",details.address,details.identifier);
      success=true;
      return socketChannel;
    }
 catch (    IOException e) {
      throw e;
    }
 finally {
      if (!success)       try {
        try {
          socketChannel.socket().close();
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
        }
        socketChannel.close();
      }
 catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
}
Program: 91313
Project: 91313
Buggy source:
private DatagramChannel connectClient(final int port) throws IOException {
  final DatagramChannel client=DatagramChannel.open();
  final InetSocketAddress hostAddress=new InetSocketAddress(port);
  client.configureBlocking(false);
  client.bind(hostAddress);
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + port);
  closeables.add(client);
  return client;
}

Fixed version (ground truth):
private DatagramChannel connectClient(final int port) throws IOException {
  final DatagramChannel client=DatagramChannel.open();
  final InetSocketAddress hostAddress=new InetSocketAddress(port);
  client.configureBlocking(false);
synchronized (closeables) {
    client.bind(hostAddress);
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
    closeables.add(client);
  }
  return client;
}
Program: 91314
Project: 91314
Buggy source:
@Override public void close(){
  executorService.shutdownNow();
  for (  Closeable closeable : closeables) {
    try {
      closeable.close();
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  executorService.shutdownNow();
synchronized (closeables) {
    for (    Closeable closeable : closeables) {
      try {
        closeable.close();
      }
 catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
}
Program: 91315
Project: 91315
Buggy source:
SelectableChannel connect() throws IOException, InterruptedException {
  final DatagramChannel server=DatagramChannel.open();
  server.socket().setBroadcast(true);
  server.configureBlocking(false);
  try {
    server.connect(details.address);
  }
 catch (  IOException e) {
    details.reconnectionInterval=100;
    reconnect(server);
    return null;
  }
  server.setOption(StandardSocketOptions.SO_REUSEADDR,true).setOption(StandardSocketOptions.IP_MULTICAST_LOOP,false).setOption(StandardSocketOptions.SO_BROADCAST,true).setOption(StandardSocketOptions.SO_REUSEADDR,true);
  details.closeables.add(server);
  return server;
}

Fixed version (ground truth):
SelectableChannel connect() throws IOException, InterruptedException {
  final DatagramChannel server=DatagramChannel.open();
  server.socket().setBroadcast(true);
  server.configureBlocking(false);
  try {
synchronized (details.closeables) {
      server.connect(details.address);
      details.closeables.add(server);
    }
  }
 catch (  IOException e) {
    details.reconnectionInterval=100;
    reconnect(server);
    return null;
  }
  server.setOption(StandardSocketOptions.SO_REUSEADDR,true).setOption(StandardSocketOptions.IP_MULTICAST_LOOP,false).setOption(StandardSocketOptions.SO_BROADCAST,true).setOption(StandardSocketOptions.SO_REUSEADDR,true);
  return server;
}
Program: 91316
Project: 91316
Buggy source:
@Test @Ignore public void testContinueToReceive() throws IOException, InterruptedException {
  for (; ; ) {
    for (int i=0; i < 1024; i++) {
      Thread.sleep(1000);
      map1.put(i * 2,"String_Node_Str");
      System.out.println(map1);
    }
  }
}

Fixed version (ground truth):
@Test @Ignore public void testContinueToReceive() throws IOException, InterruptedException {
  for (; ; ) {
    for (int i=0; i < 1024; i++) {
      Thread.sleep(1000);
      System.out.println(map1);
    }
  }
}
Program: 91318
Project: 91318
Buggy source:
private void checkHeartbeat(SelectionKey key,final long timeOutTime,final byte identifier,final Queue<SelectableChannel> pendingRegistrations) throws ConnectException {
  final Attached attached=(Attached)key.attachment();
  if (key.channel() == serverSocketChannel || attached == null)   return;
  if (!attached.isHandShakingComplete())   return;
  final SocketChannel channel=(SocketChannel)key.channel();
  if (timeOutTime < attached.entryReader.lastHeartBeatReceived) {
    connector.asyncReconnect(identifier,channel.socket());
    throw new ConnectException("String_Node_Str" + attached.remoteIdentifier + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkHeartbeat(SelectionKey key,final long approxTimeOutTime,final byte identifier,final double timeout) throws ConnectException {
  final Attached attached=(Attached)key.attachment();
  if (key.channel() == serverSocketChannel || attached == null)   return;
  if (!attached.isHandShakingComplete())   return;
  final SocketChannel channel=(SocketChannel)key.channel();
  if (approxTimeOutTime > attached.entryReader.lastHeartBeatReceived + timeout) {
    connector.asyncReconnect(identifier,channel.socket());
    throw new ConnectException("String_Node_Str" + attached.remoteIdentifier + "String_Node_Str");
  }
}
Program: 91319
Project: 91319
Buggy source:
public static <T extends SharedHashMap<Integer,CharSequence>>T newTcpSocketShmIntString(final byte identifier,final int serverPort,final InetSocketAddress... InetSocketAddress) throws IOException {
  final TcpReplicatorBuilder tcpReplicatorBuilder=new TcpReplicatorBuilder(serverPort,InetSocketAddress).heartBeatInterval(1000);
  return (T)new SharedHashMapBuilder().entries(1000).identifier(identifier).tcpReplication(tcpReplicatorBuilder).entries(20000).create(getPersistenceFile(),Integer.class,CharSequence.class);
}

Fixed version (ground truth):
public static <T extends SharedHashMap<Integer,CharSequence>>T newTcpSocketShmIntString(final byte identifier,final int serverPort,final InetSocketAddress... InetSocketAddress) throws IOException {
  final TcpReplicatorBuilder tcpReplicatorBuilder=new TcpReplicatorBuilder(serverPort,InetSocketAddress).heartBeatInterval(100);
  return (T)new SharedHashMapBuilder().entries(1000).identifier(identifier).tcpReplication(tcpReplicatorBuilder).entries(20000).create(getPersistenceFile(),Integer.class,CharSequence.class);
}
Program: 91320
Project: 91320
Buggy source:
private void onRead(final ReplicatedSharedHashMap map,final SelectionKey key,final long approxTime) throws IOException, InterruptedException {
  final SocketChannel socketChannel=(SocketChannel)key.channel();
  final Attached attached=(Attached)key.attachment();
  if (attached.entryReader.readSocketToBuffer(socketChannel) <= 0)   return;
  if (attached.isHandShakingComplete())   attached.entryReader.entriesFromBuffer(approxTime);
 else   doHandShaking(map,attached,approxTime);
}

Fixed version (ground truth):
private void onRead(final ReplicatedSharedHashMap map,final SelectionKey key,final long approxTime) throws IOException, InterruptedException {
  final SocketChannel socketChannel=(SocketChannel)key.channel();
  final Attached attached=(Attached)key.attachment();
  if (attached.entryReader.readSocketToBuffer(socketChannel) <= 0)   return;
  attached.entryReader.lastHeartBeatReceived=approxTime;
  if (attached.isHandShakingComplete())   attached.entryReader.entriesFromBuffer();
 else   doHandShaking(map,attached,approxTime);
}
Program: 91321
Project: 91321
Buggy source:
/** 
 * reads from the socket and writes the contents to the buffer
 * @param socketChannel the  socketChannel to read from
 * @return the number of bytes read
 * @throws IOException
 */
int readSocketToBuffer(@NotNull final SocketChannel socketChannel) throws IOException {
  compactBuffer();
  final int len=socketChannel.read(in);
  out.limit(in.position());
  return len;
}

Fixed version (ground truth):
/** 
 * reads from the socket and writes the contents to the buffer
 * @param socketChannel the  socketChannel to read from
 * @return the number of bytes read
 * @throws IOException
 */
private int readSocketToBuffer(@NotNull final SocketChannel socketChannel) throws IOException {
  compactBuffer();
  final int len=socketChannel.read(in);
  out.limit(in.position());
  return len;
}
Program: 91322
Project: 91322
Buggy source:
/** 
 * reads entries from the socket till it is empty
 * @param approxTime
 * @throws InterruptedException
 */
void entriesFromBuffer(final long approxTime) throws InterruptedException {
  for (; ; ) {
    out.limit(in.position());
    if (sizeOfNextEntry == Integer.MIN_VALUE) {
      if (out.remaining() < SIZE_OF_UNSIGNED_SHORT) {
        return;
      }
      sizeOfNextEntry=out.readUnsignedShort();
    }
    if (sizeOfNextEntry == 0) {
      lastHeartBeatReceived=approxTime;
      continue;
    }
    if (out.remaining() < sizeOfNextEntry) {
      return;
    }
    final long nextEntryPos=out.position() + sizeOfNextEntry;
    final long limit=out.limit();
    out.limit(nextEntryPos);
    externalizable.readExternalEntry(out);
    out.limit(limit);
    out.position(nextEntryPos);
    sizeOfNextEntry=Integer.MIN_VALUE;
  }
}

Fixed version (ground truth):
/** 
 * reads entries from the socket till it is empty
 * @throws InterruptedException
 */
private void entriesFromBuffer() throws InterruptedException {
  for (; ; ) {
    out.limit(in.position());
    if (sizeOfNextEntry == Integer.MIN_VALUE) {
      if (out.remaining() < SIZE_OF_UNSIGNED_SHORT) {
        return;
      }
      sizeOfNextEntry=out.readUnsignedShort();
    }
    if (sizeOfNextEntry == 0)     continue;
    if (out.remaining() < sizeOfNextEntry) {
      return;
    }
    final long nextEntryPos=out.position() + sizeOfNextEntry;
    final long limit=out.limit();
    out.limit(nextEntryPos);
    externalizable.readExternalEntry(out);
    out.limit(limit);
    out.position(nextEntryPos);
    sizeOfNextEntry=Integer.MIN_VALUE;
  }
}
Program: 91323
Project: 91323
Buggy source:
/** 
 * used to exchange identifiers and timestamps between the server and client
 * @param map
 * @param attached
 * @param approxTime
 * @throws java.io.IOException
 * @throws InterruptedException
 */
private void doHandShaking(final ReplicatedSharedHashMap map,final Attached attached,final long approxTime) throws IOException, InterruptedException {
  if (attached.remoteIdentifier == Byte.MIN_VALUE) {
    final byte remoteIdentifier=attached.entryReader.identifierFromBuffer();
    if (remoteIdentifier != Byte.MIN_VALUE) {
      attached.remoteIdentifier=remoteIdentifier;
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",map.identifier(),remoteIdentifier);
      }
      if (remoteIdentifier == map.identifier())       throw new IllegalStateException("String_Node_Str" + map.identifier());
      attached.remoteModificationIterator=map.acquireModificationIterator(remoteIdentifier);
      attached.entryWriter.timestampToBuffer(map.lastModificationTime(remoteIdentifier));
    }
  }
  if (attached.remoteIdentifier != Byte.MIN_VALUE && attached.remoteTimestamp == Long.MIN_VALUE) {
    attached.remoteTimestamp=attached.entryReader.timeStampFromBuffer();
    if (attached.remoteTimestamp != Long.MIN_VALUE) {
      attached.remoteModificationIterator.dirtyEntries(attached.remoteTimestamp);
      attached.setHandShakingComplete();
      attached.entryReader.entriesFromBuffer(approxTime);
    }
  }
}

Fixed version (ground truth):
/** 
 * used to exchange identifiers and timestamps between the server and client
 * @param map
 * @param attached
 * @param approxTime
 * @throws java.io.IOException
 * @throws InterruptedException
 */
private void doHandShaking(final ReplicatedSharedHashMap map,final Attached attached,final long approxTime) throws IOException, InterruptedException {
  if (attached.remoteIdentifier == Byte.MIN_VALUE) {
    final byte remoteIdentifier=attached.entryReader.identifierFromBuffer();
    if (remoteIdentifier != Byte.MIN_VALUE) {
      attached.remoteIdentifier=remoteIdentifier;
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",map.identifier(),remoteIdentifier);
      }
      if (remoteIdentifier == map.identifier())       throw new IllegalStateException("String_Node_Str" + map.identifier());
      attached.remoteModificationIterator=map.acquireModificationIterator(remoteIdentifier);
      attached.entryWriter.timestampToBuffer(map.lastModificationTime(remoteIdentifier));
    }
  }
  if (attached.remoteIdentifier != Byte.MIN_VALUE && attached.remoteTimestamp == Long.MIN_VALUE) {
    attached.remoteTimestamp=attached.entryReader.timeStampFromBuffer();
    if (attached.remoteTimestamp != Long.MIN_VALUE) {
      attached.remoteModificationIterator.dirtyEntries(attached.remoteTimestamp);
      attached.setHandShakingComplete();
      attached.entryReader.entriesFromBuffer();
    }
  }
}
Program: 91324
Project: 91324
Buggy source:
/** 
 * @param serializedEntrySize the maximum size of an entry include the meta data
 * @param externalizable      supports reading and writing serialize entries
 * @param packetSize          the estimated size of a tcp/ip packet
 */
TcpSocketChannelEntryReader(final int serializedEntrySize,@NotNull final EntryExternalizable externalizable,final short packetSize){
  this.serializedEntrySize=serializedEntrySize;
  in=ByteBuffer.allocate(packetSize + serializedEntrySize);
  this.externalizable=externalizable;
  out=new ByteBufferBytes(in);
  out.limit(0);
  in.clear();
}

Fixed version (ground truth):
/** 
 * @param serializedEntrySize the maximum size of an entry include the meta data
 * @param externalizable      supports reading and writing serialize entries
 * @param packetSize          the estimated size of a tcp/ip packet
 */
private TcpSocketChannelEntryReader(final int serializedEntrySize,@NotNull final EntryExternalizable externalizable,final short packetSize){
  this.serializedEntrySize=serializedEntrySize;
  in=ByteBuffer.allocate(packetSize + serializedEntrySize);
  this.externalizable=externalizable;
  out=new ByteBufferBytes(in);
  out.limit(0);
  in.clear();
}
Program: 91325
Project: 91325
Buggy source:
private void checkHeartbeat(SelectionKey key,final long timeOutTime,final byte identifier,final Queue<SelectableChannel> pendingRegistrations) throws ConnectException {
  final Attached attached=(Attached)key.attachment();
  if (key.channel() == serverSocketChannel || attached == null)   return;
  final SocketChannel channel=(SocketChannel)key.channel();
  final long lastHeartBeat=attached.entryReader.lastHeartBeatReceived;
  if (timeOutTime > lastHeartBeat) {
    connector.asyncReconnect(identifier,channel.socket(),pendingRegistrations);
    throw new ConnectException("String_Node_Str" + attached.remoteIdentifier + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkHeartbeat(SelectionKey key,final long timeOutTime,final byte identifier,final Queue<SelectableChannel> pendingRegistrations) throws ConnectException {
  final Attached attached=(Attached)key.attachment();
  if (key.channel() == serverSocketChannel || attached == null)   return;
  final SocketChannel channel=(SocketChannel)key.channel();
  if (timeOutTime > attached.entryReader.lastHeartBeatReceived) {
    connector.asyncReconnect(identifier,channel.socket(),pendingRegistrations);
    throw new ConnectException("String_Node_Str" + attached.remoteIdentifier + "String_Node_Str");
  }
}
Program: 91326
Project: 91326
Buggy source:
static <T extends SharedHashMap<Integer,CharSequence>>T newTcpSocketShmIntString(final byte identifier,final int serverPort,final InetSocketAddress... InetSocketAddress) throws IOException {
  final TcpReplication tcpReplication=new TcpReplication(serverPort,InetSocketAddress).heartBeatInterval(1000);
  return (T)new SharedHashMapBuilder().entries(1000).identifier(identifier).tcpReplication(tcpReplication).create(getPersistenceFile(),Integer.class,CharSequence.class);
}

Fixed version (ground truth):
static <T extends SharedHashMap<Integer,CharSequence>>T newTcpSocketShmIntString(final byte identifier,final int serverPort,final InetSocketAddress... InetSocketAddress) throws IOException {
  final TcpReplication tcpReplication=new TcpReplication(serverPort,InetSocketAddress).heartBeatInterval(1000);
  return (T)new SharedHashMapBuilder().entries(1000).identifier(identifier).tcpReplication(tcpReplication).entries(20000).create(getPersistenceFile(),Integer.class,CharSequence.class);
}
Program: 91327
Project: 91327
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(map1,map2);
  assertTrue(!map2.isEmpty());
}

Fixed version (ground truth):
@Test public void testBufferOverflow() throws IOException, InterruptedException {
  for (int i=0; i < map1.builder().entries(); i++) {
    map1.put(i,"String_Node_Str");
  }
  waitTillEqual(5000);
  assertEquals(map1,map2);
  assertTrue(!map2.isEmpty());
}
Program: 91328
Project: 91328
Buggy source:
/** 
 * called from a remote node as part of replication
 */
private void remoteRemove(Bytes keyBytes,int hash2,final long timestamp,final byte identifier){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookupLiveAndDeleted.startSearch(hash2);
    for (int pos; (pos=hashLookupLiveAndDeleted.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      long timeStampPos=entry.position();
      if (shouldIgnore(entry,timestamp,identifier)) {
        entry.skip(1);
        return;
      }
      boolean wasDeleted=entry.readBoolean();
      if (!wasDeleted)       hashLookupLiveOnly.remove(hash2,pos);
      decrementSize();
      entry.position(timeStampPos);
      entry.writeLong(timestamp);
      if (identifier <= 0)       throw new IllegalStateException("String_Node_Str" + identifier);
      entry.writeByte(identifier);
      entry.writeBoolean(true);
    }
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * called from a remote node as part of replication
 */
private void remoteRemove(Bytes keyBytes,int hash2,final long timestamp,final byte identifier){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookupLiveAndDeleted.startSearch(hash2);
    for (int pos; (pos=hashLookupLiveAndDeleted.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      long timeStampPos=entry.position();
      if (shouldIgnore(entry,timestamp,identifier)) {
        entry.skip(1);
        return;
      }
      boolean wasDeleted=entry.readBoolean();
      if (!wasDeleted) {
        hashLookupLiveOnly.remove(hash2,pos);
        decrementSize();
      }
      entry.position(timeStampPos);
      entry.writeLong(timestamp);
      if (identifier <= 0)       throw new IllegalStateException("String_Node_Str" + identifier);
      entry.writeByte(identifier);
      entry.writeBoolean(true);
    }
  }
  finally {
    unlock();
  }
}
Program: 91329
Project: 91329
Buggy source:
public SharedHashMapBuilder identifier(byte identifier){
  if (canReplicate)   VanillaSharedReplicatedHashMap.checkIdentifier(identifier);
  this.identifier=identifier;
  return this;
}

Fixed version (ground truth):
public SharedHashMapBuilder identifier(byte identifier){
  this.identifier=identifier;
  return this;
}
Program: 91330
Project: 91330
Buggy source:
/** 
 * @see net.openhft.collections.VanillaSharedHashMap.Segment#remove(net.openhft.lang.io.Bytes,Object,Object,int)
 */
public V replace(Bytes keyBytes,K key,V expectedValue,V newValue,int hash2,long timestamp){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookupLiveOnly.startSearch(hash2);
    for (int pos; (pos=hashLookupLiveOnly.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      if (canReplicate) {
        if (shouldIgnore(entry,timestamp,localIdentifier))         return null;
        entry.skip(1);
      }
      return onKeyPresentOnReplace(key,expectedValue,newValue,pos,offset,entry);
    }
    return null;
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * @see net.openhft.collections.VanillaSharedHashMap.Segment#remove(net.openhft.lang.io.Bytes,Object,Object,int)
 */
public V replace(Bytes keyBytes,K key,V expectedValue,V newValue,int hash2,long timestamp){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookupLiveOnly.startSearch(hash2);
    for (int pos; (pos=hashLookupLiveOnly.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      if (canReplicate) {
        if (shouldIgnore(entry,timestamp,localIdentifier))         return null;
        entry.skip(1);
      }
      return onKeyPresentOnReplace(key,expectedValue,newValue,pos,offset,entry,hashLookupLiveOnly);
    }
    return null;
  }
  finally {
    unlock();
  }
}
Program: 91331
Project: 91331
Buggy source:
V put(Bytes keyBytes,K key,V value,int hash2,boolean replaceIfPresent,final byte identifier,final long timestamp){
  lock();
  try {
    IntIntMultiMap hashLookup=hashLookupLiveAndDeleted;
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    int pos;
    while ((pos=hashLookup.nextPos()) >= 0) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      final long timeStampPos=entry.positionAddr();
      boolean wasDeleted=false;
      if (canReplicate) {
        if (shouldIgnore(entry,timestamp,identifier))         return null;
        wasDeleted=entry.readBoolean();
      }
      if (replaceIfPresent || wasDeleted) {
        if (canReplicate) {
          entry.positionAddr(timeStampPos);
          entry.writeLong(timestamp);
          entry.writeByte(identifier);
          entry.writeBoolean(false);
        }
        final V prevValue=replaceValueOnPut(key,value,entry,pos,offset);
        if (wasDeleted) {
          hashLookupLiveOnly.put(hash2,pos);
          incrementSize();
          return null;
        }
 else {
          return prevValue;
        }
      }
 else {
        return putReturnsNull ? null : readValue(entry,null);
      }
    }
    long offset=putEntry(keyBytes,hash2,value,false,identifier,timestamp,hashLookup);
    incrementSize();
    notifyPut(offset,true,key,value,posFromOffset(offset));
    return null;
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
V put(Bytes keyBytes,K key,V value,int hash2,boolean replaceIfPresent,final byte identifier,final long timestamp){
  lock();
  try {
    IntIntMultiMap hashLookup=hashLookupLiveAndDeleted;
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    int pos;
    while ((pos=hashLookup.nextPos()) >= 0) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      final long timeStampPos=entry.positionAddr();
      boolean wasDeleted=false;
      if (canReplicate) {
        if (shouldIgnore(entry,timestamp,identifier))         return null;
        wasDeleted=entry.readBoolean();
      }
      if (replaceIfPresent || wasDeleted) {
        if (canReplicate) {
          entry.positionAddr(timeStampPos);
          entry.writeLong(timestamp);
          entry.writeByte(identifier);
          entry.writeBoolean(false);
        }
        final V prevValue=replaceValueOnPut(key,value,entry,pos,offset,!wasDeleted && !putReturnsNull,hashLookup);
        if (wasDeleted) {
          hashLookupLiveOnly.put(hash2,pos);
          incrementSize();
          return null;
        }
 else {
          return prevValue;
        }
      }
 else {
        return putReturnsNull ? null : readValue(entry,null);
      }
    }
    long offset=putEntry(keyBytes,hash2,value,false,identifier,timestamp,hashLookup);
    incrementSize();
    notifyPut(offset,true,key,value,posFromOffset(offset));
    return null;
  }
  finally {
    unlock();
  }
}
Program: 91333
Project: 91333
Buggy source:
@Override void replacePosInHashLookupOnRelocation(int prevPos,int pos){
  hashLookupLiveAndDeleted.replacePrevPos(pos);
  int hash=hashLookupLiveAndDeleted.getSearchHash();
  hashLookupLiveOnly.replace(hash,prevPos,pos);
}

Fixed version (ground truth):
@Override void replacePosInHashLookupOnRelocation(IntIntMultiMap searchedHashLookup,int prevPos,int pos){
  searchedHashLookup.replacePrevPos(pos);
  int hash=searchedHashLookup.getSearchHash();
  IntIntMultiMap anotherLookup=searchedHashLookup == hashLookupLiveAndDeleted ? hashLookupLiveOnly : hashLookupLiveAndDeleted;
  anotherLookup.replace(hash,prevPos,pos);
}
Program: 91334
Project: 91334
Buggy source:
V put(Bytes keyBytes,K key,V value,int hash2,boolean replaceIfPresent){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    for (int pos; (pos=hashLookup.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      if (replaceIfPresent) {
        return replaceValueOnPut(key,value,entry,pos,offset);
      }
 else {
        return putReturnsNull ? null : readValue(entry,null);
      }
    }
    long offset=putEntry(keyBytes,value,false);
    incrementSize();
    notifyPut(offset,true,key,value,posFromOffset(offset));
    return null;
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
V put(Bytes keyBytes,K key,V value,int hash2,boolean replaceIfPresent){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    for (int pos; (pos=hashLookup.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      if (replaceIfPresent) {
        return replaceValueOnPut(key,value,entry,pos,offset,!putReturnsNull,hashLookup);
      }
 else {
        return putReturnsNull ? null : readValue(entry,null);
      }
    }
    long offset=putEntry(keyBytes,value,false);
    incrementSize();
    notifyPut(offset,true,key,value,posFromOffset(offset));
    return null;
  }
  finally {
    unlock();
  }
}
Program: 91335
Project: 91335
Buggy source:
/** 
 * Replaces value in existing entry. May cause entry relocation, because there may be not enough space for new value in location already allocated for this entry.
 * @param pos             index of the first block occupied by the entry
 * @param offset          relative offset of the entry in Segment bytes(before, i. e. including metaData)
 * @param entry           relative pointer in Segment bytes
 * @param valueLenPos     relative position of value "stop bit" in entry
 * @param entryEndAddr    absolute address of the entry end
 * @param valueBytes      serialized value, or {@code null} if valueAsByteable is given
 * @param valueAsByteable the value to put as {@code Byteable}, or   {@code null} if valueBytes is given
 * @param allowOversize   {@code true} if the entry is allowed become oversizedif it was not yet
 * @return relative offset of the entry in Segment bytes after putting value(that may cause entry relocation)
 */
long putValue(int pos,long offset,NativeBytes entry,long valueLenPos,long entryEndAddr,@Nullable Bytes valueBytes,@Nullable Byteable valueAsByteable,boolean allowOversize){
}

Fixed version (ground truth):
/** 
 * Replaces value in existing entry. May cause entry relocation, because there may be not enough space for new value in location already allocated for this entry.
 * @param pos             index of the first block occupied by the entry
 * @param offset          relative offset of the entry in Segment bytes(before, i. e. including metaData)
 * @param entry           relative pointer in Segment bytes
 * @param valueLenPos     relative position of value "stop bit" in entry
 * @param entryEndAddr    absolute address of the entry end
 * @param valueBytes      serialized value, or {@code null} if valueAsByteable is given
 * @param valueAsByteable the value to put as {@code Byteable}, or   {@code null} if valueBytes is given
 * @param allowOversize   {@code true} if the entry is allowed become oversizedif it was not yet
 * @return relative offset of the entry in Segment bytes after putting value(that may cause entry relocation)
 */
long putValue(int pos,long offset,NativeBytes entry,long valueLenPos,long entryEndAddr,@Nullable Bytes valueBytes,@Nullable Byteable valueAsByteable,boolean allowOversize,IntIntMultiMap searchedHashLookup){
}
Program: 91336
Project: 91336
Buggy source:
V onKeyPresentOnReplace(K key,V expectedValue,V newValue,int pos,long offset,NativeBytes entry){
  long valueLenPos=entry.position();
  long valueLen=readValueLen(entry);
  long entryEndAddr=entry.positionAddr() + valueLen;
  V valueRead=readValue(entry,null,valueLen);
  if (valueRead == null)   return null;
  if (expectedValue == null || expectedValue.equals(valueRead)) {
    offset=putValue(pos,offset,entry,valueLenPos,entryEndAddr,newValue);
    notifyPut(offset,false,key,newValue,posFromOffset(offset));
    return valueRead;
  }
  return null;
}

Fixed version (ground truth):
V onKeyPresentOnReplace(K key,V expectedValue,V newValue,int pos,long offset,NativeBytes entry,IntIntMultiMap searchedHashLookup){
  long valueLenPos=entry.position();
  long valueLen=readValueLen(entry);
  long entryEndAddr=entry.positionAddr() + valueLen;
  V valueRead=readValue(entry,null,valueLen);
  if (valueRead == null)   return null;
  if (expectedValue == null || expectedValue.equals(valueRead)) {
    offset=putValue(pos,offset,entry,valueLenPos,entryEndAddr,newValue,searchedHashLookup);
    notifyPut(offset,false,key,newValue,posFromOffset(offset));
    return valueRead;
  }
  return null;
}
Program: 91337
Project: 91337
Buggy source:
void replacePosInHashLookupOnRelocation(int prevPos,int pos){
  hashLookup.replacePrevPos(pos);
}

Fixed version (ground truth):
void replacePosInHashLookupOnRelocation(IntIntMultiMap searchedHashLookup,int prevPos,int pos){
  searchedHashLookup.replacePrevPos(pos);
}
Program: 91338
Project: 91338
Buggy source:
/** 
 * Replaces the specified value for the key with the given value. <p/>  {@code newValue} is set only if the existing value correspondingto the specified key is equal to  {@code expectedValue}or   {@code expectedValue == null}.
 * @param hash2 a hash code related to the {@code keyBytes}
 * @return the replaced value or {@code null} if the value was not replaced
 */
V replace(Bytes keyBytes,K key,V expectedValue,V newValue,int hash2){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    for (int pos; (pos=hashLookup.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      return onKeyPresentOnReplace(key,expectedValue,newValue,pos,offset,entry);
    }
    return null;
  }
  finally {
    unlock();
  }
}

Fixed version (ground truth):
/** 
 * Replaces the specified value for the key with the given value. <p/>  {@code newValue} is set only if the existing value correspondingto the specified key is equal to  {@code expectedValue}or   {@code expectedValue == null}.
 * @param hash2 a hash code related to the {@code keyBytes}
 * @return the replaced value or {@code null} if the value was not replaced
 */
V replace(Bytes keyBytes,K key,V expectedValue,V newValue,int hash2){
  lock();
  try {
    long keyLen=keyBytes.remaining();
    hashLookup.startSearch(hash2);
    for (int pos; (pos=hashLookup.nextPos()) >= 0; ) {
      long offset=offsetFromPos(pos);
      NativeBytes entry=entry(offset);
      if (!keyEquals(keyBytes,keyLen,entry))       continue;
      entry.skip(keyLen);
      return onKeyPresentOnReplace(key,expectedValue,newValue,pos,offset,entry,hashLookup);
    }
    return null;
  }
  finally {
    unlock();
  }
}
Program: 91339
Project: 91339
Buggy source:
V replaceValueOnPut(K key,V value,NativeBytes entry,int pos,long offset){
  long valueLenPos=entry.position();
  long valueLen=readValueLen(entry);
  long entryEndAddr=entry.positionAddr() + valueLen;
  V prevValue=null;
  if (!putReturnsNull)   prevValue=readValue(entry,null,valueLen);
  offset=putValue(pos,offset,entry,valueLenPos,entryEndAddr,value);
  notifyPut(offset,false,key,value,posFromOffset(offset));
  return prevValue;
}

Fixed version (ground truth):
V replaceValueOnPut(K key,V value,NativeBytes entry,int pos,long offset,boolean readPrevValue,IntIntMultiMap searchedHashLookup){
  long valueLenPos=entry.position();
  long valueLen=readValueLen(entry);
  long entryEndAddr=entry.positionAddr() + valueLen;
  V prevValue=null;
  if (readPrevValue)   prevValue=readValue(entry,null,valueLen);
  offset=putValue(pos,offset,entry,valueLenPos,entryEndAddr,value,searchedHashLookup);
  notifyPut(offset,false,key,value,posFromOffset(offset));
  return prevValue;
}