diverse-project / melange

The Melange Language Workbench
http://melange-lang.org
Eclipse Public License 1.0
28 stars 7 forks source link

impossible to save melange file due to NPE #46

Closed dvojtise closed 8 years ago

dvojtise commented 8 years ago

in some case, the save is not possible due to a NPE.

workaround, say that we do not want to save then reopen, the file seems to be saved anyway :confused:

it should be catched properly in order to be able to close the editor view even if there are some internal error (which should be trace in the error log or the problem view anyway)

I don't have a precise example to provide rigth now but here is the stacktrace java.lang.NullPointerException at fr.inria.diverse.melange.processors.ExtensionPointProcessor$8.accept(ExtensionPointProcessor.java:372) at fr.inria.diverse.melange.processors.ExtensionPointProcessor$8.accept(ExtensionPointProcessor.java:1) at java.lang.Iterable.forEach(Unknown Source) at fr.inria.diverse.melange.processors.ExtensionPointProcessor.serializedAspects(ExtensionPointProcessor.java:376) at fr.inria.diverse.melange.processors.ExtensionPointProcessor.access$6(ExtensionPointProcessor.java:364) at fr.inria.diverse.melange.processors.ExtensionPointProcessor$7.accept(ExtensionPointProcessor.java:321) at fr.inria.diverse.melange.processors.ExtensionPointProcessor$7.accept(ExtensionPointProcessor.java:1) at java.lang.Iterable.forEach(Unknown Source) at fr.inria.diverse.melange.processors.ExtensionPointProcessor._preProcess(ExtensionPointProcessor.java:353) at fr.inria.diverse.melange.processors.ExtensionPointProcessor.preProcess(ExtensionPointProcessor.java:395) at fr.inria.diverse.melange.ui.editor.MelangeDocumentProvider$1.exec(MelangeDocumentProvider.java:30) at fr.inria.diverse.melange.ui.editor.MelangeDocumentProvider$1.exec(MelangeDocumentProvider.java:1) at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:121) at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:520) at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:492) at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:133) at fr.inria.diverse.melange.ui.editor.MelangeDocumentProvider.doSaveDocument(MelangeDocumentProvider.java:34) at org.eclipse.ui.texteditor.AbstractDocumentProvider$1$SaveOperation.execute(AbstractDocumentProvider.java:610) at org.eclipse.ui.texteditor.AbstractDocumentProvider$DocumentProviderOperation.run(AbstractDocumentProvider.java:74) at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:69) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313) at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118) at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:75) at org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:65) at org.eclipse.ui.texteditor.AbstractDocumentProvider.executeOperation(AbstractDocumentProvider.java:551) at org.eclipse.ui.texteditor.AbstractDocumentProvider.saveDocument(AbstractDocumentProvider.java:629) at org.eclipse.ui.texteditor.AbstractTextEditor.performSave(AbstractTextEditor.java:5076) at org.eclipse.ui.texteditor.AbstractTextEditor.doSave(AbstractTextEditor.java:4866) at org.eclipse.xtext.ui.editor.XtextEditor.doSave(XtextEditor.java:312) at org.eclipse.ui.texteditor.AbstractTextEditor$TextEditorSavable.doSave(AbstractTextEditor.java:7209) at org.eclipse.ui.Saveable.doSave(Saveable.java:216) at org.eclipse.ui.internal.SaveableHelper.doSaveModel(SaveableHelper.java:355) at org.eclipse.ui.internal.SaveableHelper$3.run(SaveableHelper.java:199) at org.eclipse.ui.internal.SaveableHelper$5.run(SaveableHelper.java:283) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374) at org.eclipse.ui.internal.WorkbenchWindow$13.run(WorkbenchWindow.java:2157) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2153) at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:291) at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:269) at org.eclipse.ui.internal.SaveableHelper.saveModels(SaveableHelper.java:211) at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelper.java:146) at org.eclipse.ui.internal.WorkbenchPage.saveSaveable(WorkbenchPage.java:3915) at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:3929) at org.eclipse.ui.internal.handlers.SaveHandler.execute(SaveHandler.java:54) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294) at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90) at sun.reflect.GeneratedMethodAccessor192.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55) at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247) at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229) at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132) at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:286) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:507) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:558) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:378) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:324) at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:86) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1060) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1112) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1529) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4722) at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:343) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4610) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5023) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

fcoulon commented 8 years ago

I fixed it in fa4a75c2b599796e16e2eaf643962d081e04c0f6

fcoulon commented 8 years ago

I add a try/catch to be safe

68855d28814cfa8287287472c8dad0f7a8a11677

tdegueul commented 8 years ago

You should try/catch the entire process (starting from MelangeDerivedStateComputer). Other exceptions may arise from elsewhere, and we never want to fail abrupty.

See a6a4c25