Program: 94986
Project: 94986
Buggy source:
public void connect(ID targetID,IConnectContext connectContext) throws ContainerConnectException {
  if (!(targetID instanceof MSNID)) {
    throw new ContainerConnectException();
  }
  connectID=(MSNID)targetID;
  client=new MsnClient();
  ObjectCallback[] cb={new ObjectCallback()};
  try {
    connectContext.getCallbackHandler().handle(cb);
    client.addSessionListener(new ISessionListener(){
      public void sessionConnected(      ChatSession session){
        try {
          Contact contact=session.getParticipants()[0];
          final ID toID=namespace.createInstance(new Object[]{contact.getEmail(),contact.getDisplayName()});
          chatSessions.put(toID,session);
          session.addChatSessionListener(new ChatSessionListener(toID));
        }
 catch (        IDCreateException e) {
          e.printStackTrace();
        }
      }
    }
);
    client.getContactList().addContactListListener(new IContactListListener(){
      public void contactAdded(      Contact contact){
        final MSNRosterEntry entry=new MSNRosterEntry(MSNContainer.this,contact,namespace);
        for (int i=0; i < entries.size(); i++) {
          Object e=entries.get(i);
          if (e instanceof MSNRosterGroup) {
            MSNRosterGroup group=(MSNRosterGroup)e;
            if (group.getGroup().contains(contact)) {
              MSNRosterEntry check=group.getEntryFor(contact);
              if (check == null) {
                check=entry;
                contact.addContactListener(new IContactListener(){
                  public void nameChanged(                  String name){
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                  public void personalMessageChanged(                  String personalMessage){
                    entry.updatePersonalMessage();
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                  public void statusChanged(                  Status status){
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                }
);
                group.add(check);
              }
              fireRosterUpdate(group);
              fireRosterEntryAdded(check);
              return;
            }
          }
 else {
            MSNRosterEntry check=(MSNRosterEntry)e;
            if (entry.getContact().equals(check.getContact())) {
              fireRosterEntryAdded(check);
              return;
            }
          }
        }
        entries.add(entry);
        entry.setParent(MSNContainer.this);
        fireRosterEntryAdded(entry);
      }
      public void contactRemoved(      Contact contact){
        IRosterEntry entry=findEntry(entries,contact.getEmail());
        if (entry != null) {
          fireHandleUnsubscribed(entry.getUser().getID());
        }
      }
      public void contactAddedUser(      String email){
        try {
          fireHandleSubscriptionRequest(namespace.createInstance(new Object[]{email}));
        }
 catch (        IDCreateException e) {
        }
      }
      public void contactRemovedUser(      String email){
      }
      public void groupAdded(      Group group){
        entries.add(new MSNRosterGroup(MSNContainer.this,group));
      }
    }
);
    fireContainerEvent(new ContainerConnectingEvent(guid,connectID));
    client.connect(connectID.getName(),(String)cb[0].getObject());
    fireContainerEvent(new ContainerConnectedEvent(guid,connectID));
  }
 catch (  UnsupportedCallbackException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void connect(ID targetID,IConnectContext connectContext) throws ContainerConnectException {
  if (!(targetID instanceof MSNID)) {
    throw new ContainerConnectException();
  }
  connectID=(MSNID)targetID;
  client=new MsnClient();
  ObjectCallback[] cb={new ObjectCallback()};
  try {
    connectContext.getCallbackHandler().handle(cb);
    client.addSessionListener(new ISessionListener(){
      public void sessionConnected(      ChatSession session){
        try {
          Contact contact=session.getParticipants()[0];
          final ID toID=namespace.createInstance(new Object[]{contact.getEmail()});
          chatSessions.put(toID,session);
          session.addChatSessionListener(new ChatSessionListener(toID));
        }
 catch (        IDCreateException e) {
          e.printStackTrace();
        }
      }
    }
);
    client.getContactList().addContactListListener(new IContactListListener(){
      public void contactAdded(      Contact contact){
        final MSNRosterEntry entry=new MSNRosterEntry(MSNContainer.this,contact,namespace);
        for (int i=0; i < entries.size(); i++) {
          Object e=entries.get(i);
          if (e instanceof MSNRosterGroup) {
            MSNRosterGroup group=(MSNRosterGroup)e;
            if (group.getGroup().contains(contact)) {
              MSNRosterEntry check=group.getEntryFor(contact);
              if (check == null) {
                check=entry;
                contact.addContactListener(new IContactListener(){
                  public void nameChanged(                  String name){
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                  public void personalMessageChanged(                  String personalMessage){
                    entry.updatePersonalMessage();
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                  public void statusChanged(                  Status status){
                    fireRosterUpdate(entry);
                    fireRosterEntryUpdated(entry);
                  }
                }
);
                group.add(check);
              }
              fireRosterUpdate(group);
              fireRosterEntryAdded(check);
              return;
            }
          }
 else {
            MSNRosterEntry check=(MSNRosterEntry)e;
            if (entry.getContact().equals(check.getContact())) {
              fireRosterEntryAdded(check);
              return;
            }
          }
        }
        contact.addContactListener(new IContactListener(){
          public void nameChanged(          String name){
            fireRosterUpdate(entry);
            fireRosterEntryUpdated(entry);
          }
          public void personalMessageChanged(          String personalMessage){
            entry.updatePersonalMessage();
            fireRosterUpdate(entry);
            fireRosterEntryUpdated(entry);
          }
          public void statusChanged(          Status status){
            fireRosterUpdate(entry);
            fireRosterEntryUpdated(entry);
          }
        }
);
        entries.add(entry);
        entry.setParent(MSNContainer.this);
        fireRosterEntryAdded(entry);
      }
      public void contactRemoved(      Contact contact){
        IRosterEntry entry=findEntry(entries,contact.getEmail());
        if (entry != null) {
          fireHandleUnsubscribed(entry.getUser().getID());
        }
      }
      public void contactAddedUser(      String email){
        try {
          fireHandleSubscriptionRequest(namespace.createInstance(new Object[]{email}));
        }
 catch (        IDCreateException e) {
        }
      }
      public void contactRemovedUser(      String email){
      }
      public void groupAdded(      Group group){
        entries.add(new MSNRosterGroup(MSNContainer.this,group));
      }
    }
);
    fireContainerEvent(new ContainerConnectingEvent(guid,connectID));
    client.connect(connectID.getName(),(String)cb[0].getObject());
    fireContainerEvent(new ContainerConnectedEvent(guid,connectID));
  }
 catch (  UnsupportedCallbackException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}