nus-yam/ex-repair huggingface dataset:
Program: 55330
Project: 55330
Buggy source:
@Test public void testSubscriptionOnKey() throws InterruptedException {
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  YamlLogging.clientWrites=true;
  YamlLogging.clientReads=true;
  String key="String_Node_Str";
  String keyUri=NAME + "String_Node_Str" + key+ "String_Node_Str";
  BlockingQueue<String> q=new ArrayBlockingQueue<>(2);
  yamlLoggger(() -> {
    final MapView<String,String> server=clientTree.acquireMap(NAME,String.class,String.class);
    server.size();
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      Jvm.rethrow(e);
    }
    clientTree.registerSubscriber(keyUri,String.class,q::add);
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      Jvm.rethrow(e);
    }
    server.put(key,"String_Node_Str");
    server.put(key,"String_Node_Str");
  }
);
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
}

Fixed version (ground truth):
@Test(timeout=10000) public void testSubscriptionOnKey() throws InterruptedException {
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  YamlLogging.clientWrites=true;
  YamlLogging.clientReads=true;
  String key="String_Node_Str";
  String keyUri=NAME + "String_Node_Str" + key+ "String_Node_Str";
  BlockingQueue<String> q=new ArrayBlockingQueue<>(2);
  yamlLoggger(() -> {
    final MapView<String,String> server=clientTree.acquireMap(NAME,String.class,String.class);
    server.size();
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      Jvm.rethrow(e);
    }
    clientTree.registerSubscriber(keyUri,String.class,q::add);
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      Jvm.rethrow(e);
    }
    server.put(key,"String_Node_Str");
    server.put(key,"String_Node_Str");
  }
);
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
}
Program: 55331
Project: 55331
Buggy source:
/** 
 * test registerKeySubscriber before doing an operation ont the map
 */
