Program: 41606
Project: 41606
Buggy source:
@Test(timeout=20000) public void testFailoverHandlesDropAfterQueueBrowserDrain() throws Exception {
  try (TestAmqpPeer originalPeer=new TestAmqpPeer();TestAmqpPeer finalPeer=new TestAmqpPeer()){
    final CountDownLatch originalConnected=new CountDownLatch(1);
    final CountDownLatch finalConnected=new CountDownLatch(1);
    final String originalURI=createPeerURI(originalPeer);
    final String finalURI=createPeerURI(finalPeer);
    LOG.info("String_Node_Str",originalURI);
    LOG.info("String_Node_Str",finalURI);
    originalPeer.expectSaslAnonymousConnect();
    originalPeer.expectBegin();
    final JmsConnection connection=establishAnonymousConnecton(originalPeer,finalPeer);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onConnectionEstablished(      URI remoteURI){
        LOG.info("String_Node_Str",remoteURI);
        if (originalURI.equals(remoteURI.toString())) {
          originalConnected.countDown();
        }
      }
      @Override public void onConnectionRestored(      URI remoteURI){
        LOG.info("String_Node_Str",remoteURI);
        if (finalURI.equals(remoteURI.toString())) {
          finalConnected.countDown();
        }
      }
    }
);
    connection.start();
    assertTrue("String_Node_Str",originalConnected.await(5,TimeUnit.SECONDS));
    originalPeer.expectBegin();
    originalPeer.expectQueueBrowserAttach();
    originalPeer.expectLinkFlow();
    originalPeer.expectLinkFlowThenDrop();
    finalPeer.expectSaslAnonymousConnect();
    finalPeer.expectBegin();
    finalPeer.expectBegin();
    finalPeer.expectQueueBrowserAttach();
    finalPeer.expectLinkFlow();
    finalPeer.expectLinkFlow(true,true,equalTo(UnsignedInteger.valueOf(1)));
    finalPeer.expectDetach(true,true,true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    QueueBrowser browser=session.createBrowser(queue);
    Enumeration<?> queueView=browser.getEnumeration();
    assertNotNull(queueView);
    assertFalse(queueView.hasMoreElements());
    browser.close();
  }
 }

Fixed version (ground truth):
@Test(timeout=20000) public void testFailoverHandlesDropAfterQueueBrowserDrain() throws Exception {
  try (TestAmqpPeer originalPeer=new TestAmqpPeer();TestAmqpPeer finalPeer=new TestAmqpPeer()){
    final CountDownLatch originalConnected=new CountDownLatch(1);
    final CountDownLatch finalConnected=new CountDownLatch(1);
    final String originalURI=createPeerURI(originalPeer);
    final String finalURI=createPeerURI(finalPeer);
    LOG.info("String_Node_Str",originalURI);
    LOG.info("String_Node_Str",finalURI);
    originalPeer.expectSaslAnonymousConnect();
    originalPeer.expectBegin();
    final JmsConnection connection=establishAnonymousConnecton(originalPeer,finalPeer);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onConnectionEstablished(      URI remoteURI){
        LOG.info("String_Node_Str",remoteURI);
        if (originalURI.equals(remoteURI.toString())) {
          originalConnected.countDown();
        }
      }
      @Override public void onConnectionRestored(      URI remoteURI){
        LOG.info("String_Node_Str",remoteURI);
        if (finalURI.equals(remoteURI.toString())) {
          finalConnected.countDown();
        }
      }
    }
);
    connection.start();
    assertTrue("String_Node_Str",originalConnected.await(5,TimeUnit.SECONDS));
    originalPeer.expectBegin();
    originalPeer.expectQueueBrowserAttach();
    originalPeer.expectLinkFlow();
    originalPeer.expectLinkFlowThenDrop();
    finalPeer.expectSaslAnonymousConnect();
    finalPeer.expectBegin();
    finalPeer.expectBegin();
    finalPeer.expectQueueBrowserAttach();
    finalPeer.expectLinkFlow();
    finalPeer.expectLinkFlow(true,true,equalTo(UnsignedInteger.valueOf(JmsPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH)));
    finalPeer.expectDetach(true,true,true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    QueueBrowser browser=session.createBrowser(queue);
    Enumeration<?> queueView=browser.getEnumeration();
    assertNotNull(queueView);
    assertFalse(queueView.hasMoreElements());
    browser.close();
  }
 }