Project: Eclipse_Platform_UI
Bug 309851 [CommonNavigator] Navigating to Project Explorer causes an NPE
Reported: 2010-04-20 15:02:43 | Status: verified fixed

Build Identifier: Eclipse 3.6, build I20100406-1034 If the object in Project Explorer's tree does not have associated IWorkbenchAdapter then navigating to Project Explorer causes an NPE. The regression was introduced in the "org.eclipse.ui.navigator.resources.ProjectExplorer" class. Private method "convertElement" attempts to get the IWorkbenchAdapter class from our object in the tree. It then blindly calls "getParent()" without checking if the adapter is returned first, which causes the NPE and breaks navigation. Please take a look at the line "found = wba.getParent(original);". private Object convertElement(Object original) { NavigatorContentService ncs = (NavigatorContentService) getNavigatorContentService(); Object found = ncs.getViewerElementData(original); if (found != null) return original; if (original instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) original; found = adaptable.getAdapter(IResource.class); if (found != null) return found; IWorkbenchAdapter wba = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class); found = wba.getParent(original); if (found != null) return convertElement(found); } return original; } Marking as major because navigation is completely broken for us. Reproducible: Always Steps to Reproduce: 1. Please see the details section. 2. 3.

Files changed in fix:
bundles/org.eclipse.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ProjectExplorer.java