Project: Eclipse_Platform_UI
Bug 301193 Restoring editor with inputURI from deltas.xml leads to an NPE in XMLModelReconciler.getValue()
Reported: 2010-01-28 18:14:22 | Status: resolved fixed

Build Identifier: as of 2010-01-27 I have an MEditor instance configured with a valid inputURI. But running the app again leads to an NPE (below). The problem is that XMLModelReconciler.getStructuralFeature() for an EditorImpl and attributeName "inputURI" returns null. As I wasn't sure how the long list was populated, I hacked the getStructuralFeature() to do EMF introspection. I'm sure this isn't efficient, but it works for now. === modified file 'bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/XMLModelReconciler.java' --- bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/XMLModelReconciler.java 2010-01-25 18:42:27 +0000 +++ bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/XMLModelReconciler.java 2010-01-28 23:10:38 +0000 @@ -214,6 +214,12 @@ return MApplicationPackage.eINSTANCE.getPartDescriptor_AllowMultiple(); } else if (featureName.equals(PARTDESCRIPTOR_CATEGORY_ATTNAME)) { return MApplicationPackage.eINSTANCE.getPartDescriptor_Category(); + } else { + for (EStructuralFeature sf : object.eClass().getEAllStructuralFeatures()) { + if (sf.getName().equals(featureName)) { + return sf; + } + } } return null; } Exception is as follows: Daemon Thread [Thread-0] (Suspended (exception NullPointerException)) XMLModelReconciler.getValue(EStructuralFeature, String) line: 222 XMLModelReconciler.createObject(Collection<ModelDelta>, String, Element, List<Object>) line: 673 XMLModelReconciler.createObject(Collection<ModelDelta>, Element, List<Object>) line: 685 XMLModelReconciler.createMultiReferenceDelta(Collection<ModelDelta>, List<Object>, EObject, EStructuralFeature, Element) line: 535 XMLModelReconciler.constructObjectDeltas(Collection<ModelDelta>, List<Object>, EObject, Element) line: 337 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 251 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Collection<ModelDelta>, List<Object>, EObject, Element, String) line: 258 XMLModelReconciler.constructDeltas(Object, Object) line: 129 ResourceHandler.loadMostRecentModel() line: 168 E4Application.loadApplicationModel(IApplicationContext, IEclipseContext) line: 176 E4Application.start(IApplicationContext) line: 72 EclipseAppHandle.run(Object) line: 194 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 367 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 Main.invokeFramework(String[], URL[]) line: 611 Main.basicRun(String[]) line: 566 Main.run(String[]) line: 1363 Main.main(String[]) line: 1339 Reproducible: Always Steps to Reproduce: 1. Setup an MEditor with an inputURI 2. Quit the app 3. Restart the app.

Files changed in fix:
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/workbench/ui/internal/XMLModelReconciler.java