Program: 41598
Project: 41598
Buggy source:
@Test(timeout=20000) public void testRemotelyCloseSessionAndAttemptAsyncCompletionSendThrowsAndLeavesMessageReadable() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    JmsConnection connection=(JmsConnection)testFixture.establishConnecton(testPeer);
    final CountDownLatch sessionClosed=new CountDownLatch(1);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onSessionClosed(      Session session,      Throwable cause){
        sessionClosed.countDown();
      }
    }
);
    testPeer.expectBegin();
    testPeer.expectSenderAttach();
    testPeer.remotelyEndLastOpenedSession(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    MessageProducer producer=session.createProducer(queue);
    Message message=session.createTextMessage("String_Node_Str");
    message.setIntProperty("String_Node_Str",1);
    assertNull("String_Node_Str",message.getJMSDestination());
    testPeer.waitForAllHandlersToComplete(100);
    assertTrue("String_Node_Str",sessionClosed.await(2,TimeUnit.SECONDS));
    TestJmsCompletionListener listener=new TestJmsCompletionListener();
    try {
      producer.send(message,listener);
      fail("String_Node_Str");
    }
 catch (    JMSException e) {
      LOG.warn("String_Node_Str",e.getMessage());
    }
    assertFalse("String_Node_Str",listener.awaitCompletion(5,TimeUnit.MILLISECONDS));
    assertNull("String_Node_Str",message.getJMSDestination());
    assertEquals("String_Node_Str","String_Node_Str",((TextMessage)message).getText());
    assertEquals("String_Node_Str",1,message.getIntProperty("String_Node_Str"));
    testPeer.expectClose();
    connection.close();
    testPeer.waitForAllHandlersToComplete(2000);
  }
 }

Fixed version (ground truth):
@Test(timeout=20000) public void testRemotelyCloseSessionAndAttemptAsyncCompletionSendThrowsAndLeavesMessageReadable() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    JmsConnection connection=(JmsConnection)testFixture.establishConnecton(testPeer);
    final CountDownLatch sessionClosed=new CountDownLatch(1);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onSessionClosed(      Session session,      Throwable cause){
        sessionClosed.countDown();
      }
    }
);
    testPeer.expectBegin();
    testPeer.expectSenderAttach();
    testPeer.remotelyEndLastOpenedSession(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    Message message=session.createTextMessage("String_Node_Str");
    message.setIntProperty("String_Node_Str",1);
    assertNull("String_Node_Str",message.getJMSDestination());
    MessageProducer producer=session.createProducer(queue);
    testPeer.waitForAllHandlersToComplete(100);
    assertTrue("String_Node_Str",sessionClosed.await(2,TimeUnit.SECONDS));
    TestJmsCompletionListener listener=new TestJmsCompletionListener();
    try {
      producer.send(message,listener);
      fail("String_Node_Str");
    }
 catch (    JMSException e) {
      LOG.trace("String_Node_Str",e.getMessage());
    }
    assertFalse("String_Node_Str",listener.awaitCompletion(5,TimeUnit.MILLISECONDS));
    assertNull("String_Node_Str",message.getJMSDestination());
    assertEquals("String_Node_Str","String_Node_Str",((TextMessage)message).getText());
    assertEquals("String_Node_Str",1,message.getIntProperty("String_Node_Str"));
    testPeer.expectClose();
    connection.close();
    testPeer.waitForAllHandlersToComplete(2000);
  }
 }