@Test public void testKey() throws IOException, InterruptedException {
  BlockingQueue<String> q=new ArrayBlockingQueue<>(1);
  clientTree.acquireMap(NAME,String.class,String.class).registerKeySubscriber(q::add);
  Thread.sleep(1000);
  final MapView<String,String> serverMap=serverAssetTree.acquireMap(NAME,String.class,String.class);
  serverMap.put("String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
}

Fixed version (ground truth):
/** 
 * test registerKeySubscriber before doing an operation ont the map
 */
@Test(timeout=10000) public void testKey() throws IOException, InterruptedException {
  BlockingQueue<String> q=new ArrayBlockingQueue<>(1);
  clientTree.acquireMap(NAME,String.class,String.class).registerKeySubscriber(q::add);
  Thread.sleep(1000);
  final MapView<String,String> serverMap=serverAssetTree.acquireMap(NAME,String.class,String.class);
  serverMap.put("String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",q.poll(10,TimeUnit.SECONDS));
}
Program: 55332
Project: 55332
Buggy source:
@Test public void test() throws InterruptedException {
  YamlLogging.setAll(false);
  char[] chars=new char[(1 << 20) * 2];
  Arrays.fill(chars,'X');
  String data=new String(chars);
  final ConcurrentMap<String,String> map;
  final String type=System.getProperty("String_Node_Str","String_Node_Str");
  if ("String_Node_Str".equals(type)) {
    map=tree1.acquireMap(NAME,String.class,String.class);
  }
 else {
    map=tree2.acquireMap(NAME,String.class,String.class);
  }
  for (int i=0; i < 500; i++) {
    map.put("String_Node_Str" + i,data);
  }
  for (; ; ) {
    Thread.sleep(5000);
  }
}

Fixed version (ground truth):
@Test @Ignore public void test() throws InterruptedException {
  YamlLogging.setAll(false);
  char[] chars=new char[(1 << 20) * 2];
  Arrays.fill(chars,'X');
  String data=new String(chars);
  final ConcurrentMap<String,String> map;
  final String type=System.getProperty("String_Node_Str","String_Node_Str");
  if ("String_Node_Str".equals(type)) {
    map=tree1.acquireMap(NAME,String.class,String.class);
  }
 else {
    map=tree2.acquireMap(NAME,String.class,String.class);
  }
  for (int i=0; i < 500; i++) {
    map.put("String_Node_Str" + i,data);
  }
  for (; ; ) {
    Thread.sleep(5000);
  }
}
Program: 55333
Project: 55333
Buggy source:
@Test public void testValuesCollection() throws IOException {
  try (final RemoteMapSupplier<String,String> remote=new RemoteMapSupplier<>("String_Node_Str",String.class,String.class,WireType.BINARY,assetTree,"String_Node_Str")){
    final MapView<String,String> map=remote.get();
    HashMap<String,String> data=new HashMap<String,String>();
    data.put("String_Node_Str","String_Node_Str");
    data.put("String_Node_Str","String_Node_Str");
    map.putAll(data);
    assertEquals(data.size(),map.size());
    assertEquals(data.size(),map.values().size());
    Iterator<String> it=map.values().iterator();
    ArrayList<String> values=new ArrayList<String>();
    while (it.hasNext()) {
      values.add(it.next());
    }
    Collections.sort(values);
    Object[] dataValues=data.values().toArray();
    Arrays.sort(dataValues);
    assertArrayEquals(dataValues,values.toArray());
  }
 }

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testValuesCollection() throws IOException {
  try (final RemoteMapSupplier<String,String> remote=new RemoteMapSupplier<>("String_Node_Str",String.class,String.class,WireType.BINARY,assetTree,"String_Node_Str")){
    final MapView<String,String> map=remote.get();
    Map<String,String> data=new HashMap<String,String>();
    data.put("String_Node_Str","String_Node_Str");
    data.put("String_Node_Str","String_Node_Str");
    map.putAll(data);
    Utils.waitFor(() -> data.size() == map.size());
    assertEquals(data.size(),map.size());
    assertEquals(data.size(),map.values().size());
    Iterator<String> it=map.values().iterator();
    ArrayList<String> values=new ArrayList<String>();
    while (it.hasNext()) {
      values.add(it.next());
    }
    Collections.sort(values);
    Object[] dataValues=data.values().toArray();
    Arrays.sort(dataValues);
    assertArrayEquals(dataValues,values.toArray());
  }
 }
Program: 55334
Project: 55334
Buggy source:
public void onRemove0(@NotNull K key,V value,boolean replicationEven){
  if (subscriptions.hasSubscribers())   subscriptions.notifyEvent(RemovedEvent.of(assetFullName,key,value,false));
}

Fixed version (ground truth):
public void onRemove0(@NotNull K key,V value,boolean replicationEven){
  if (subscriptions.hasSubscribers())   subscriptions.notifyEvent(RemovedEvent.of(assetFullName,key,value,replicationEven));
}
Program: 55335
Project: 55335
Buggy source:
@Override public void applyReplication(@NotNull final ReplicationEntry entry){
  System.out.println("String_Node_Str");
  if (entry.isDeleted())   remove(entry);
 else   put(entry);
  System.out.println("String_Node_Str");
  setLastModificationTime(entry.identifier(),entry.bootStrapTimeStamp());
}

Fixed version (ground truth):
@Override public void applyReplication(@NotNull final ReplicationEntry entry){
  if (Jvm.isDebug())   System.out.println("String_Node_Str");
  if (entry.isDeleted())   remove(entry);
 else   put(entry);
  if (Jvm.isDebug())   System.out.println("String_Node_Str");
  setLastModificationTime(entry.identifier(),entry.bootStrapTimeStamp());
}
Program: 55336
Project: 55336
Buggy source:
/** 
 * publishes changes - this method pushes the replication events
 * @param mi     the modification iterator that notifies us of changes
 * @param remote details about the remote connection
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote){
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(new EventHandler(){
    final Bytes bytes=Bytes.elasticByteBuffer();
    final Wire wire=wireType.apply(bytes);
    @Override public boolean action() throws InvalidEventHandlerException {
      if (ReplicationHub.this.isClosed.get())       throw new InvalidEventHandlerException();
      bytes.clear();
      mi.nextEntry(e -> wire.writeDocument(false,wireOut -> wireOut.writeEventName(replicationEvent).typedMarshallable(e)));
      ReplicationHub.this.sendBytes(bytes,true);
      return true;
    }
    public HandlerPriority priority(){
      return HandlerPriority.REPLICATION;
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}

Fixed version (ground truth):
/** 
 * publishes changes - this method pushes the replication events
 * @param mi     the modification iterator that notifies us of changes
 * @param remote details about the remote connection
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote){
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(new EventHandler(){
    final Bytes bytes=Bytes.elasticByteBuffer();
    final Wire wire=wireType.apply(bytes);
    @Override public boolean action() throws InvalidEventHandlerException {
      if (ReplicationHub.this.isClosed.get())       throw new InvalidEventHandlerException();
      bytes.clear();
      mi.nextEntry(e -> wire.writeDocument(false,wireOut -> wireOut.writeEventName(replicationEvent).typedMarshallable(e)));
      ReplicationHub.this.sendBytes(bytes,false);
      return true;
    }
    public HandlerPriority priority(){
      return HandlerPriority.REPLICATION;
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}
Program: 55337
Project: 55337
Buggy source:
@Override public boolean action() throws InvalidEventHandlerException {
  if (ReplicationHub.this.isClosed.get())   throw new InvalidEventHandlerException();
  bytes.clear();
  mi.nextEntry(e -> wire.writeDocument(false,wireOut -> wireOut.writeEventName(replicationEvent).typedMarshallable(e)));
  ReplicationHub.this.sendBytes(bytes,true);
  return true;
}

Fixed version (ground truth):
@Override public boolean action() throws InvalidEventHandlerException {
  if (ReplicationHub.this.isClosed.get())   throw new InvalidEventHandlerException();
  bytes.clear();
  mi.nextEntry(e -> wire.writeDocument(false,wireOut -> wireOut.writeEventName(replicationEvent).typedMarshallable(e)));
  ReplicationHub.this.sendBytes(bytes,false);
  return true;
}
Program: 55339
Project: 55339
Buggy source:
@Ignore @Test public void test() throws InterruptedException {
  final ConcurrentMap<String,String> map;
  final String type=System.getProperty("String_Node_Str","String_Node_Str");
  if ("String_Node_Str".equals(type)) {
    map=tree1.acquireMap(NAME,String.class,String.class);
  }
 else {
    map=tree2.acquireMap(NAME,String.class,String.class);
  }
  map.put(type,type);
  for (; ; ) {
    System.out.println(map.entrySet().toString());
    Thread.sleep(5000);
  }
}

Fixed version (ground truth):
@Ignore @Test public void test() throws InterruptedException {
  YamlLogging.setAll(false);
  char[] chars=new char[1048576 * 2];
  Arrays.fill(chars,'X');
  String data=new String(chars);
  final ConcurrentMap<String,String> map;
  final String type=System.getProperty("String_Node_Str","String_Node_Str");
  if ("String_Node_Str".equals(type)) {
    map=tree1.acquireMap(NAME,String.class,String.class);
  }
 else {
    map=tree2.acquireMap(NAME,String.class,String.class);
  }
  for (int i=0; i < 50; i++) {
    map.put("String_Node_Str" + i,data);
  }
  for (; ; ) {
    Thread.sleep(5000);
  }
}
Program: 55340
Project: 55340
Buggy source:
/** 
 * publishes changes - this method pushes the replication events
 * @param mi               the modification iterator that notifies us of changes
 * @param remote           details about the remote connection
 * @param localIdentifier  the identifier of this host or client
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote,byte localIdentifier){
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(() -> {
    try {
      if (isClosed.get())       throw new InvalidEventHandlerException();
      hub.lock(() -> mi.forEach(e -> {
        if (e.identifier() != localIdentifier)         return;
        sendEventAsyncWithoutLock(replicationEvent,new Consumer<ValueOut>(){
          @Override public void accept(          ValueOut v){
            v.typedMarshallable(e);
          }
        }
);
      }
));
      return true;
    }
 catch (    IORuntimeException e) {
      LOG.error(e.getMessage());
      throw new InvalidEventHandlerException();
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}

Fixed version (ground truth):
/** 
 * publishes changes - this method pushes the replication events
 * @param mi               the modification iterator that notifies us of changes
 * @param remote           details about the remote connection
 * @param localIdentifier  the identifier of this host or client
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote,byte localIdentifier){
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(() -> {
    try {
      if (isClosed.get())       throw new InvalidEventHandlerException();
      hub.lock(() -> mi.forEach(e -> {
        sendEventAsyncWithoutLock(replicationEvent,new Consumer<ValueOut>(){
          @Override public void accept(          ValueOut v){
            v.typedMarshallable(e);
          }
        }
);
      }
));
      return true;
    }
 catch (    IORuntimeException e) {
      LOG.error(e.getMessage());
      throw new InvalidEventHandlerException();
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}
Program: 55341
Project: 55341
Buggy source:
@BeforeClass public static void before() throws IOException {
  YamlLogging.clientWrites=true;
  YamlLogging.clientReads=true;
  ClassAliasPool.CLASS_ALIASES.addAlias(ChronicleMapGroupFS.class);
  ClassAliasPool.CLASS_ALIASES.addAlias(FilePerKeyGroupFS.class);
  Files.deleteIfExists(Paths.get(OS.TARGET,NAME));
  TCPRegistry.createServerSocketChannelFor("String_Node_Str","String_Node_Str");
  WireType writeType=WireType.TEXT;
  tree1=create(1,writeType,"String_Node_Str");
  serverEndpoint1=new ServerEndpoint("String_Node_Str",tree1,writeType);
  tree2=create(2,writeType,"String_Node_Str");
  serverEndpoint2=new ServerEndpoint("String_Node_Str",tree2,writeType);
}

Fixed version (ground truth):
@BeforeClass public static void before() throws IOException {
  YamlLogging.clientWrites=true;
  YamlLogging.clientReads=true;
  ClassAliasPool.CLASS_ALIASES.addAlias(ChronicleMapGroupFS.class);
  ClassAliasPool.CLASS_ALIASES.addAlias(FilePerKeyGroupFS.class);
  Files.deleteIfExists(Paths.get(OS.TARGET,NAME));
  TCPRegistry.createServerSocketChannelFor("String_Node_Str","String_Node_Str","String_Node_Str");
  WireType writeType=WireType.TEXT;
  tree1=create(1,writeType,"String_Node_Str");
  serverEndpoint1=new ServerEndpoint("String_Node_Str",tree1,writeType);
  tree2=create(2,writeType,"String_Node_Str");
  serverEndpoint2=new ServerEndpoint("String_Node_Str",tree2,writeType);
}
Program: 55342
Project: 55342
Buggy source:
@Test public void testCheckDataIsLoadedFromPersistedFile() throws InterruptedException, IOException {
  final Path basePath=Files.createTempDirectory("String_Node_Str");
  ConcurrentMap<String,String> map1=tree1.acquireMap(NAME + "String_Node_Str" + basePath,String.class,String.class);
  assertNotNull(map1);
  map1.put("String_Node_Str","String_Node_Str");
  serverEndpoint1.close();
  tree1.close();
  tree1=create(1,WireType.TEXT,"String_Node_Str");
  serverEndpoint1=new ServerEndpoint("String_Node_Str",tree1,WireType.TEXT);
  ConcurrentMap<String,String> map1a=tree1.acquireMap(NAME + "String_Node_Str" + basePath,String.class,String.class);
  assertNotNull(map1a);
  Thread.sleep(100);
  Assert.assertEquals(1,map1a.size());
}

Fixed version (ground truth):
@Test public void testCheckDataIsLoadedFromPersistedFile() throws InterruptedException, IOException {
  final Path basePath=Files.createTempDirectory("String_Node_Str");
  ConcurrentMap<String,String> map1=tree1.acquireMap(NAME + "String_Node_Str" + "String_Node_Str"+ basePath,String.class,String.class);
  assertNotNull(map1);
  map1.put("String_Node_Str","String_Node_Str");
  Thread.sleep(100);
  serverEndpoint1.close();
  tree1.close();
  tree1=create(1,WireType.TEXT,"String_Node_Str");
  serverEndpoint1=new ServerEndpoint("String_Node_Str",tree1,WireType.TEXT);
  ConcurrentMap<String,String> map1a=tree1.acquireMap(NAME + "String_Node_Str" + "String_Node_Str"+ basePath,String.class,String.class);
  assertNotNull(map1a);
  Thread.sleep(100);
  Assert.assertEquals(1,map1a.size());
}
Program: 55343
Project: 55343
Buggy source:
@NotNull private net.openhft.lang.io.Bytes toLangBytes(@NotNull BytesStore b){
  if (b.underlyingObject() == null)   return wrap(b.address(b.start()),b.readRemaining());
 else {
    ByteBuffer buffer=(ByteBuffer)b.underlyingObject();
    IByteBufferBytes wrap=ByteBufferBytes.wrap(buffer);
    wrap.limit((int)b.readLimit());
    return wrap;
  }
}

Fixed version (ground truth):
@NotNull private net.openhft.lang.io.Bytes toLangBytes(@NotNull BytesStore b){
  if (b.underlyingObject() == null)   return wrap(b.address(b.start()),b.readRemaining());
 else {
    ByteBuffer buffer=ByteBuffer.wrap((byte[])b.underlyingObject());
    IByteBufferBytes wrap=ByteBufferBytes.wrap(buffer);
    wrap.limit((int)b.readLimit());
    return wrap;
  }
}
Program: 55344
Project: 55344
Buggy source:
/** 
 * @param key                the key of the entry
 * @param value              the value of the entry
 * @param timestamp          the timestamp send from the remote server, this time stamp wasthe time the entry was removed
 * @param identifier         the identifier of the remote server
 * @param bootStrapTimeStamp sent to the client on every update this is the timestamp thatthe remote client should bootstrap from when there has been a
 * @param remoteIdentifier   the identifier of the server we are sending data to ( only used as a comment )
 */
VanillaReplicatedEntry(@NotNull final BytesStore key,@Nullable final BytesStore value,final long timestamp,final byte identifier,final boolean isDeleted,final long bootStrapTimeStamp,byte remoteIdentifier){
}

Fixed version (ground truth):
/** 
 * @param key                the key of the entry
 * @param value              the value of the entry
 * @param timestamp          the timestamp send from the remote server, this time stamp wasthe time the entry was removed
 * @param identifier         the identifier of the remote server
 * @param bootStrapTimeStamp sent to the client on every update this is the timestamp thatthe remote client should bootstrap from when there has been a
 * @param remoteIdentifier   the identifier of the server we are sending data to ( only usedas a comment )
 */
VanillaReplicatedEntry(@NotNull final BytesStore key,@Nullable final BytesStore value,final long timestamp,final byte identifier,final boolean isDeleted,final long bootStrapTimeStamp,byte remoteIdentifier){
}
Program: 55345
Project: 55345
Buggy source:
/** 
 * because we have set System.setProperty("Throttler.maxEventsPreSecond", "1"); in the static above, we will only get one event per second, this test also checks that the messages still arrive in order.
 * @throws IOException
 * @throws InterruptedException
 */
@Test public void testReceivingThrottledEventsInOrder() throws IOException, InterruptedException {
  final BlockingQueue<String> eventsQueue=new LinkedBlockingDeque<>();
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  yamlLoggger(() -> {
    try {
      Subscriber<String> add=eventsQueue::add;
      assetTree.registerSubscriber(NAME,String.class,add);
      Thread.sleep(1000);
      for (int i=0; i < 10; i++) {
        serverMap.put("String_Node_Str" + i,"String_Node_Str" + i);
      }
      final long start=System.currentTimeMillis();
      for (int i=0; i < 10; i++) {
        String actual=eventsQueue.poll(2,SECONDS);
        Assert.assertNotNull(actual);
        Assert.assertEquals("String_Node_Str" + i,actual);
      }
      Assert.assertTrue(System.currentTimeMillis() > start + TimeUnit.SECONDS.toMillis(5));
    }
 catch (    Exception e) {
      throw Jvm.rethrow(e);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * because we have set System.setProperty("Throttler.maxEventsPreSecond", "1"); in the static above, we will only get one event per second, this test also checks that the messages still arrive in order.
 * @throws IOException
 * @throws InterruptedException
 */
@Test public void testReceivingThrottledEventsInOrder() throws IOException, InterruptedException {
  final BlockingQueue<String> eventsQueue=new LinkedBlockingDeque<>();
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  yamlLoggger(() -> {
    try {
      Subscriber<String> queue=eventsQueue::add;
      assetTree.registerSubscriber(NAME,String.class,queue);
      Thread.sleep(1000);
      for (int i=0; i < 10; i++) {
        serverMap.put("String_Node_Str" + i,"String_Node_Str" + i);
      }
      final long start=System.currentTimeMillis();
      for (int i=0; i < 10; i++) {
        String actual=eventsQueue.poll(2,SECONDS);
        Assert.assertNotNull(actual);
        Assert.assertEquals("String_Node_Str" + i,actual);
      }
      Assert.assertTrue(System.currentTimeMillis() > start + TimeUnit.SECONDS.toMillis(5));
    }
 catch (    Exception e) {
      throw Jvm.rethrow(e);
    }
  }
);
}
Program: 55346
Project: 55346
Buggy source:
/** 
 * the transaction id are generated as unique timestamps
 * @param timeMs in milliseconds
 * @return a unique transactionId
 */
public long nextUniqueTransaction(long timeMs){
  long id=timeMs;
  for (; ; ) {
    long old=transactionID.get();
    if (old == id)     id=old + 1;
    if (transactionID.compareAndSet(old,id))     break;
  }
  return id;
}

Fixed version (ground truth):
/** 
 * the transaction id are generated as unique timestamps
 * @param timeMs in milliseconds
 * @return a unique transactionId
 */
public long nextUniqueTransaction(long timeMs){
  long id=timeMs;
  for (; ; ) {
    long old=transactionID.get();
    if (old >= id)     id=old + 1;
    if (transactionID.compareAndSet(old,id))     break;
  }
  return id;
}
Program: 55347
Project: 55347
Buggy source:
@Deprecated default void registerKeySubscriber(@NotNull RequestContext rc,@NotNull Subscriber<K> subscriber){
  registerKeySubscriber(rc,subscriber,Filter.EMPTY);
}

Fixed version (ground truth):
@Deprecated default void registerKeySubscriber(@NotNull RequestContext rc,@NotNull Subscriber<K> subscriber){
  registerKeySubscriber(rc,subscriber,Filter.empty());
}
Program: 55348
Project: 55348
Buggy source:
/** 
 * because we have set System.setProperty("Throttler.maxEventsPreSecond", "1"); in the static above, we will only get one event per second, this test also checks that the messages still arrive in order.
 * @throws IOException
 * @throws InterruptedException
 */
@Test public void testReceivingThrottledEventsInOrder() throws IOException, InterruptedException {
  final BlockingQueue<String> eventsQueue=new LinkedBlockingDeque<>();
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  yamlLoggger(() -> {
    try {
      Subscriber<String> add=eventsQueue::add;
      assetTree.registerSubscriber(NAME,String.class,add);
      for (int i=0; i < 10; i++) {
        map.put("String_Node_Str" + i,"String_Node_Str" + i);
      }
      final long start=System.currentTimeMillis();
      for (int i=0; i < 10; i++) {
        String actual=eventsQueue.poll(2,SECONDS);
        Assert.assertNotNull(actual);
        Assert.assertEquals("String_Node_Str" + i,actual);
      }
      Assert.assertTrue(System.currentTimeMillis() > start + TimeUnit.SECONDS.toMillis(5));
    }
 catch (    Exception e) {
      throw Jvm.rethrow(e);
    }
  }
);
  System.setProperty("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * because we have set System.setProperty("Throttler.maxEventsPreSecond", "1"); in the static above, we will only get one event per second, this test also checks that the messages still arrive in order.
 * @throws IOException
 * @throws InterruptedException
 */
@Test public void testReceivingThrottledEventsInOrder() throws IOException, InterruptedException {
  final BlockingQueue<String> eventsQueue=new LinkedBlockingDeque<>();
  YamlLogging.showServerWrites=true;
  YamlLogging.showServerReads=true;
  yamlLoggger(() -> {
    try {
      Subscriber<String> add=eventsQueue::add;
      assetTree.registerSubscriber(NAME,String.class,add);
      for (int i=0; i < 10; i++) {
        map.put("String_Node_Str" + i,"String_Node_Str" + i);
      }
      final long start=System.currentTimeMillis();
      for (int i=0; i < 10; i++) {
        String actual=eventsQueue.poll(2,SECONDS);
        Assert.assertNotNull(actual);
        Assert.assertEquals("String_Node_Str" + i,actual);
      }
      Assert.assertTrue(System.currentTimeMillis() > start + TimeUnit.SECONDS.toMillis(5));
    }
 catch (    Exception e) {
      throw Jvm.rethrow(e);
    }
  }
);
}
Program: 55349
Project: 55349
Buggy source:
@Before public void before() throws IOException {
  serverAssetTree=new VanillaAssetTree().forTesting();
  methodName(name.getMethodName());
  final String hostPort="String_Node_Str" + name.getMethodName() + "String_Node_Str";
  TCPRegistry.createServerSocketChannelFor(hostPort);
  serverEndpoint=new ServerEndpoint(hostPort,serverAssetTree,WIRE_TYPE);
  assetTree=new VanillaAssetTree().forRemoteAccess(hostPort,WIRE_TYPE);
  map=assetTree.acquireMap(NAME,String.class,String.class);
}

Fixed version (ground truth):
@Before public void before() throws IOException {
  System.setProperty("String_Node_Str","String_Node_Str");
  serverAssetTree=new VanillaAssetTree().forTesting();
  methodName(name.getMethodName());
  final String hostPort="String_Node_Str" + name.getMethodName() + "String_Node_Str";
  TCPRegistry.createServerSocketChannelFor(hostPort);
  serverEndpoint=new ServerEndpoint(hostPort,serverAssetTree,WIRE_TYPE);
  assetTree=new VanillaAssetTree().forRemoteAccess(hostPort,WIRE_TYPE);
  map=assetTree.acquireMap(NAME,String.class,String.class);
}
Program: 55350
Project: 55350
Buggy source:
@After public void after() throws IOException {
  assetTree.close();
  if (serverEndpoint != null)   serverEndpoint.close();
  serverAssetTree.close();
  if (map instanceof Closeable)   ((Closeable)map).close();
  TCPRegistry.assertAllServersStopped();
  TCPRegistry.reset();
}

Fixed version (ground truth):
@After public void after() throws IOException {
  assetTree.close();
  if (serverEndpoint != null)   serverEndpoint.close();
  serverAssetTree.close();
  if (map instanceof Closeable)   ((Closeable)map).close();
  TCPRegistry.assertAllServersStopped();
  TCPRegistry.reset();
  System.setProperty("String_Node_Str","String_Node_Str");
}
Program: 55351
Project: 55351
Buggy source:
/** 
 * publishes changes - this method pushes the replication events
 * @param mi               the modification iterator that notifies us of changes
 * @param remote           details about the remote connection
 * @param localIdentifier  the identifier of this host or client
 * @param remoteIdentifier @throws InterruptedException
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote,byte localIdentifier,byte remoteIdentifier) throws InterruptedException {
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(new EventHandler(){
    @Override public boolean action() throws InvalidEventHandlerException {
      try {
        if (isClosed.get())         throw new InvalidEventHandlerException();
        hub.lock(() -> mi.forEach(e -> {
          if (e.identifier() != localIdentifier)           return;
          sendEventAsyncWithoutLock(replicationEvent,v -> v.typedMarshallable(e));
        }
));
        return true;
      }
 catch (      IORuntimeException e) {
        LOG.error(e.getMessage());
        throw new InvalidEventHandlerException();
      }
    }
    @NotNull @Override public HandlerPriority priority(){
      return HandlerPriority.MEDIUM;
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}

Fixed version (ground truth):
/** 
 * publishes changes - this method pushes the replication events
 * @param mi               the modification iterator that notifies us of changes
 * @param remote           details about the remote connection
 * @param localIdentifier  the identifier of this host or client
 */
private void publish(@NotNull final ModificationIterator mi,@NotNull final Bootstrap remote,byte localIdentifier) throws InterruptedException {
  final TcpChannelHub hub=this.hub;
  mi.setModificationNotifier(eventLoop::unpause);
  eventLoop.addHandler(new EventHandler(){
    @Override public boolean action() throws InvalidEventHandlerException {
      try {
        if (isClosed.get())         throw new InvalidEventHandlerException();
        hub.lock(() -> mi.forEach(e -> {
          if (e.identifier() != localIdentifier)           return;
          sendEventAsyncWithoutLock(replicationEvent,(Consumer<ValueOut>)v -> v.typedMarshallable(e));
        }
));
        return true;
      }
 catch (      IORuntimeException e) {
        LOG.error(e.getMessage());
        throw new InvalidEventHandlerException();
      }
    }
    @NotNull @Override public HandlerPriority priority(){
      return HandlerPriority.MEDIUM;
    }
  }
);
  mi.dirtyEntries(remote.lastUpdatedTime());
}
Program: 55352
Project: 55352
Buggy source:
@Override public boolean action() throws InvalidEventHandlerException {
  try {
    if (isClosed.get())     throw new InvalidEventHandlerException();
    hub.lock(() -> mi.forEach(e -> {
      if (e.identifier() != localIdentifier)       return;
      sendEventAsyncWithoutLock(replicationEvent,v -> v.typedMarshallable(e));
    }
));
    return true;
  }
 catch (  IORuntimeException e) {
    LOG.error(e.getMessage());
    throw new InvalidEventHandlerException();
  }
}

Fixed version (ground truth):
@Override public boolean action() throws InvalidEventHandlerException {
  try {
    if (isClosed.get())     throw new InvalidEventHandlerException();
    hub.lock(() -> mi.forEach(e -> {
      if (e.identifier() != localIdentifier)       return;
      sendEventAsyncWithoutLock(replicationEvent,(Consumer<ValueOut>)v -> v.typedMarshallable(e));
    }
));
    return true;
  }
 catch (  IORuntimeException e) {
    LOG.error(e.getMessage());
    throw new InvalidEventHandlerException();
  }
}
Program: 55353
Project: 55353
Buggy source:
public void bootstrap(@NotNull EngineReplication replication,byte localIdentifier,byte remoteIdentifier) throws InterruptedException {
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    @NotNull WireOut wireOut){
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str" + localIdentifier + "String_Node_Str"+ "String_Node_Str"+ remoteIdentifier);
      wireOut.writeEventName(identifier).marshallable(WriteMarshallable.EMPTY).writeComment(toString() + "String_Node_Str" + hub.toString()+ "String_Node_Str");
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        byte remoteIdentifier=d.read(identifierReply).int8();
        onConnected(localIdentifier,remoteIdentifier,replication);
      }
);
    }
    @NotNull @Override public String toString(){
      return "String_Node_Str" + localIdentifier + "String_Node_Str"+ remoteIdentifier+ "String_Node_Str";
    }
  }
);
}

Fixed version (ground truth):
public void bootstrap(@NotNull EngineReplication replication,byte localIdentifier,byte remoteIdentifier){
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    @NotNull WireOut wireOut){
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str" + localIdentifier + "String_Node_Str"+ "String_Node_Str"+ remoteIdentifier);
      wireOut.writeEventName(identifier).marshallable(WriteMarshallable.EMPTY).writeComment(toString() + "String_Node_Str" + hub.toString()+ "String_Node_Str");
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        byte remoteIdentifier=d.read(identifierReply).int8();
        onConnected(localIdentifier,remoteIdentifier,replication);
      }
);
    }
    @NotNull @Override public String toString(){
      return "String_Node_Str" + localIdentifier + "String_Node_Str"+ remoteIdentifier+ "String_Node_Str";
    }
  }
);
}
Program: 55354
Project: 55354
Buggy source:
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException {
  StringBuilder clusterName=new StringBuilder();
  while (wire.hasMore()) {
    wire.readEventName(clusterName).marshallable(host -> {
      Cluster cluster=clusterMap.computeIfAbsent(clusterName.toString(),Cluster::new);
      cluster.readMarshallable(host);
    }
);
  }
}

