Program: 104377
Project: 104377
Buggy source:
/** 
 * Implements the <tt>LocalUserChatRoomPresenceListener.localUserPresenceChanged</tt> method.
 */
public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt){
  ChatRoom sourceChatRoom=evt.getChatRoom();
  ChatRoomsList chatRoomsList=mainFrame.getChatRoomsListPanel().getChatRoomsList();
  ChatRoomWrapper chatRoomWrapper=chatRoomsList.findChatRoomWrapperFromChatRoom(sourceChatRoom);
  if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED)) {
    if (chatRoomWrapper != null) {
      chatRoomsList.refresh();
      ConferenceChatPanel chatPanel=(ConferenceChatPanel)chatWindowManager.getMultiChat(chatRoomWrapper);
      if (chatWindowManager.isChatOpenedForChatRoom(chatRoomWrapper)) {
        chatPanel.loadChatRoom(sourceChatRoom);
      }
 else {
        chatWindowManager.openChat(chatPanel,true);
      }
      chatPanel.updateChatRoomStatus(Constants.ONLINE_STATUS);
    }
    if (sourceChatRoom.isSystem()) {
      MultiUserChatServerWrapper serverWrapper=chatRoomsList.findServerWrapperFromProvider(sourceChatRoom.getParentProvider());
      serverWrapper.setSystemRoom(sourceChatRoom);
    }
    sourceChatRoom.addMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOIN_FAILED)) {
    new ErrorDialog(mainFrame,Messages.getI18NString("String_Node_Str",new String[]{sourceChatRoom.getName()}).getText() + evt.getReason(),Messages.getI18NString("String_Node_Str").getText()).showDialog();
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
}

Fixed version (ground truth):
/** 
 * Implements the <tt>LocalUserChatRoomPresenceListener.localUserPresenceChanged</tt> method.
 */
public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt){
  ChatRoom sourceChatRoom=evt.getChatRoom();
  ChatRoomsList chatRoomsList=mainFrame.getChatRoomsListPanel().getChatRoomsList();
  ChatRoomWrapper chatRoomWrapper=chatRoomsList.findChatRoomWrapperFromChatRoom(sourceChatRoom);
  if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED)) {
    if (chatRoomWrapper != null) {
      chatRoomsList.refresh();
      ConferenceChatPanel chatPanel=(ConferenceChatPanel)chatWindowManager.getMultiChat(chatRoomWrapper);
      if (chatWindowManager.isChatOpenedForChatRoom(chatRoomWrapper)) {
        chatPanel.loadChatRoom(sourceChatRoom);
      }
 else {
        chatWindowManager.openChat(chatPanel,true);
      }
      chatPanel.updateChatRoomStatus(Constants.ONLINE_STATUS);
    }
    if (sourceChatRoom.isSystem()) {
      MultiUserChatServerWrapper serverWrapper=chatRoomsList.findServerWrapperFromProvider(sourceChatRoom.getParentProvider());
      serverWrapper.setSystemRoom(sourceChatRoom);
    }
    sourceChatRoom.addMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOIN_FAILED)) {
    new ErrorDialog(mainFrame,Messages.getI18NString("String_Node_Str").getText(),Messages.getI18NString("String_Node_Str",new String[]{sourceChatRoom.getName()}).getText() + evt.getReason()).showDialog();
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
 else   if (evt.getEventType().equals(LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED)) {
    this.closeChatRoom(chatRoomWrapper);
    mainFrame.getChatRoomsListPanel().getChatRoomsList().refresh();
    sourceChatRoom.removeMessageListener(this);
  }
}