Program: 41061
Project: 41061
Buggy source:
@Test(timeout=20000) public void testRemotelyCloseProducerAndAttemptAsyncCompletionSendThrowsAndLeavesMessageReadable() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    JmsConnection connection=(JmsConnection)testFixture.establishConnecton(testPeer);
    final CountDownLatch producerClosed=new CountDownLatch(1);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onProducerClosed(      MessageProducer producer,      Throwable cause){
        producerClosed.countDown();
      }
    }
);
    testPeer.expectBegin();
    testPeer.expectSenderAttach();
    testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true,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",producerClosed.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 testRemotelyCloseProducerAndAttemptAsyncCompletionSendThrowsAndLeavesMessageReadable() throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    JmsConnection connection=(JmsConnection)testFixture.establishConnecton(testPeer);
    final CountDownLatch producerClosed=new CountDownLatch(1);
    connection.addConnectionListener(new JmsDefaultConnectionListener(){
      @Override public void onProducerClosed(      MessageProducer producer,      Throwable cause){
        producerClosed.countDown();
      }
    }
);
    testPeer.expectBegin();
    testPeer.expectSenderAttach();
    testPeer.remotelyDetachLastOpenedLinkOnLastOpenedSession(true,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",producerClosed.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);
  }
 }