Fixed version (ground truth):
@Override public void readMarshallable(@NotNull WireIn wire) throws IllegalStateException {
  StringBuilder clusterName=Wires.acquireStringBuilder();
  while (wire.hasMore()) {
    wire.readEventName(clusterName).marshallable(host -> {
      Cluster cluster=clusterMap.computeIfAbsent(clusterName.toString(),Cluster::new);
      cluster.readMarshallable(host);
    }
);
  }
}
Program: 55356
Project: 55356
Buggy source:
@Override public void onSubscribe(@NotNull final WireOut wireOut){
  wireOut.writeEventName(replicationSubscribe).int8(localIdentifier);
}

Fixed version (ground truth):
@Override public void onSubscribe(@NotNull final WireOut wireOut){
  wireOut.writeEventName(replicationSubscribe).int8(localIdentifier).writeComment("String_Node_Str" + remoteIdentifier);
}
Program: 55357
Project: 55357
Buggy source:
/** 
 * subscribes to updates
 * @param replication     the event will be applied to the EngineReplication
 * @param localIdentifier our local identifier
 */
private void subscribe(@NotNull final EngineReplication replication,final byte localIdentifier){
  hub.subscribe(new AbstractAsyncTemporarySubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    @NotNull final WireOut wireOut){
      wireOut.writeEventName(replicationSubscribe).int8(localIdentifier);
    }
    @Override public void onConsumer(    @NotNull final WireIn d){
      d.readDocument(null,w -> replication.applyReplication(w.read(replicationReply).typedMarshallable()));
    }
  }
);
}

