Buggy code:
public class DiscoveryView extends ViewPart { protected static final String DISCOVERED_SERVICES = "Services" ; protected static final int SERVICE_INFO_TIMEOUT = 3000 ; protected static final int TREE_EXPANSION_LEVELS = 3 ; private TreeViewer viewer ; private Action requestServiceInfoAction ; private Action registerServiceTypeAction ; private Action connectToAction ; private Action disconnectContainerAction ; private Action connectContainerAction ; IDiscoveryController controller = null ; String [ ] controllerServiceTypes = null ; protected boolean showTypeDetails = false ; public void setShowTypeDetails ( boolean val ) { } protected boolean isSupportedServiceType ( String serviceType ) { } public void setDiscoveryController ( final IDiscoveryController controller ) { } protected void setConnectMenus ( boolean connected ) { } protected boolean isConnected ( ) { } protected IDiscoveryController getController ( ) { } protected IContainer getIContainer ( ) { } protected IDiscoveryContainerAdapter getDiscoveryContainer ( ) { } class TreeObject implements IAdaptable { private String name ; private DiscoveryView . TreeParent parent ; public TreeObject ( String name ) { } public String getName ( ) { } public void setParent ( DiscoveryView . TreeParent parent ) { } public DiscoveryView . TreeParent getParent ( ) { } public String toString ( ) { } public Object getAdapter ( Class key ) { } } class TreeParent extends DiscoveryView . TreeObject { private ArrayList children ; private IServiceID id ; private IServiceInfo serviceInfo ; public TreeParent ( IServiceID id , String name , IServiceInfo svcInfo ) { } public IServiceInfo getServiceInfo ( ) { } public IServiceID getID ( ) { } public void addChild ( DiscoveryView . TreeObject child ) { } public void removeChild ( DiscoveryView . TreeObject child ) { } public DiscoveryView . TreeObject [ ] getChildren ( ) { } public boolean hasChildren ( ) { } public void clearChildren ( ) { } } class ViewContentProvider implements IStructuredContentProvider , ITreeContentProvider { private DiscoveryView . TreeParent invisibleRoot ; protected DiscoveryView . TreeParent root ; public void inputChanged ( Viewer v , Object oldInput , Object newInput ) { } public void dispose ( ) { } public Object [ ] getElements ( Object parent ) { } public Object getParent ( Object child ) { } public Object [ ] getChildren ( Object parent ) { } public boolean hasChildren ( Object parent ) { } private void initialize ( ) { } public void clear ( ) { } public boolean isRoot ( DiscoveryView . TreeParent tp ) { } void replaceOrAdd ( DiscoveryView . TreeParent top , DiscoveryView . TreeParent newEntry ) { } void addServiceTypeInfo ( String type ) { } DiscoveryView . TreeParent findServiceTypeNode ( String typename ) { } void addServiceInfo ( IServiceID id ) { } void addServiceInfo ( IServiceInfo serviceInfo ) { } void removeServiceInfo ( IServiceInfo serviceInfo ) { } } protected String cleanTypeName ( String inputName ) { } class ViewLabelProvider extends LabelProvider { public String getText ( Object obj ) { } public Image getImage ( Object obj ) { } } public DiscoveryView ( ) { } public void clearAllServices ( ) { } public void addServiceTypeInfo ( final String type ) { } public void addServiceInfo ( final IServiceInfo serviceInfo ) { } public void addServiceInfo ( final IServiceID id ) { } public void removeServiceInfo ( final IServiceInfo serviceInfo ) { } protected void refreshView ( ) { } protected void expandAll ( ) { } private void makeActions ( ) { } private void fillContextMenu ( IMenuManager manager ) { } protected void connectToService ( IServiceInfo svcInfo ) { } protected DiscoveryView . TreeObject getSelectedTreeObject ( ) { } public void createPartControl ( Composite parent ) { } private void contributeToActionBars ( ) { } private void fillLocalPullDown ( IMenuManager manager ) { } private void fillLocalToolBar ( IToolBarManager manager ) { } private void hookContextMenu ( ) { <START_BUG> MenuManager menuMgr = new MenuManager ( "#PopupMenu" ) ; <END_BUG> menuMgr . setRemoveAllWhenShown ( true ) ; menuMgr . addMenuListener ( new IMenuListener ( ) { public void menuAboutToShow ( IMenuManager manager ) { DiscoveryView . this . fillContextMenu ( manager ) ; } } ) ; Menu menu = menuMgr . createContextMenu ( viewer . getControl ( ) ) ; viewer . getControl ( ) . setMenu ( menu ) ; getSite ( ) . registerContextMenu ( menuMgr , viewer ) ; } private void hookDoubleClickAction ( ) { } public void dispose ( ) { } public void setFocus ( ) { } }

Fix:
MenuManager menuMgr = new MenuManager ( ) ;