Program: 27476
Project: 27476
Buggy source:
protected void processConnect(IoSession session,ConnectMessage msg){
  if (msg.getProcotolVersion() != 0x03) {
    ConnAckMessage badProto=new ConnAckMessage();
    badProto.setReturnCode(ConnAckMessage.UNNACEPTABLE_PROTOCOL_VERSION);
    session.write(badProto);
    session.close(false);
    return;
  }
  if (msg.getClientID() == null || msg.getClientID().length() > 23) {
    ConnAckMessage okResp=new ConnAckMessage();
    okResp.setReturnCode(ConnAckMessage.IDENTIFIER_REJECTED);
    session.write(okResp);
    return;
  }
  if (m_clientIDs.containsKey(msg.getClientID())) {
    IoSession oldSession=m_clientIDs.get(msg.getClientID()).getSession();
    boolean cleanSession=(Boolean)oldSession.getAttribute(Constants.CLEAN_SESSION);
    if (cleanSession) {
      processRemoveAllSubscriptions(msg.getClientID());
    }
    m_clientIDs.get(msg.getClientID()).getSession().close(false);
  }
  ConnectionDescriptor connDescr=new ConnectionDescriptor(msg.getClientID(),session,msg.isCleanSession());
  m_clientIDs.put(msg.getClientID(),connDescr);
  int keepAlive=msg.getKeepAlive();
  session.setAttribute("String_Node_Str",keepAlive);
  session.setAttribute(Constants.CLEAN_SESSION,msg.isCleanSession());
  session.setAttribute(Constants.ATTR_CLIENTID,msg.getClientID());
  session.getConfig().setIdleTime(IdleStatus.READER_IDLE,Math.round(keepAlive * 1.5f));
  if (msg.isWillFlag()) {
    QOSType willQos=QOSType.values()[msg.getWillQos()];
    PublishEvent pubEvt=new PublishEvent(msg.getWillTopic(),willQos,msg.getWillMessage().getBytes(),msg.isWillRetain(),msg.getClientID(),session);
    processPublish(pubEvt);
  }
  if (msg.isUserFlag()) {
    String pwd=null;
    if (msg.isPasswordFlag()) {
      pwd=msg.getPassword();
    }
    if (!m_authenticator.checkValid(msg.getUsername(),pwd)) {
      ConnAckMessage okResp=new ConnAckMessage();
      okResp.setReturnCode(ConnAckMessage.BAD_USERNAME_OR_PASSWORD);
      session.write(okResp);
      return;
    }
  }
  if (msg.isCleanSession()) {
    processRemoveAllSubscriptions(msg.getClientID());
  }
 else {
    republishStored(msg.getClientID());
  }
  ConnAckMessage okResp=new ConnAckMessage();
  okResp.setReturnCode(ConnAckMessage.CONNECTION_ACCEPTED);
  session.write(okResp);
}

Fixed version (ground truth):
protected void processConnect(IoSession session,ConnectMessage msg){
  if (msg.getProcotolVersion() != 0x03) {
    ConnAckMessage badProto=new ConnAckMessage();
    badProto.setReturnCode(ConnAckMessage.UNNACEPTABLE_PROTOCOL_VERSION);
    session.write(badProto);
    session.close(false);
    return;
  }
  if (msg.getClientID() == null || msg.getClientID().length() > 23) {
    ConnAckMessage okResp=new ConnAckMessage();
    okResp.setReturnCode(ConnAckMessage.IDENTIFIER_REJECTED);
    session.write(okResp);
    return;
  }
  if (m_clientIDs.containsKey(msg.getClientID())) {
    IoSession oldSession=m_clientIDs.get(msg.getClientID()).getSession();
    boolean cleanSession=(Boolean)oldSession.getAttribute(Constants.CLEAN_SESSION);
    if (cleanSession) {
      processRemoveAllSubscriptions(msg.getClientID());
    }
    m_clientIDs.get(msg.getClientID()).getSession().close(false);
  }
  ConnectionDescriptor connDescr=new ConnectionDescriptor(msg.getClientID(),session,msg.isCleanSession());
  m_clientIDs.put(msg.getClientID(),connDescr);
  int keepAlive=msg.getKeepAlive();
  session.setAttribute("String_Node_Str",keepAlive);
  session.setAttribute(Constants.CLEAN_SESSION,msg.isCleanSession());
  session.setAttribute(Constants.ATTR_CLIENTID,msg.getClientID());
  session.getConfig().setIdleTime(IdleStatus.READER_IDLE,Math.round(keepAlive * 1.5f));
  if (msg.isWillFlag()) {
    QOSType willQos=QOSType.values()[msg.getWillQos()];
    PublishEvent pubEvt=new PublishEvent(msg.getWillTopic(),willQos,msg.getWillMessage().getBytes(),msg.isWillRetain(),msg.getClientID(),session);
    processPublish(pubEvt);
  }
  if (msg.isUserFlag()) {
    String pwd=null;
    if (msg.isPasswordFlag()) {
      pwd=msg.getPassword();
    }
    if (!m_authenticator.checkValid(msg.getUsername(),pwd)) {
      ConnAckMessage okResp=new ConnAckMessage();
      okResp.setReturnCode(ConnAckMessage.BAD_USERNAME_OR_PASSWORD);
      session.write(okResp);
      return;
    }
  }
  subscriptions.connect(msg.getClientID());
  if (msg.isCleanSession()) {
    processRemoveAllSubscriptions(msg.getClientID());
  }
 else {
    republishStored(msg.getClientID());
  }
  ConnAckMessage okResp=new ConnAckMessage();
  okResp.setReturnCode(ConnAckMessage.CONNECTION_ACCEPTED);
  session.write(okResp);
}