Fixed version (ground truth):
/** 
 * subscribes to updates
 * @param replication     the event will be applied to the EngineReplication
 * @param localIdentifier our local identifier
 */
private void subscribe(@NotNull final EngineReplication replication,final byte localIdentifier,final byte remoteIdentifier){
  hub.subscribe(new AbstractAsyncTemporarySubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    @NotNull final WireOut wireOut){
      wireOut.writeEventName(replicationSubscribe).int8(localIdentifier).writeComment("String_Node_Str" + remoteIdentifier);
    }
    @Override public void onConsumer(    @NotNull final WireIn d){
      d.readDocument(null,w -> replication.applyReplication(w.read(replicationReply).typedMarshallable()));
    }
  }
);
}
Program: 55358
Project: 55358
Buggy source:
public void bootstrap(@NotNull EngineReplication replication,byte localIdentifier,byte remoteIdentifier) throws InterruptedException {
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    WireOut wireOut){
      wireOut.writeEventName(identifier).marshallable(WriteMarshallable.EMPTY);
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        byte remoteIdentifier=d.read(identifierReply).int8();
        onConnected(localIdentifier,remoteIdentifier,replication);
      }
);
    }
  }
);
}

Fixed version (ground truth):
public void bootstrap(@NotNull EngineReplication replication,byte localIdentifier,byte remoteIdentifier) throws InterruptedException {
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str"){
    @Override public void onSubscribe(    WireOut wireOut){
      wireOut.writeEventName(identifier).marshallable(WriteMarshallable.EMPTY).writeComment(toString() + "String_Node_Str" + hub.toString()+ "String_Node_Str");
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        byte remoteIdentifier=d.read(identifierReply).int8();
        onConnected(localIdentifier,remoteIdentifier,replication);
      }
);
    }
    @Override public String toString(){
      return "String_Node_Str" + localIdentifier + "String_Node_Str"+ remoteIdentifier+ "String_Node_Str";
    }
  }
);
}
Program: 55359
Project: 55359
Buggy source:
/** 
 * called when the connection is established to the remote host, if the connection to the remote host is lost and re-established this method is called again each time the connection is establish.
 * @param localIdentifier  the identifier of this host
 * @param remoteIdentifier the identifier of the remote host
 * @param replication      the instance the handles the replication
 */
