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 149330 - Cannot save form class after refactoring
Summary: Cannot save form class after refactoring
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW, REGRESSION
: 149152 149992 150217 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-10-07 09:04 UTC by Jana Maleckova
Modified: 2008-12-22 13:55 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
149330 (4.43 KB, text/plain)
2008-10-07 09:07 UTC, Jana Maleckova
Details
messages.log (51.75 KB, text/plain)
2008-10-10 10:27 UTC, Jiri Rechtacek
Details
log with the switch that Jarda required (340.07 KB, text/plain)
2008-10-10 12:39 UTC, Lukas Hasik
Details
log message with jarda's switch (106.26 KB, text/plain)
2008-10-10 13:00 UTC, Jana Maleckova
Details
RC1 messageLog (116.90 KB, text/plain)
2008-10-16 10:20 UTC, Jana Maleckova
Details
log from rc1 when refactor+file modified. With plain java. (78.32 KB, text/plain)
2008-10-16 11:45 UTC, Lukas Hasik
Details
Could this be the fix we are searching for? (5.25 KB, patch)
2008-10-16 14:52 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jana Maleckova 2008-10-07 09:04:58 UTC
Product Version: NetBeans IDE Dev (Build 20081006054500)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

Description:
============
1. have form class
2. move this class to another package
3. insert some component there and try to save it => not possible => data loss

StackTrace:
===========
SEVERE [global]
org.openide.text.CloneableEditorSupport$4: File C:\Documents and Settings\Admin\My
Documents\NetBeansProjects\JavaApplication38\src\javaapplication38\NewJFrame.java was modified externally. Overwrite it?
	at org.openide.text.CloneableEditorSupport.saveDocument(CloneableEditorSupport.java:899)
	at org.openide.text.DataEditorSupport.superSaveDoc(DataEditorSupport.java:417)
	at org.openide.text.DataEditorSupport$SaveImpl.run(DataEditorSupport.java:1006)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:120)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:502)
	at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:216)
Comment 1 Jana Maleckova 2008-10-07 09:07:35 UTC
Created attachment 71267 [details]
149330
Comment 2 mslama 2008-10-07 09:12:27 UTC
Passing to Jarda.
Comment 3 Lukas Hasik 2008-10-07 09:36:37 UTC
duplicate of issue 149152 that was fixed in issue 149069


*** This issue has been marked as a duplicate of 149069 ***
Comment 4 pribyl 2008-10-08 13:40:40 UTC
Product Version: NetBeans IDE Dev (Build 200810080201)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

I can still reproduce this, even with issue 149069 fixed.


Comment 5 Jana Maleckova 2008-10-09 20:31:58 UTC
For now I can reproduce this bug even though issue 149069 has been already fixed. I am not sure about described steps in
149069 if they are working therefore I will reopen this issue. But if description in 149069 always persists please
reopen it as soon as possible and mark this issue as duplicate once again.

Tested on

Product Version: NetBeans IDE Dev (Build 20081009145249)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
Comment 6 Jaroslav Tulach 2008-10-10 10:16:48 UTC
Cannot reproduce on my linux and revision 2503c826312d
Comment 7 Jaroslav Tulach 2008-10-10 10:25:53 UTC
Works on my windowsxp as well. If you insist on existence of the problem, try to generate some logs with
-J-Dorg.openide.text.level=100
Comment 8 Jiri Rechtacek 2008-10-10 10:26:21 UTC
I reproduced this defect on 200810090201. See attached messages.log. P1? Restart IDE fixed it.
Comment 9 Jiri Rechtacek 2008-10-10 10:27:59 UTC
Created attachment 71532 [details]
messages.log
Comment 10 Lukas Hasik 2008-10-10 10:30:43 UTC
easily reproducible on my build 2503c826312d
Product Version: NetBeans IDE Dev (Build 081009)
Java: 1.5.0_14; Java HotSpot(TM) Client VM 1.5.0_14-b03
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

-create new java project
-create new jframe class in the javaapplicationrefactor package
-put some components to the jframe, close it
-right click the class, Refactor > Move
-move to javaapplicationrefactor.newpackage
-open the jframe
-put some components on it
->CTRL+S, Save All does nothing

I'll try to pull -u and rebuild my build to latest sources but definitely reproducible after the fix of 149069


Comment 11 Jaroslav Tulach 2008-10-10 11:54:19 UTC
I need logfile with records from org.openide.text logger.
Comment 12 Jiri Rechtacek 2008-10-10 12:02:59 UTC
I'm sorry Jardo. I cannot help myself but it cannot be a reason to close it as worksforme, it have happened recently to
three peoples. Consider the priority instead, but it's still a real problem in Nb6.5.
Comment 13 Jaroslav Tulach 2008-10-10 12:25:46 UTC
Workforme, means "for me". I need the log or reproducible scenario.
Comment 14 Lukas Hasik 2008-10-10 12:39:24 UTC
Created attachment 71540 [details]
log with the switch that Jarda required
Comment 15 Lukas Hasik 2008-10-10 12:42:14 UTC
log attached -> reopening

I'm decreasing priority as it doesn't seem to be datalost. The file is saved only the tab in editor still shows the *. 
And the exception is logged. And the "file modified externally dialog" appears when you want to close&save the 
document.

