Program: 95235
Project: 95235
Buggy source:
protected void setupPresenceContainer(final ISharedObjectContainer container,IPresenceContainer pc,final ID localUser,final String nick){
  messageSender=pc.getMessageSender();
  presenceSender=pc.getPresenceSender();
  accountManager=pc.getAccountManager();
  Display.getDefault().syncExec(new Runnable(){
    public void run(){
      try {
        IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage wp=ww.getActivePage();
        IViewPart view=wp.showView("String_Node_Str");
        rosterView=(RosterView)view;
        String nickname=null;
        if (nick != null) {
          nickname=nick;
        }
 else {
          String name=localUser.getName();
          nickname=name.substring(0,name.indexOf("String_Node_Str"));
        }
        rosterView.setLocalUser(new org.eclipse.ecf.core.user.User(localUser,nickname),new ILocalInputHandler(){
          public void inputText(          ID userID,          String text){
            messageSender.sendMessage(localUser,userID,null,null,text);
          }
          public void startTyping(          ID userID){
          }
          public void disconnect(){
            container.leaveGroup();
          }
          public void updatePresence(          ID userID,          IPresence presence){
            presenceSender.sendPresenceUpdate(localUser,userID,presence);
          }
          public void sendRosterAdd(          String user,          String name,          String[] groups){
            presenceSender.sendRosterAdd(localUser,user,name,groups);
          }
          public void sendRosterRemove(          ID userID){
            presenceSender.sendRosterRemove(localUser,userID);
          }
        }
);
      }
 catch (      Exception e) {
        IStatus status=new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"String_Node_Str",e);
        ClientPlugin.getDefault().getLog().log(status);
      }
    }
  }
);
  pc.addMessageListener(new IMessageListener(){
    public void handleMessage(    final ID fromID,    final ID toID,    final Type type,    final String subject,    final String message){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handleMessage(fromID,toID,type,subject,message);
        }
      }
);
    }
  }
);
  pc.addPresenceListener(new IPresenceListener(){
    public void handleContainerJoined(    final ID joinedContainer){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.setGroup(joinedContainer);
        }
      }
);
    }
    public void handleRosterEntry(    final IRosterEntry entry){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handleRosterEntry(entry);
        }
      }
);
    }
    public void handlePresence(    final ID fromID,    final IPresence presence){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handlePresence(fromID,presence);
        }
      }
);
    }
    public void handleContainerDeparted(    final ID departedContainer){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          if (rosterView != null) {
            rosterView.memberDeparted(departedContainer);
          }
        }
      }
);
      messageSender=null;
      rosterView=null;
    }
  }
);
  pc.addSubscribeListener(new ISubscribeListener(){
    public void handleSubscribeRequest(    final ID fromID,    IPresence presence){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          try {
            IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            ReceiveAuthorizeRequestDialog authRequest=new ReceiveAuthorizeRequestDialog(ww.getShell(),fromID.getName(),localUser.getName());
            authRequest.setBlockOnOpen(true);
            authRequest.open();
            int res=authRequest.getButtonPressed();
            if (res == ReceiveAuthorizeRequestDialog.AUTHORIZE_AND_ADD) {
              if (presenceSender != null) {
                presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.SUBSCRIBED));
                if (rosterView != null) {
                  String[] groupNames=rosterView.getGroupNames();
                  List g=Arrays.asList(groupNames);
                  String selectedGroup=rosterView.getSelectedGroupName();
                  int selected=(selectedGroup == null) ? -1 : g.indexOf(selectedGroup);
                  AddBuddyDialog sg=new AddBuddyDialog(ww.getShell(),fromID.getName(),groupNames,selected);
                  sg.open();
                  if (sg.getReturnCode() == Window.OK) {
                    String group=sg.getGroup();
                    String user=sg.getUser();
                    String nickname=sg.getNickname();
                    sg.close();
                    if (!g.contains(group)) {
                      rosterView.addGroup(group);
                    }
                    presenceSender.sendRosterAdd(localUser,user,nickname,new String[]{group});
                  }
                }
              }
            }
 else             if (res == ReceiveAuthorizeRequestDialog.AUTHORIZE_ID) {
              if (presenceSender != null) {
                presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.SUBSCRIBED));
              }
            }
 else             if (res == ReceiveAuthorizeRequestDialog.REFUSE_ID) {
              System.out.println("String_Node_Str");
            }
 else {
              System.out.println("String_Node_Str");
            }
          }
 catch (          Exception e) {
            IStatus status=new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"String_Node_Str",e);
            ClientPlugin.getDefault().getLog().log(status);
          }
        }
      }
);
    }
    public void handleUnsubscribeRequest(    ID fromID,    IPresence presence){
      System.out.println("String_Node_Str" + fromID);
      if (presenceSender != null) {
        presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.UNSUBSCRIBED));
      }
    }
    public void handleSubscribed(    ID fromID,    IPresence presence){
      System.out.println("String_Node_Str" + fromID);
    }
    public void handleUnsubscribed(    ID fromID,    IPresence presence){
      System.out.println("String_Node_Str" + fromID);
    }
  }
);
}

