Program: 104589
Project: 104589
Buggy source:
/** 
 * When message is received determines whether to open a new chat window or chat window tab, or to indicate that a message is received from a contact which already has an open chat. When the chat is found  shows the message in the appropriate chat panel.
 */
public void messageReceived(MessageReceivedEvent evt){
  Calendar calendar=Calendar.getInstance();
  calendar.setTime(evt.getTimestamp());
  MetaContact metaContact=mainFrame.getContactList().findMetaContactByContact(evt.getSourceContact());
  PresenceStatus contactStatus=((ContactListModel)this.contactList.getModel()).getMetaContactStatus(metaContact);
  if (!Constants.TABBED_CHAT_WINDOW) {
    if (contactMsgWindows.containsKey(metaContact)) {
      ChatWindow msgWindow=(ChatWindow)contactMsgWindows.get(metaContact);
      msgWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      if (!msgWindow.isVisible())       msgWindow.setVisible(true);
    }
 else {
      ChatWindow msgWindow=new ChatWindow(mainFrame);
      contactMsgWindows.put(metaContact,msgWindow);
      msgWindow.addChat(metaContact,contactStatus);
      msgWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      msgWindow.pack();
      msgWindow.setVisible(true);
    }
  }
 else {
    if (tabbedChatWindow == null) {
      tabbedChatWindow=new ChatWindow(mainFrame);
      tabbedChatWindow.addWindowListener(new WindowAdapter(){
        public void windowClosing(        WindowEvent e){
          tabbedChatWindow=null;
        }
      }
);
    }
    Hashtable contactTabsTable=tabbedChatWindow.getContactTabsTable();
    if (contactTabsTable.get(metaContact.getDisplayName()) == null) {
      tabbedChatWindow.addChatTab(metaContact,contactStatus);
      tabbedChatWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      if (!tabbedChatWindow.isVisible())       tabbedChatWindow.setVisible(true);
      tabbedChatWindow.getWriteMessagePanel().getEditorPane().requestFocus();
    }
 else {
      tabbedChatWindow.getChatPanel(metaContact).getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      if (!tabbedChatWindow.isVisible())       tabbedChatWindow.setVisible(true);
      tabbedChatWindow.getWriteMessagePanel().getEditorPane().requestFocus();
    }
    if (tabbedChatWindow.getTabCount() > 1) {
      tabbedChatWindow.highlightTab(metaContact);
    }
  }
  Constants.getDefaultAudio().play();
}

Fixed version (ground truth):
/** 
 * When message is received determines whether to open a new chat window or chat window tab, or to indicate that a message is received from a contact which already has an open chat. When the chat is found  shows the message in the appropriate chat panel.
 */
public void messageReceived(MessageReceivedEvent evt){
  Calendar calendar=Calendar.getInstance();
  calendar.setTime(evt.getTimestamp());
  MetaContact metaContact=mainFrame.getContactList().findMetaContactByContact(evt.getSourceContact());
  PresenceStatus contactStatus=((ContactListModel)this.contactList.getModel()).getMetaContactStatus(metaContact);
  if (!Constants.TABBED_CHAT_WINDOW) {
    if (contactMsgWindows.containsKey(metaContact)) {
      ChatWindow msgWindow=(ChatWindow)contactMsgWindows.get(metaContact);
      msgWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      msgWindow.setVisible(true);
    }
 else {
      ChatWindow msgWindow=new ChatWindow(mainFrame);
      contactMsgWindows.put(metaContact,msgWindow);
      msgWindow.addChat(metaContact,contactStatus);
      msgWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      msgWindow.pack();
      msgWindow.setVisible(true);
    }
  }
 else {
    if (tabbedChatWindow == null) {
      tabbedChatWindow=new ChatWindow(mainFrame);
      tabbedChatWindow.addWindowListener(new WindowAdapter(){
        public void windowClosing(        WindowEvent e){
          tabbedChatWindow=null;
        }
      }
);
    }
    Hashtable contactTabsTable=tabbedChatWindow.getContactTabsTable();
    if (contactTabsTable.get(metaContact.getDisplayName()) == null) {
      tabbedChatWindow.addChatTab(metaContact,contactStatus);
      tabbedChatWindow.getCurrentChatPanel().getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      tabbedChatWindow.setVisible(true);
      tabbedChatWindow.getWriteMessagePanel().getEditorPane().requestFocus();
    }
 else {
      tabbedChatWindow.getChatPanel(metaContact).getConversationPanel().processMessage(evt.getSourceContact().getDisplayName(),calendar,ChatMessage.INCOMING_MESSAGE,evt.getSourceMessage().getContent());
      tabbedChatWindow.setVisible(true);
      tabbedChatWindow.getWriteMessagePanel().getEditorPane().requestFocus();
    }
    if (tabbedChatWindow.getTabCount() > 1) {
      tabbedChatWindow.highlightTab(metaContact);
    }
  }
  Constants.getDefaultAudio().play();
}