Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348667 - Delete diagram editor, then Save, receive errors
Summary: Delete diagram editor, then Save, receive errors
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: Diagram Editor (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Alexandrina Ivanova CLA
QA Contact: Stefan Dimov CLA
URL:
Whiteboard:
Keywords:
Depends on: 351409
Blocks:
  Show dependency tree
 
Reported: 2011-06-07 20:55 EDT by Jolene Moffitt CLA
Modified: 2011-08-11 11:52 EDT (History)
0 users

See Also:
stefan.dimov: indigo+
stefan.dimov: juno+
stefan.dimov: review+


Attachments
Fix (5.21 KB, patch)
2011-06-29 10:34 EDT, Alexandrina Ivanova CLA
no flags Details | Diff
Fix reworked as agreed. (6.15 KB, patch)
2011-07-05 03:34 EDT, Alexandrina Ivanova CLA
no flags Details | Diff
Fix reworked as agreed. (redundant imports deleted and a null check added) (5.96 KB, patch)
2011-07-05 03:49 EDT, Alexandrina Ivanova CLA
no flags Details | Diff
patch v4 (36.29 KB, patch)
2011-07-15 08:22 EDT, Stefan Dimov CLA
stefan.dimov: review+
Details | Diff
Screenshot of the process explorer (66.95 KB, image/jpeg)
2011-07-15 09:22 EDT, Stefan Dimov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jolene Moffitt CLA 2011-06-07 20:55:29 EDT
1. Create a project then select JPA Tools >Open Diagram.  
2. It creates the file diagrams\diagram.xml and the diagram.xml opens in the editor.  
3. Delete the diagrams folder (which contains the diagram.xml) the diagram editor still remains open.  
4. Add a Java Entity to the diagram editor and then try and save 
5. Receive problem occurred dialog that shows Save All Failed – java.lang.NullPointerException.    
6. The same thing happens if I just deleted the diagram.xml.

The diagram editor should close if the diagram.xml is deleted.  The same thing happens if I just removed the diagram.xml – the diagram editor still remains open.

java.lang.NullPointerException
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.util.EntitiesCoordinatesXML.store(EntitiesCoordinatesXML.java:92)
	at org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor.doSave(JPADiagramEditor.java:186)
	at org.eclipse.ui.internal.DefaultSaveable.doSave(DefaultSaveable.java:54)
	at org.eclipse.ui.Saveable.doSave(Saveable.java:214)
	at org.eclipse.ui.internal.SaveableHelper.doSaveModel(SaveableHelper.java:349)
	at org.eclipse.ui.internal.EditorManager$8.run(EditorManager.java:1269)
	at org.eclipse.ui.internal.SaveableHelper$5.run(SaveableHelper.java:277)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2642)
	at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:285)
	at org.eclipse.ui.internal.EditorManager.saveAll(EditorManager.java:1279)
	at org.eclipse.ui.internal.EditorManager.saveAll(EditorManager.java:1050)
	at org.eclipse.ui.internal.EditorManager.saveAll(EditorManager.java:1027)
	at org.eclipse.ui.internal.WorkbenchPage.saveAllEditors(WorkbenchPage.java:3406)
	at org.eclipse.ui.internal.handlers.SaveAllHandler.execute(SaveAllHandler.java:48)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4163)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Alexandrina Ivanova CLA 2011-06-29 10:34:40 EDT
Created attachment 198833 [details]
Fix
Comment 2 Stefan Dimov CLA 2011-07-01 11:05:27 EDT
Ina, please rework the patch as we agreed.
Comment 3 Alexandrina Ivanova CLA 2011-07-05 03:34:28 EDT
Created attachment 199090 [details]
Fix reworked as agreed.
Comment 4 Alexandrina Ivanova CLA 2011-07-05 03:49:19 EDT
Created attachment 199091 [details]
Fix reworked as agreed. (redundant imports deleted and a null check added)
Comment 5 Stefan Dimov CLA 2011-07-07 05:27:22 EDT
The fix seems ok, but exposes a problem described in the bug #351409, so submitting the patch will have to wait until the other bug is fixed.
Comment 6 Stefan Dimov CLA 2011-07-15 08:22:49 EDT
Created attachment 199741 [details]
patch v4

It appears that this one needed a little more rework. With this last patch I still notice some problems. When you open and close the editor quick a few times and then try to delete the diagram xml file you get an error, that the file could not be deleted. I've researched the  problem and I'm sure that the reason is not this fix or anything other in the editor. Somewhere (but I can't exactly put a finger on it) happens late closing of the file handles. In the editor the streams for reading/writing xml file are being closed explicitly, immediately after their usage, so the problem is somewhere else. I've monitored the handles with the process explorer (see the attached screenshot) and when you open/close editor quickly the number of the handled to the xml file increases, but after a minute they are being wiped and the user may delete the xml file. I believe that it's got something to do with the following post: http://www.eclipse.org/forums/index.php/t/172929/

Having in mind all of the above I consider that this version of the patch is ok and will submit it in the HEAD and in the maintenance release branch. For the file handles problem I will continue the research and eventually will open a bug (as long as I discover in which component).
Comment 7 Stefan Dimov CLA 2011-07-15 08:27:37 EDT
One more comment. This patch actually fixes the problem described in the bug #351409. Both are too tightly related to separate them.
Comment 8 Stefan Dimov CLA 2011-07-15 08:43:37 EDT
Common patch for bug #351409 and bug #348667 submitted
Comment 9 Stefan Dimov CLA 2011-07-15 09:22:15 EDT
Created attachment 199746 [details]
Screenshot of the process explorer
Comment 10 Jolene Moffitt CLA 2011-08-11 11:52:08 EDT
Verified in Build I-3.4.0-20110805150738 

Verified user can delete diagram editor and/or diagram.xml file and the editor closes and no errors appear in error log.  See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.0.1