Fixed version (ground truth):
protected void setupPresenceContainer(final ISharedObjectContainer container,IPresenceContainer pc,final ID localUser,final String nick){
  messageSender=pc.getMessageSender();
  presenceSender=pc.getPresenceSender();
  accountManager=pc.getAccountManager();
  Display.getDefault().syncExec(new Runnable(){
    public void run(){
      try {
        IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage wp=ww.getActivePage();
        IViewPart view=wp.showView("String_Node_Str");
        rosterView=(RosterView)view;
        String nickname=null;
        if (nick != null) {
          nickname=nick;
        }
 else {
          String name=localUser.getName();
          nickname=name.substring(0,name.indexOf("String_Node_Str"));
        }
        rosterView.setLocalUser(new org.eclipse.ecf.core.user.User(localUser,nickname),new ILocalInputHandler(){
          public void inputText(          ID userID,          String text){
            messageSender.sendMessage(localUser,userID,null,null,text);
          }
          public void startTyping(          ID userID){
          }
          public void disconnect(){
            container.leaveGroup();
          }
          public void updatePresence(          ID userID,          IPresence presence){
            presenceSender.sendPresenceUpdate(localUser,userID,presence);
          }
          public void sendRosterAdd(          String user,          String name,          String[] groups){
            presenceSender.sendRosterAdd(localUser,user,name,groups);
          }
          public void sendRosterRemove(          ID userID){
            presenceSender.sendRosterRemove(localUser,userID);
          }
        }
);
      }
 catch (      Exception e) {
        IStatus status=new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"String_Node_Str",e);
        ClientPlugin.getDefault().getLog().log(status);
      }
    }
  }
);
  pc.addMessageListener(new IMessageListener(){
    public void handleMessage(    final ID fromID,    final ID toID,    final Type type,    final String subject,    final String message){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handleMessage(fromID,toID,type,subject,message);
        }
      }
);
    }
  }
);
  pc.addPresenceListener(new IPresenceListener(){
    public void handleContainerJoined(    final ID joinedContainer){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.setGroup(joinedContainer);
        }
      }
);
    }
    public void handleRosterEntry(    final IRosterEntry entry){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handleRosterEntry(entry);
        }
      }
);
    }
    public void handlePresence(    final ID fromID,    final IPresence presence){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handlePresence(fromID,presence);
        }
      }
);
    }
    public void handleContainerDeparted(    final ID departedContainer){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          if (rosterView != null) {
            rosterView.memberDeparted(departedContainer);
          }
        }
      }
);
      messageSender=null;
      rosterView=null;
    }
    public void handleSetRosterEntry(    final IRosterEntry entry){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          rosterView.handleSetRosterEntry(entry);
        }
      }
);
    }
  }
);
  pc.addSubscribeListener(new ISubscribeListener(){
    public void handleSubscribeRequest(    final ID fromID,    IPresence presence){
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          try {
            IWorkbenchWindow ww=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            ReceiveAuthorizeRequestDialog authRequest=new ReceiveAuthorizeRequestDialog(ww.getShell(),fromID.getName(),localUser.getName());
            authRequest.setBlockOnOpen(true);
            authRequest.open();
            int res=authRequest.getButtonPressed();
            if (res == ReceiveAuthorizeRequestDialog.AUTHORIZE_AND_ADD) {
              if (presenceSender != null) {
                presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.SUBSCRIBED));
                if (rosterView != null) {
                  String[] groupNames=rosterView.getGroupNames();
                  List g=Arrays.asList(groupNames);
                  String selectedGroup=rosterView.getSelectedGroupName();
                  int selected=(selectedGroup == null) ? -1 : g.indexOf(selectedGroup);
                  AddBuddyDialog sg=new AddBuddyDialog(ww.getShell(),fromID.getName(),groupNames,selected);
                  sg.open();
                  if (sg.getResult() == Window.OK) {
                    String group=sg.getGroup();
                    String user=sg.getUser();
                    String nickname=sg.getNickname();
                    sg.close();
                    if (!g.contains(group)) {
                      rosterView.addGroup(group);
                    }
                    presenceSender.sendRosterAdd(localUser,user,nickname,new String[]{group});
                  }
                }
              }
            }
 else             if (res == ReceiveAuthorizeRequestDialog.AUTHORIZE_ID) {
              if (presenceSender != null) {
                presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.SUBSCRIBED));
              }
            }
 else             if (res == ReceiveAuthorizeRequestDialog.REFUSE_ID) {
              System.out.println("String_Node_Str");
            }
 else {
              System.out.println("String_Node_Str");
            }
          }
 catch (          Exception e) {
            IStatus status=new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"String_Node_Str",e);
            ClientPlugin.getDefault().getLog().log(status);
          }
        }
      }
);
    }
    public void handleUnsubscribeRequest(    ID fromID,    IPresence presence){
      if (presenceSender != null) {
        presenceSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.UNSUBSCRIBED));
      }
    }
    public void handleSubscribed(    ID fromID,    IPresence presence){
      System.out.println("String_Node_Str" + fromID);
    }
    public void handleUnsubscribed(    ID fromID,    IPresence presence){
      System.out.println("String_Node_Str" + fromID);
    }
  }
);
}