private void onConnected(final byte localIdentifier,byte remoteIdentifier,EngineReplication replication){
  final ModificationIterator mi=replication.acquireModificationIterator(remoteIdentifier);
  final long lastModificationTime=replication.lastModificationTime(remoteIdentifier);
  final Bootstrap bootstrap=new Bootstrap();
  bootstrap.lastUpdatedTime(lastModificationTime);
  bootstrap.identifier(localIdentifier);
  subscribe(replication,localIdentifier);
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str" + "String_Node_Str"){
    @Override public void onSubscribe(    WireOut wireOut){
      wireOut.writeEventName(MapWireHandler.EventId.bootstrap).typedMarshallable(bootstrap);
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        Bootstrap b=d.read(bootstrapReply).typedMarshallable();
        try {
          publish(mi,b,localIdentifier,remoteIdentifier);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * called when the connection is established to the remote host, if the connection to the remote host is lost and re-established this method is called again each time the connection is establish.
 * @param localIdentifier  the identifier of this host
 * @param remoteIdentifier the identifier of the remote host
 * @param replication      the instance the handles the replication
 */
private void onConnected(final byte localIdentifier,byte remoteIdentifier,EngineReplication replication){
  final ModificationIterator mi=replication.acquireModificationIterator(remoteIdentifier);
  final long lastModificationTime=replication.lastModificationTime(remoteIdentifier);
  final Bootstrap bootstrap=new Bootstrap();
  bootstrap.lastUpdatedTime(lastModificationTime);
  bootstrap.identifier(localIdentifier);
  subscribe(replication,localIdentifier,remoteIdentifier);
  hub.subscribe(new AbstractAsyncSubscription(hub,csp,localIdentifier,"String_Node_Str" + "String_Node_Str"){
    @Override public void onSubscribe(    WireOut wireOut){
      wireOut.writeEventName(MapWireHandler.EventId.bootstrap).typedMarshallable(bootstrap);
    }
    @Override public void onConsumer(    @NotNull WireIn inWire){
      inWire.readDocument(null,d -> {
        Bootstrap b=d.read(bootstrapReply).typedMarshallable();
        try {
          publish(mi,b,localIdentifier,remoteIdentifier);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",e);
        }
      }
);
    }
  }
);
}
Program: 55360
Project: 55360
Buggy source:
void unregisterSubscriber0(Subscriber subscriber){
  Long tid=subscribersToTid.get(subscriber);
  if (tid == null) {
    AbstractRemoteSubscription.LOG.warn("String_Node_Str");
    return;
  }
  hub.checkConnection();
  hub.outBytesLock().lock();
  try {
    writeMetaDataForKnownTID(tid);
    hub.outWire().writeDocument(false,wireOut -> {
      wireOut.writeEventName(unregisterSubscriber).text("String_Node_Str");
    }
);
    try {
      hub.writeSocket(hub.outWire());
    }
 catch (    IORuntimeException e) {
    }
  }
  finally {
    hub.outBytesLock().unlock();
  }
}

Fixed version (ground truth):
void unregisterSubscriber0(Subscriber subscriber){
  Long tid=subscribersToTid.get(subscriber);
  if (tid == null) {
    AbstractRemoteSubscription.LOG.warn("String_Node_Str");
    return;
  }
  hub.lock(() -> {
    writeMetaDataForKnownTID(tid);
    hub.outWire().writeDocument(false,wireOut -> {
      wireOut.writeEventName(unregisterSubscriber).text("String_Node_Str");
    }
);
  }
);
}
Program: 55361
Project: 55361
Buggy source:
public <A>void asyncUpdate(SerializableUpdaterWithArg updateFunction,A arg){
  sendEventAsync(update2,toParameters(update2,updateFunction,arg));
}

Fixed version (ground truth):
public <A>void asyncUpdate(SerializableUpdaterWithArg updateFunction,A arg){
  sendEventAsync(update2,toParameters(update2,updateFunction,arg),true);
}
Program: 55362
Project: 55362
Buggy source:
public boolean remove(Object key){
  checkKey(key);
  sendEventAsync(remove,toParameters(remove,key));
  return false;
}

Fixed version (ground truth):
public boolean remove(Object key){
  checkKey(key);
  sendEventAsync(remove,toParameters(remove,key),true);
  return false;
}
Program: 55363
Project: 55363
Buggy source:
public boolean put(K key,V value){
  checkKey(key);
  checkValue(value);
  sendEventAsync(put,toParameters(put,key,value));
  return false;
}

Fixed version (ground truth):
public boolean put(K key,V value){
  checkKey(key);
  checkValue(value);
  sendEventAsync(put,toParameters(put,key,value),true);
  return false;
}
Program: 55364
Project: 55364
Buggy source:
@Override public void set(final E event){
  checkEvent(event);
  sendEventAsync(set,valueOut -> valueOut.object(event));
}

Fixed version (ground truth):
@Override public void set(final E event){
  checkEvent(event);
  sendEventAsync(set,valueOut -> valueOut.object(event),true);
}
Program: 55365
Project: 55365
Buggy source:
@Override public void unregisterSubscriber(Subscriber<E> subscriber){
  Long subscriberTid=subscribersToTid.remove(subscriber);
  if (subscriberTid != null) {
    sendEventAsync(unregisterSubscriber,valueOut -> valueOut.int64(subscriberTid));
  }
 else   LOG.warn("String_Node_Str");
}

Fixed version (ground truth):
@Override public void unregisterSubscriber(Subscriber<E> subscriber){
  Long subscriberTid=subscribersToTid.remove(subscriber);
  if (subscriberTid != null) {
    sendEventAsync(unregisterSubscriber,valueOut -> valueOut.int64(subscriberTid),false);
  }
 else   LOG.warn("String_Node_Str");
}
Program: 55366
Project: 55366
Buggy source:
@Override public <T>void asyncUpdate(@NotNull SerializableBiFunction<E,T,E> updateFunction,T argument){
  sendEventAsync(update2,toParameters(update2,updateFunction,argument));
}

Fixed version (ground truth):
@Override public <T>void asyncUpdate(@NotNull SerializableBiFunction<E,T,E> updateFunction,T argument){
  sendEventAsync(update2,toParameters(update2,updateFunction,argument),true);
}
Program: 55367
Project: 55367
Buggy source:
@Override public void remove(){
  sendEventAsync(remove,null);
}

Fixed version (ground truth):
@Override public void remove(){
  sendEventAsync(remove,null,true);
}
Program: 55368
Project: 55368
Buggy source:
@Override public void publish(final T topic,final M message){
  checkTopic(topic);
  checkMessage(message);
  sendEventAsync(publish,valueOut -> valueOut.marshallable(m -> {
    m.write(Params.topic).object(topic);
    m.write(Params.message).object(message);
  }
));
}

Fixed version (ground truth):
@Override public void publish(final T topic,final M message){
  checkTopic(topic);
  checkMessage(message);
  sendEventAsync(publish,valueOut -> valueOut.marshallable(m -> {
    m.write(Params.topic).object(topic);
    m.write(Params.message).object(message);
  }
),true);
}
Program: 55369
Project: 55369
Buggy source:
protected <R>R readReply(@NotNull WireIn wireIn,@NotNull WireKey replyId,@NotNull Function<ValueIn,R> function){
  final ValueIn event=wireIn.read(eventName);
  if (replyId.contentEquals(eventName))   return function.apply(event);
  if (CoreFields.exception.contentEquals(eventName)) {
    throw Jvm.rethrow(event.throwable(true));
  }
  throw new UnsupportedOperationException("String_Node_Str" + eventName);
}

Fixed version (ground truth):
protected <R>R readReply(@NotNull WireIn wireIn,@NotNull WireKey replyId,@NotNull Function<ValueIn,R> function){
  StringBuilder eventName=Wires.acquireStringBuilder();
  final ValueIn event=wireIn.read(eventName);
  if (replyId.contentEquals(eventName))   return function.apply(event);
  if (CoreFields.exception.contentEquals(eventName)) {
    throw Jvm.rethrow(event.throwable(true));
  }
  throw new UnsupportedOperationException("String_Node_Str" + eventName);
}
Program: 55370
Project: 55370
Buggy source:
protected void readReplyConsumer(@NotNull WireIn wireIn,@NotNull WireKey replyId,@NotNull Consumer<ValueIn> consumer){
  final ValueIn event=wireIn.read(eventName);
  if (replyId.contentEquals(eventName)) {
    consumer.accept(event);
    return;
  }
  if (CoreFields.exception.contentEquals(eventName)) {
    throw Jvm.rethrow(event.throwable(true));
  }
  throw new UnsupportedOperationException("String_Node_Str" + eventName);
}

Fixed version (ground truth):
protected void readReplyConsumer(@NotNull WireIn wireIn,@NotNull WireKey replyId,@NotNull Consumer<ValueIn> consumer){
  StringBuilder eventName=Wires.acquireStringBuilder();
  final ValueIn event=wireIn.read(eventName);
  if (replyId.contentEquals(eventName)) {
    consumer.accept(event);
    return;
  }
  if (CoreFields.exception.contentEquals(eventName)) {
    throw Jvm.rethrow(event.throwable(true));
  }
  throw new UnsupportedOperationException("String_Node_Str" + eventName);
}
Program: 55371
Project: 55371
Buggy source:
protected void sendEventAsync(@NotNull final WireKey eventId,@Nullable final Consumer<ValueOut> consumer){
  hub.checkConnection();
  hub.outBytesLock().lock();
  try {
    sendEventAsyncWithoutLock(eventId,consumer);
  }
 catch (  IORuntimeException e) {
  }
 finally {
    hub.outBytesLock().unlock();
  }
}

Fixed version (ground truth):
/** 
 * @param eventId
 * @param consumer
 * @param blockTillTimeout if false - will only be sent if the connection is valid
 */
protected void sendEventAsync(@NotNull final WireKey eventId,@Nullable final Consumer<ValueOut> consumer,boolean blockTillTimeout){
  if (blockTillTimeout)   hub.checkConnection();
 else   if (!hub.isOpen())   return;
  hub.outBytesLock().lock();
  try {
    sendEventAsyncWithoutLock(eventId,consumer);
  }
 catch (  IORuntimeException e) {
  }
 finally {
    hub.outBytesLock().unlock();
  }
}