Bug 101625 NPE when cancelling Call Hierachy search
In I20050624-0010. 1) Start a Call Hierarchy query that is likely to take a long time (for example, on SomeClass.toString()). 2) Try to cancel the search before it completes. The search is not cancelled, and the following is written to the error log: java.lang.NullPointerException at org.eclipse.ui.progress.DeferredTreeContentManager$1.isParent(DeferredTreeContentManager.java:225) at org.eclipse.ui.progress.DeferredTreeContentManager$1.belongsTo(DeferredTreeContentManager.java:206) at org.eclipse.core.internal.jobs.JobManager.select(JobManager.java:876) at org.eclipse.core.internal.jobs.JobManager.select(JobManager.java:898) at org.eclipse.core.internal.jobs.JobManager.select(JobManager.java:886) at org.eclipse.core.internal.jobs.JobManager.cancel(JobManager.java:229) at org.eclipse.ui.progress.DeferredTreeContentManager.cancel(DeferredTreeContentManager.java:365) at org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyContentProvider.cancelJobs(CallHierarchyContentProvider.java:171) at org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyViewer.cancelJobs(CallHierarchyViewer.java:129) at org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyViewPart.cancelJobs(CallHierarchyViewPart.java:922) at org.eclipse.jdt.internal.ui.callhierarchy.CancelSearchAction.run(CancelSearchAction.java:37) at org.eclipse.jface.action.Action.runWithEvent(Action.java:996) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:538) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3080) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2713) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java
/**
     * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
     */
    public Object[] getChildren(Object parentElement) {
        if (parentElement instanceof TreeRoot) {
            TreeRoot dummyRoot = (TreeRoot) parentElement;
            return new Object[] { dummyRoot.getRoot() };
        } else if (parentElement instanceof MethodWrapper) {
            MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
            if (shouldStopTraversion(methodWrapper)) {
                return EMPTY_ARRAY;
            } else {
                if (fManager != null) {
                    Object[] children = fManager.getChildren(new DeferredMethodWrapper(this, methodWrapper));
                    if (children != null)
                        return children;
                }
                return fetchChildren(methodWrapper);            
            }
        }
        return EMPTY_ARRAY;
    }
    protected Object[] fetchChildren(MethodWrapper methodWrapper) {
        IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow();
        MethodWrapperRunnable runnable= new MethodWrapperRunnable(methodWrapper);
        try {
            context.run(true, true, runnable);
        } catch (InvocationTargetException e) {
            ExceptionHandler.handle(e, CallHierarchyMessages.CallHierarchyContentProvider_searchError_title, CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);  
            return EMPTY_ARRAY;