Program: 95042
Project: 95042
Buggy source:
protected void doJoin(final String target,final String key){
  CTabItem item=getTabItem(target);
  if (item != null) {
    tabFolder.setSelection(item);
    return;
  }
  IChatRoomInfo roomInfo=chatRoomManager.getChatRoomInfo(target);
  if (roomInfo == null)   return;
 else {
    try {
      final IChatRoomContainer chatRoomContainer=roomInfo.createChatRoomContainer();
      final ChatRoom chatroomview=new ChatRoom(chatRoomContainer,new Manager(tabFolder,target));
      chatRoomContainer.addMessageListener(new IIMMessageListener(){
        public void handleMessageEvent(        IIMMessageEvent messageEvent){
          if (messageEvent instanceof IChatRoomMessageEvent) {
            IChatRoomMessage m=((IChatRoomMessageEvent)messageEvent).getChatRoomMessage();
            chatroomview.handleMessage(m.getFromID(),m.getMessage());
          }
        }
      }
);
      chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener(){
        public void handlePresence(        ID fromID,        IPresence presence){
          chatroomview.handlePresence(fromID,presence);
        }
        public void handleArrivedInChat(        ID participant){
          chatroomview.handleJoin(participant);
        }
        public void handleDepartedFromChat(        ID participant){
          chatroomview.handleLeave(participant);
        }
      }
);
      chatRoomContainer.addListener(new IContainerListener(){
        public void handleEvent(        IContainerEvent evt){
          if (evt instanceof IContainerDisconnectedEvent) {
            chatroomview.disconnected();
          }
        }
      }
);
      Display.getDefault().asyncExec(new Runnable(){
        public void run(){
          try {
            chatRoomContainer.connect(IDFactory.getDefault().createID(chatRoomContainer.getConnectNamespace(),target),ConnectContextFactory.createPasswordConnectContext(key));
          }
 catch (          Exception e) {
          }
        }
      }
);
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
protected void doJoin(final String target,final String key){
  ChatRoom room=(ChatRoom)rooms.get(target);
  if (room != null && room.isConnected()) {
    room.setSelected();
    return;
  }
  IChatRoomInfo roomInfo=chatRoomManager.getChatRoomInfo(target);
  if (roomInfo == null)   return;
 else {
    try {
      final IChatRoomContainer chatRoomContainer=roomInfo.createChatRoomContainer();
      final ChatRoom chatroomview=new ChatRoom(chatRoomContainer,new Manager(tabFolder,target));
      chatRoomContainer.addMessageListener(new IIMMessageListener(){
        public void handleMessageEvent(        IIMMessageEvent messageEvent){
          if (messageEvent instanceof IChatRoomMessageEvent) {
            IChatRoomMessage m=((IChatRoomMessageEvent)messageEvent).getChatRoomMessage();
            chatroomview.handleMessage(m.getFromID(),m.getMessage());
          }
        }
      }
);
      chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener(){
        public void handlePresence(        ID fromID,        IPresence presence){
          chatroomview.handlePresence(fromID,presence);
        }
        public void handleArrivedInChat(        ID participant){
          chatroomview.handleJoin(participant);
        }
        public void handleDepartedFromChat(        ID participant){
          chatroomview.handleLeave(participant);
        }
      }
);
      chatRoomContainer.addListener(new IContainerListener(){
        public void handleEvent(        IContainerEvent evt){
          if (evt instanceof IContainerDisconnectedEvent) {
            chatroomview.disconnected();
          }
        }
      }
);
      Display.getDefault().asyncExec(new Runnable(){
        public void run(){
          try {
            chatRoomContainer.connect(IDFactory.getDefault().createID(chatRoomContainer.getConnectNamespace(),target),ConnectContextFactory.createPasswordConnectContext(key));
            rooms.put(target,chatroomview);
          }
 catch (          Exception e) {
            e.printStackTrace();
          }
        }
      }
);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}