This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 151787

Summary: [65cat] Can't save + can't discard overwrite -> DATALOSS
Product: platform Reporter: ulfzibis <ulfzibis>
Component: TextAssignee: mslama <mslama>
Status: VERIFIED FIXED    
Severity: blocker CC: jiriprox, jskrivanek, jtulach, lhasik, mslama, musilt2, ppis, sustaining
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 150818    
Bug Blocks:    
Attachments: Can't save
Can't discard
log
log1
log2
No Discard on "Overwrite externally modified file?"
Refactor->Rename caused undiscardable "Warning"
Cannot "Save All" after refactoring
log file

Description ulfzibis 2008-10-29 22:15:59 UTC
[ BUILD # : RC1 ]
[ JDK VERSION : 1.6.0 ]

See attachment ...

First I Refactor->Renamed some classes.
Because of mistake, one of those classes I Refactor->Renamed 2nd
time.

After this, I had big problems:
- I got some messages like 'Cannot save' + 'file has externally
modified.

There was no way, to get rid of the asterix (modified file), so I
made backup copies externally, and repaired my workspace.

As I returned back to NetBeans, it recognized properly the external
changes, and all seems to be OK than.

Then I Refactor->Renamed a variable inside a class c2bIndexedMap -->
c2bPagedMap. The renaming was done, but again I got the described
problems.
At this point I created the 2 attached screenshots.

Note: Besides the described problems, the 2nd dialogue is a JOKE: Why
asking for overwrite, if there is no "Discard" button.

Maybe it's P1, because of dataloss.
Comment 1 ulfzibis 2008-10-29 22:17:08 UTC
Created attachment 72854 [details]
Can't save
Comment 2 ulfzibis 2008-10-29 22:17:54 UTC
Created attachment 72855 [details]
Can't discard
Comment 3 ulfzibis 2008-10-29 22:23:52 UTC
Sorry, I mixed the order of the attached screenshots.
First was: *_2.jpg = "Can't save"
Second was: *_1.jpg = "Can't discard"
Comment 4 Lukas Hasik 2008-10-30 10:17:52 UTC
It looks as issue 149330 however it is different way how to get it. The only OK button is described in issue 150818.

I'm not able to reproduce it however it may be caused by the fact that my sources are not versioned (VCS). What VCS do
you use?

Could you try to reproduce with -J-Dorg.openide.text.level=100 and attach the log here -> INCOMPLETE for now
thank you
Comment 5 ulfzibis 2008-10-30 15:49:57 UTC
VCS = subversion 1.5.4
Comment 6 ulfzibis 2008-10-30 15:51:24 UTC
Created attachment 72921 [details]
log
Comment 7 ulfzibis 2008-10-30 15:52:00 UTC
Created attachment 72922 [details]
log1
Comment 8 ulfzibis 2008-10-30 15:52:50 UTC
Created attachment 72923 [details]
log2
Comment 9 mslama 2008-11-05 17:55:50 UTC
Are you able to reproduce with non versioned files? Are you able to reproduce this with latest trunk build? I assume you
have files you refactor opened in editor.
Comment 10 mslama 2008-11-05 17:58:13 UTC
Issue 150818 is about Bundle file ie. properties file. It is handled by different code not by CES/DES in
openide.loaders/openide.editor.
Comment 11 ulfzibis 2008-11-05 18:30:31 UTC
> Are you able to reproduce with non versioned files? Are you able to reproduce this with latest trunk build?
Maybe next days :-(

You are right, some, probably all, of the renamed classes had been open in editor at that time.

BTW: You can checkout the project here:
https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/?rev=470
- I had renamed all *Indexed* to *Paged*
- In case of sun.nio.cs.US_ASCIIOffsetIndexedMapEncoder, I first erroneously renamed to US_ASCIIPagedIndexedMapEncoder,
and later to US_ASCIIOffsetPagedMapEncoder, which caused the issue.
- final result (after external repair): rev=471
Comment 12 mslama 2008-11-25 16:22:14 UTC
It looks like duplicate of #149330. Please test with NB 6.5 FCS or latest trunk dev build. There should be no * after
refactoring.
Comment 13 Lukas Hasik 2008-11-25 16:47:10 UTC
I was able to reproduce with your project. The bug appears whenever you rename a class opened in editor two times
subsequently. However it seems that it is reproducible only on windows. 
I can reproduce it with NB65 and trunk (200811251401)
Comment 14 mslama 2008-11-28 14:03:43 UTC
subversion client on Windows is externally modifying java file after file is saved from editor. It is easy to reproduce
on Win XP.
1.Create local svn repo.
2.Create simple Java SE project with Main.java.
3.Import this project into svn repo.
4.Open Main.java in editor
5.Refactor->Rename Main.java (keep in the same package) eg. to a.java
6.Modify a.java in editor.
7.Save it. Dialog that file was modified externally appears.

It does not happen when file/project is not in svn repo. There was also bug in DataEditorSupport which caused incorrect
(original) file name was displayed in this dialog. I already fixed this as issue #154095 and changeset #d7a3a55ba8db.
Comment 15 mslama 2008-11-28 14:05:00 UTC
Note: When I imported project to svn I selected default bundled svn client in IDE.
Comment 16 mslama 2008-11-28 14:09:11 UTC
Note: You can repeat this as necessary. Just revert svn changes. Close new file in editor with Discard changes. Delete
new file created by rename. Open original file in editor, restart IDE and you can repeat with step 4. We debugged with
Jarda and there is no setLastSaveTime in code. Now CES/DES uses strictly file time stamp. You can use FileMon to find
out who touches file in question.
Comment 17 ulfzibis 2008-11-28 16:48:38 UTC
Good catch!

So bug is in Subversion client ?
Comment 18 Tomas Stupka 2008-12-01 10:41:49 UTC
the svn move command is changing a files timestamp. Unfortunately, the svn module has no control over it. 
Is there any chance to refresh the timestamp value not only after a file change, but also after a rename?

please evaluate
Comment 19 ulfzibis 2008-12-01 11:30:53 UTC
Moving a file in Windows normally does not touch it's timestamp, also renaming.
So IMHO consider of a bug in SVN.
Comment 20 mslama 2008-12-02 10:03:40 UTC
core-main #54a007e7f51c

"expectedTime" event is used to update lastSaveTime in CES when fileRename event comes from file to DES. It handles case
when svn client externally changes file timestamp during rename (Refactor->Rename on file under svn).
Comment 21 Lukas Hasik 2008-12-02 11:54:35 UTC
it needs to be verified properly on different setups and different VCS.

I'm marking as candidate for patch 2 of NB65
Comment 22 Quality Engineering 2008-12-03 05:57:10 UTC
Integrated into 'main-golden', will be available in build *200812030201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/54a007e7f51c
User: Marek Slama <mslama@netbeans.org>
Log: #151787: Sync timestamp when svn client changes timestamp externally during rename.
Comment 23 mslama 2008-12-03 14:24:54 UTC
*** Issue 153175 has been marked as a duplicate of this issue. ***
Comment 24 Jiri Skrivanek 2008-12-05 11:13:06 UTC
*** Issue 154402 has been marked as a duplicate of this issue. ***
Comment 25 Tomas Stupka 2008-12-17 10:44:46 UTC
*** Issue 155624 has been marked as a duplicate of this issue. ***
Comment 26 ulfzibis 2008-12-29 16:42:28 UTC
No Discard on "Overwrite externally modified file?"

After Refactor->Rename of a class, it did some editing on it.
Then I did "Save All" or "Run single Test" (Sorry, I don't remember), and got Warning instead of Error.
See Attachment ...
Comment 27 ulfzibis 2008-12-29 16:44:45 UTC
Created attachment 75347 [details]
No Discard on "Overwrite externally modified file?"
Comment 28 ulfzibis 2008-12-29 16:51:35 UTC
Sorry for error:

After OK, now I can see that I did Refactor->Rename of a variable, before I got the "Warning".
See next Attachment ...
Comment 29 ulfzibis 2008-12-29 16:53:36 UTC
Created attachment 75348 [details]
Refactor->Rename caused undiscardable "Warning"
Comment 30 ulfzibis 2008-12-29 16:57:55 UTC
Created attachment 75349 [details]
Cannot "Save All" after refactoring
Comment 31 ulfzibis 2008-12-29 17:51:21 UTC
I got rid of those messages by workaround:
File->Save As "MyClass.java.bak" :-)
Comment 32 pgebauer 2009-01-14 09:49:34 UTC
The issue hasn't passed the nomination process for 65patch2 by cut-off date. It has been moved to 65patch3.
Comment 33 mslama 2009-01-14 13:45:19 UTC
Please could you sum current status? Steps to reproduce? Again I assume you are on Win XP and your files are in svn repo.
Comment 34 mslama 2009-01-14 13:48:36 UTC
Also part of IDE log with this exception would help.
Comment 35 ulfzibis 2009-01-14 14:03:24 UTC
Yes, I am on Win XP and my files are in svn repo:
https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/

Steps to reproduce?
It's too long time ago. I can't say more, than I had written.

The oldest log, I have, is from 6. Jan.


Comment 36 ulfzibis 2009-01-14 14:05:16 UTC
Created attachment 75827 [details]
log file
Comment 37 mslama 2009-01-14 14:08:14 UTC
I will try to play with renaming.
Comment 38 mslama 2009-02-02 14:19:56 UTC
Closing. If anything like this happens again with latest dev build please file new issue and I will try to evaluate soon.
Comment 39 matusdekanek 2009-02-23 15:44:18 UTC
marking verified
Comment 40 mslama 2009-02-25 10:39:29 UTC
release65_fixes #ef0f2b16f3fa
Comment 41 mslama 2009-03-10 18:03:24 UTC
*** Issue 160029 has been marked as a duplicate of this issue. ***
Comment 42 mslama 2009-03-12 16:13:19 UTC
*** Issue 151501 has been marked as a duplicate of this issue. ***