Program: 27466
Project: 27466
Buggy source:
@Test public void testPublishOfRetainedMessage_afterNewSubscription() throws Exception {
  m_session=new DummyChannel(){
    @Override public void write(    Object value){
      try {
        System.out.println("String_Node_Str" + value.getClass().getName());
        if (value instanceof PublishMessage) {
          m_receivedMessage=(AbstractMessage)value;
        }
        if (m_receivedMessage instanceof ConnAckMessage) {
          ConnAckMessage buf=(ConnAckMessage)m_receivedMessage;
          m_returnCode=buf.getReturnCode();
        }
      }
 catch (      Exception ex) {
        throw new AssertionError("String_Node_Str");
      }
    }
  }
;
  final Subscription subscription=new Subscription(FAKE_CLIENT_ID,FAKE_TOPIC,AbstractMessage.QOSType.MOST_ONE,true);
  SubscriptionsStore subs=new SubscriptionsStore(){
    @Override public List<Subscription> matches(    String topic){
      if (topic.equals(FAKE_TOPIC)) {
        return Arrays.asList(subscription);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + FAKE_TOPIC + "String_Node_Str"+ topic);
      }
    }
  }
;
  subs.init(new MemoryStorageService());
  m_processor.init(subs,m_storageService);
  ConnectMessage connectMessage=new ConnectMessage();
  connectMessage.setClientID(FAKE_CLIENT_ID);
  connectMessage.setProcotolVersion((byte)3);
  connectMessage.setCleanSession(subscription.isCleanSession());
  m_processor.processConnect(m_session,connectMessage);
  ByteBuffer buffer=ByteBuffer.allocate(5).put("String_Node_Str".getBytes());
  PublishEvent pubEvt=new PublishEvent(FAKE_TOPIC,AbstractMessage.QOSType.MOST_ONE,buffer,true,"String_Node_Str",null);
  m_processor.processPublish(pubEvt);
  SubscribeMessage msg=new SubscribeMessage();
  msg.addSubscription(new SubscribeMessage.Couple((byte)QOSType.MOST_ONE.ordinal(),"String_Node_Str"));
  m_processor.processSubscribe(m_session,msg,FAKE_CLIENT_ID,false);
  assertNotNull(m_receivedMessage);
  assertTrue(m_receivedMessage instanceof PublishMessage);
  PublishMessage pubMessage=(PublishMessage)m_receivedMessage;
  assertEquals(FAKE_TOPIC,pubMessage.getTopicName());
}

Fixed version (ground truth):
@Test public void testPublishOfRetainedMessage_afterNewSubscription() throws Exception {
  m_session=new DummyChannel(){
    @Override public void write(    Object value){
      try {
        System.out.println("String_Node_Str" + value.getClass().getName());
        if (value instanceof PublishMessage) {
          m_receivedMessage=(AbstractMessage)value;
        }
        if (m_receivedMessage instanceof ConnAckMessage) {
          ConnAckMessage buf=(ConnAckMessage)m_receivedMessage;
          m_returnCode=buf.getReturnCode();
        }
      }
 catch (      Exception ex) {
        throw new AssertionError("String_Node_Str");
      }
    }
  }
;
  final Subscription subscription=new Subscription(FAKE_PUBLISHER_ID,FAKE_TOPIC,AbstractMessage.QOSType.MOST_ONE,true);
  SubscriptionsStore subs=new SubscriptionsStore(){
    @Override public List<Subscription> matches(    String topic){
      if (topic.equals(FAKE_TOPIC)) {
        return Arrays.asList(subscription);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + FAKE_TOPIC + "String_Node_Str"+ topic);
      }
    }
  }
;
  subs.init(new MemoryStorageService());
  m_processor.init(subs,m_storageService);
  ConnectMessage connectMessage=new ConnectMessage();
  connectMessage.setClientID(FAKE_PUBLISHER_ID);
  connectMessage.setProcotolVersion((byte)3);
  connectMessage.setCleanSession(subscription.isCleanSession());
  m_processor.processConnect(m_session,connectMessage);
  ByteBuffer buffer=ByteBuffer.allocate(5).put("String_Node_Str".getBytes());
  PublishEvent pubEvt=new PublishEvent(FAKE_TOPIC,AbstractMessage.QOSType.MOST_ONE,buffer,true,"String_Node_Str",null);
  m_processor.processPublish(pubEvt);
  SubscribeMessage msg=new SubscribeMessage();
  msg.addSubscription(new SubscribeMessage.Couple((byte)QOSType.MOST_ONE.ordinal(),"String_Node_Str"));
  m_processor.processSubscribe(m_session,msg,FAKE_PUBLISHER_ID,false);
  assertNotNull(m_receivedMessage);
  assertTrue(m_receivedMessage instanceof PublishMessage);
  PublishMessage pubMessage=(PublishMessage)m_receivedMessage;
  assertEquals(FAKE_TOPIC,pubMessage.getTopicName());
}