Definitely something that needs to be fixed for 6.5 -> P2
Comment 16 Jana Maleckova 2008-10-10 13:00:03 UTC
Created attachment 71543 [details]
log message with jarda's switch
Comment 17 pribyl 2008-10-10 13:50:45 UTC
Product Version: NetBeans IDE Dev (Build 200810100201)
Java: 1.6.0_10-rc; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

Additional observations, maybe some of them help:
- I can reproduce this on Ubuntu too
- When this problem occurs and the IDE is closed, the form file can be saved by the dialog that appears during closing.
However, only the layout of the form is saved (in the Design view you can see the all changes you made). The changes in
the source code are lost.
- I could not reproduce this behaviour on project, created in older versions (I opened project created by NB 6.1 and it
was working fine). It seems it has to be fresh new project
- After the moving of the form file to a new package (and after confirming of the Refactoring dialog), the exception
warning dialog appears, but it is closed immediatelly (can be observed better on a low performance machines)
Comment 18 Jaroslav Tulach 2008-10-10 16:40:37 UTC
I've managed to simulate the problem once following Lukáš's steps.
Comment 19 Jaroslav Tulach 2008-10-10 17:05:49 UTC
I have just fixed something: afe07db1345a
Comment 20 Tomas Pavek 2008-10-12 20:38:03 UTC
*** Issue 149152 has been marked as a duplicate of this issue. ***
Comment 21 Quality Engineering 2008-10-14 06:02:30 UTC
Integrated into 'main-golden', will be available in build *200810140201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/63674cda1579
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: Use setter to modify lastModified time. Plus an additional test to similate #149330 - unsuccessfully
Comment 22 Jiri Prox 2008-10-14 09:23:30 UTC
*** Issue 149992 has been marked as a duplicate of this issue. ***
Comment 23 soldatov 2008-10-14 21:39:59 UTC
*** Issue 149152 has been marked as a duplicate of this issue. ***
Comment 24 Jan Pokorsky 2008-10-15 13:36:30 UTC
*** Issue 150217 has been marked as a duplicate of this issue. ***
Comment 25 Jana Maleckova 2008-10-16 10:07:21 UTC
I tried to verify this bug on RC1 where should be already fixed (according to record in releas65 clone
http://hg.netbeans.org/release65/rev/63674cda1579) but the issue always happens => reopening

Use steps described by lhasik

1. create new java project
2. create new jframe class in the javaapplicationrefactor package
3. put jButton into the jframe
4. move to javaapplicationrefactor.newpackage
5. add actionPerformed to jButton
->CTRL+S, Save All does nothing

tested on

Product Version: NetBeans IDE 6.5 RC1 (Build 200810151402)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

And what about the priority. I have to insist on P1 because there data loss really happens even though it's not visible
for the first sight. Form in design looks like all changes were saved but source code contains old data and newly
generated one has been lost.
e.g.
do all 5 steps
6. CTR+S 
7. close the form and push save button which appears afterwards => warning is thrown
8. restart IDE
9. confirm save (no warning now and IDE is closed and finally opened)
check source code of jFrame => no code for actionPerformed is there


Comment 26 Jana Maleckova 2008-10-16 10:20:24 UTC
Created attachment 71949 [details]
RC1 messageLog
Comment 27 Lukas Hasik 2008-10-16 11:40:30 UTC
I can reproduce with "plain" java.
-have javaapplication/Main.java
-move it to javaapplicationrefactor.newpackage
-CTRL+S
->file modified externally message appears
Comment 28 Lukas Hasik 2008-10-16 11:45:02 UTC
Created attachment 71956 [details]
log from rc1 when refactor+file modified. With plain java.
Comment 29 Jaroslav Tulach 2008-10-16 14:24:59 UTC
Unit test written.
Comment 30 Jaroslav Tulach 2008-10-16 14:52:46 UTC
Created attachment 71986 [details]
Could this be the fix we are searching for?
Comment 31 Jaroslav Tulach 2008-10-16 15:45:33 UTC
Fixed: 
http://hg.netbeans.org/main/rev/09c8d6bb50aa

I needed to introduce new friend API. Jesse, Jirka Skřivánek, Marek Sláma, Tomáš Holý can you be reviewers and confirm 
that this is acceptable API change?

Comment 32 Jesse Glick 2008-10-16 15:52:55 UTC
Harmless for branch. For the trunk I would suggest a properly exposed constant in Env.
Comment 33 Jana Maleckova 2008-10-16 16:11:08 UTC
patch is working, I will verify it firstly on trunk build late tonight and finally on new build of RC1 tomorrow morning.
Comment 34 mslama 2008-10-16 16:32:17 UTC
Works on trunk build, Win2K, refactoring move java calss to another package. Before it failed now it works.

Patch seems ok.
Comment 35 Jiri Skrivanek 2008-10-16 16:35:38 UTC
Patch works for me. Both test and 'save after refactoring' case are fixed by the patch.
Comment 36 Jana Maleckova 2008-10-16 19:14:29 UTC
verified on trunk build
Product Version: NetBeans IDE Dev (Build 20081016162902)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
Comment 38 Quality Engineering 2008-10-17 05:01:45 UTC
Integrated into 'main-golden', will be available in build *200810170201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/09c8d6bb50aa
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #149330: Extra API between CloneableEditorSupport and DataEditorSupport to notify the first about change of primary file
Comment 39 Jana Maleckova 2008-10-17 09:27:16 UTC
verified on RC1

Product Version: NetBeans IDE 6.5 RC1 (Build 200810170201)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)