Project: Eclipse_Platform_UI
Bug 89903 [EditorMgmt] EditorRegistry returns null as one of the default editors
Reported: 2005-03-31 17:16:06 | Status: verified fixed

The following is the contract for 'setDefaultEditor' in IEditorRegistry: /** * Sets the default editor id for the files that match that * specified file name or extension. The specified editor must be * defined as an editor for that file name or extension. * * @param fileNameOrExtension the file name or extension pattern (e.g. "*.xml"); * @param editorId the editor id or <code>null</code> for no default */ public void setDefaultEditor(String fileNameOrExtension, String editorId); However, when we set the default editor to null, OpenWithMenu chokes and throws null exception. It happens when it wants to sort the default editors because one of the editors returned by IEditorRegistry is null, and the sorter does not expect that. The culprit is the following method in EditorRegistry: public IEditorDescriptor[] getEditors(String fileName, IContentType contentType); It does filter the array before returning it, but for some reason null goes through the filter. I would have fixed the problem and provided the patch, but I am a bit scared of the new content code, so you are better off fixing it yourselves.

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorRegistryTest.java