Bug 85615 - Replaced file in workspace still has old content
Summary: Replaced file in workspace still has old content
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2005-02-16 18:08 EST by Keith McQueen CLA
Modified: 2007-06-22 10:04 EDT (History)
1 user (show)

See Also:


Attachments
Zip contains video (.avi) file demonstrating problem (562.44 KB, application/octet-stream)
2005-02-16 18:14 EST, Keith McQueen CLA
no flags Details
Contains deployable plugins and fragments with source. (1.42 MB, application/x-zip-compressed)
2005-02-22 11:07 EST, Keith McQueen CLA
no flags Details
Data file (171.70 KB, application/octet-stream)
2005-02-22 11:08 EST, Keith McQueen CLA
no flags Details
Namelist file (1.54 KB, application/octet-stream)
2005-02-22 11:08 EST, Keith McQueen CLA
no flags Details
Tables file (1.24 KB, application/octet-stream)
2005-02-22 11:08 EST, Keith McQueen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keith McQueen CLA 2005-02-16 18:08:01 EST
When I delete a file from the workspace, either programmatically or manually,
and then replace the file, Eclipse seems to get kind of stuck with the old file.
 Let me elaborate.

I have a multipage editor with separate pages for different files.  If I delete
one of the files, the associated page is removed.  If I replace the file (same
name, different content) I get my page back, but it displays the contents of the
old, deleted file.

If I have the file open in its own editor (default text editor) and delete the
file, the editor is closed.  If I replace the file (as above) then open the
editor, I get a popup message telling me that the file has changed on disk, and
do I want to reload the file.

I'm wondering if there is a way to "force" eclipse to reload the file from the
file system without having to have a dialog (or in the case of my own multipage
editor, not having any way to reload the file).  I have the "Refresh workspace
automatically" turned on already.

I will attach a zip file containing a .avi file demonstrating what I mean.
Comment 1 Keith McQueen CLA 2005-02-16 18:14:24 EST
Created attachment 18034 [details]
Zip contains video (.avi) file demonstrating problem

In the demo, the workbench starts up with an editor open.  The editor contains
pages for multiple files.  A change is made in the primary file (cruise.mvs)
and then the launch is run.  The launch causes the output file (cruise.mvs.lis)
to be deleted and then a new one is created in its place. The change in the
primary file is reflected in the echoed content of the output file
(cruise.mvs.lis).  The editor is closed and then reopened.  A change is made to
the primary file (cruise.mvs) and the launch is run again.  The change is not
reflected in the output (cruise.mvs.lis) file until opening it in its own
editor.  Then a popup is displayed asking the user to reload the contents from
disk.  Then the file is updated in both the text editor and in the multipage
editor.
Comment 2 John Arthorne CLA 2005-02-17 13:24:41 EST
This is an issue with synchronization between the editor's in-memory
representation of the file with the file contents on disk. I suspect your editor
can be customized to automatically load the changed contents from disk without
prompting if that is the behaviour you are looking for.  Moving to text for
further comment.
Comment 3 Keith McQueen CLA 2005-02-17 14:05:01 EST
The editor that is being used is eclipse's text editor.  In one case the user
opens the file separately in the default text editor, in the other, an instance
of TextEditor is embedded as a page in a multipage editor.  It appears that
eclipse itself (or the default text editor) keeps a cache of the file.  These
are new instances of the editor in each case, so it must really be the
workbench/resources that is keeping the cache.  

This only occurs when the file is deleted and then replaced, not when the
contents are just overwritten.  And the funny thing is, as demonstrated by the
video, is that the first time the file(s) are opened, everything works fine. 
Its only after the file(s) have been opened, then closed, then opened again.

I've tried to debug the problem to see if I could find anything, but I have not
had any real success.  Every time I debug, I think I interfere with the system
enough for things to work properly, because it always seems to think the file is
in sync with the disk (but maybe that's all in my head).
Comment 4 Dani Megert CLA 2005-02-18 09:29:50 EST
Which build?

To me this looks like the embedded text editor doesn't get closed correctly in
which case the underlying document (and file buffer - depends on which build you
use) is still connected to the file path. If you open the same path again the
old document is shown.

Is the following preference enabled?
Workbench > General > Refresh workspace automatically

In order to debug this we either need a test case based on Eclipse SDK or you
need to provide us a simple version of your multi-page editor that demonstrates
the problem.
Comment 5 Keith McQueen CLA 2005-02-18 11:17:23 EST
I'm not sure what you mean by "closed correctly".  When the page containing the
TextEditor is removed from the multipage editor, the editor is disposed.  This
all happens through the FormEditor/MultiPageEditorPart#removePage(int) method
which invokes the disposePart(IWorkbenchPart) method.  Is there something else I
should be doing?

As far as a test case goes, I'll see if I can come up with something.
Comment 6 Dani Megert CLA 2005-02-18 11:38:32 EST
Correct: if dispose() is called then the document provider should get disposed
as well (unless there's some error inbetween - log entries?). I just named a
possible cause since I don't have enough information to tell more.
Comment 7 Keith McQueen CLA 2005-02-22 11:06:06 EST
I am attaching a zip file containing my plugins (with source).  I was not able 
to conjure up a simple test case, so I am providing my plugins as-is.  I will 
also attach 3 text files that will be opened by my multipage editor.  With all 
of this, you should be able to actually run and see what I see.
Comment 8 Keith McQueen CLA 2005-02-22 11:07:11 EST
Created attachment 18177 [details]
Contains deployable plugins and fragments with source.
Comment 9 Keith McQueen CLA 2005-02-22 11:08:13 EST
Created attachment 18178 [details]
Data file
Comment 10 Keith McQueen CLA 2005-02-22 11:08:34 EST
Created attachment 18179 [details]
Namelist file
Comment 11 Keith McQueen CLA 2005-02-22 11:08:57 EST
Created attachment 18180 [details]
Tables file
Comment 12 Dani Megert CLA 2005-02-22 11:58:42 EST
Thanks plug-ins. Where do I have to put the three test files?
Comment 13 Keith McQueen CLA 2005-02-22 12:15:45 EST
You can just import them into your runtime workspace (where the plugins are
running).  Then you should just be able to double-click any one of them to open
the editor.  Once the editor is open, you should create a KADRE launch, using
the launch configuration dialog.  We may have changed the settings in the launch
to avoid the problem for now, so go to the Output tab/page of the LCD and make
sure the Clear option is selected under Existing Files.  Then run.  You may have
to run once before you can see the problem, since the first run will create the
output files, and subsequent runs will clear and then replace the output files.
Comment 14 Dani Megert CLA 2005-05-26 18:47:15 EDT
Investigate during RC2.
Comment 15 Tom Hofmann CLA 2005-06-01 10:58:00 EDT
Note: the attached plug-ins cannot be compiled or run due to unmet dependencies: 

- com.tsccos.utils
- org.jfree

Comment 16 Tom Hofmann CLA 2005-06-01 11:21:00 EDT
cannot reproduce with the given steps.
Comment 17 Dani Megert CLA 2005-06-01 11:26:42 EDT
We could not detect a problem on the Text editor side using 3.1 RC1. We tried
the described scenrio by deleting/replacing inside and outside of Eclipse using
Linux and WindowsXP.

As mentioned by Tom the attached code could not be used. We will look at this
after 3.1 again once more details are available.
Comment 18 Dani Megert CLA 2007-06-22 09:59:18 EDT
Get rid of deprecated state.
Comment 19 Dani Megert CLA 2007-06-22 10:04:33 EDT
.