Bug 353025 - [implementation] NPE during Save when "Refresh on Access" enabled
Summary: [implementation] NPE during Save when "Refresh on Access" enabled
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M7   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on: 14867
Blocks:
  Show dependency tree
 
Reported: 2011-07-25 13:44 EDT by Martin Oberhuber CLA
Modified: 2012-04-03 09:04 EDT (History)
20 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2011-07-25 13:44:53 EDT
Build ID: Eclipse 3.7 (Indigo)

When the new "Refresh on Access" Preference from bug 14867 is on, data loss can occur in the following scenario:

1. Create a General Project
2. Create file "sample.txt", save but keep editor open.
3. Outside Eclipse, delete or rename sample.txt
4. Switch back to Eclipse --> See following dialog:

   "The file proj/sample.txt has been deleted or is not accessible. Do you
    want to save your changes or close the editor without saving?"

5. Press "Save" --> Nothing happens, except NPE printed to errorlog
   (see below). That is, the file which I've just been editing, is lost and
   gone. 

The problem seems to be that due to the "Refresh on Access", the EditorInput is deleted before Eclipse has a chance to save the file. The issue does not occur when the editor is dirty, or when the "Refresh on Access" preference is off.

This issue is particularly concerning in a ClearCase dynamic view, when I'm editing a file while a different user performs renames or deletes that file. Recovering my data may be possible (since the editor was not dirty), but the behavior is unexpected and recovery likely nontrivial.

The NPE:

Caused by: java.lang.NullPointerException
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.performSaveAs(AbstractDecoratedTextEditor.java:1552)
	at org.eclipse.ui.texteditor.AbstractTextEditor.handleEditorInputChanged(AbstractTextEditor.java:4737)
	at org.eclipse.ui.texteditor.StatusTextEditor.handleEditorInputChanged(StatusTextEditor.java:267)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.handleEditorInputChanged(AbstractDecoratedTextEditor.java:1474)
	at org.eclipse.ui.texteditor.AbstractTextEditor.sanityCheckState(AbstractTextEditor.java:4887)
	at org.eclipse.ui.texteditor.StatusTextEditor.sanityCheckState(StatusTextEditor.java:257)
	at org.eclipse.ui.texteditor.AbstractTextEditor.safelySanityCheckState(AbstractTextEditor.java:4865)
	at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.handleActivation(AbstractTextEditor.java:984)
	at org.eclipse.ui.texteditor.AbstractTextEditor$ActivationListener.access$0(AbstractTextEditor.java:977)
	at org.eclipse.ui.texteditor.AbstractTextEditor$10.run(AbstractTextEditor.java:1005)
Comment 1 Dani Megert CLA 2011-07-26 03:35:56 EDT
>3. Outside Eclipse, delete or rename sample.txt

Mmh, I'd rather say it's data loss if the file is still there after you explicitly deleted it ;-).