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.
While renaming the name of a class and the name of it's constructor (in editor) and then renaming the name of the corresponding file (in explorer) to the same value, after saving this file a FSException exception is occured. (in ForteFJ -build 1160- there is another one exception in setter while renaming the file) org.openide.filesystems.FSException: Invalid lock for file ClasssX.java in C:\Program Files\NetBeans\Development. at org.openide.filesystems.FSException.io(FSException.java:72) at org.openide.filesystems.AbstractFileObject.testLock (AbstractFileObject.java:215) at org.openide.filesystems.AbstractFileObject.getOutputStream (AbstractFileObject.java:174) at org.openide.text.DataEditorSupport$Env.outputStream (DataEditorSupport.java:305) at org.openide.text.CloneableEditorSupport.saveDocument (CloneableEditorSupport.java:379) at org.openide.text.EditorSupport$Del.superSaveDocument (EditorSupport.java:711) at org.openide.text.EditorSupport.saveDocument(EditorSupport.java:258) at org.netbeans.modules.java.JavaEditor.saveDocument (JavaEditor.java:380) at org.netbeans.modules.java.JavaEditor.saveDocument (JavaEditor.java:362) at org.openide.text.EditorSupport$EntryEnv.save(EditorSupport.java:810) at org.openide.actions.SaveAction.performAction(SaveAction.java:49) at org.openide.util.actions.NodeAction.performAction(NodeAction.java:93) at org.openide.util.actions.NodeAction.actionPerformed (NodeAction.java:84) at org.netbeans.core.ModuleActions$1.run(ModuleActions.java:67) at org.openide.util.Task.run(Task.java:124) [catch] at org.openide.util.RequestProcessor$ProcessorThread.run (RequestProcessor.java:562)
Probably problem lies anywhere in EditorSupport and for this bug is not responsible org.openide.filesystems. Method FileObject.getOutputStream expects FileLock parametr and validates it in testLock. Because FileLock parameter is null, than is not validated in testLock and FSException is fired. The problem is caused in DataEditorSupport.Env.outputStream() in call: return getFileImpl ().getOutputStream (fileLock), where fileLock is null. Method DataEditorSupport.Env.changeFile () is responsible for setting fileLock (fileLock = takeLock()). But when DataObject is renamed EditorSupport.EntryEnv.propertyChange is called as notification. From propertyChange is called changeFile (), but takeLock () is not called, because methods returns prematurely: protected final void changeFile () { FileObject newFile = getFile (); if (newFile.equals (fileObject)) { // the file has not been updated return; } ....
Reassigning to editor because of the Radek's comment and increasing priority of this bug to P2, because of simple steps to reproduce and big impact at the user (cannot save data from editor).
x
*** Issue 9937 has been marked as a duplicate of this issue. ***
I don't know what's the proper fix for this openide bug. I think Yarda or someone else should take care about this.
This is bad behaviour and user cannot save his data. Yarda can you suggest any solution?
Steps to reproduce? I tried: 1. open a java file named GetNode 2. change the name of class to Get 3. change the name of constructor to Get => the file renamed on disk to 4. then I renamed the file on disk to Get and also I tried Get1
Now it works for mee too, seems that the behaviour has changed ;-)
Yarda, 5. step to reproduce is "Save". After modification of the file in editor (a name of class and constructor) you don't have to save the file, first rename the file in explorer and then save it.
Sorry, now IDE really changed behaviour (NB 3.2 build 19), my last additional comment was related to NB 3.2 build 16, BUT the FSException persists in other steps to reproduce. So here it is: 1. rename only class name in editor, e.g. Get -> GetNode (it does not lead to synchronization with explorer) 2. rename the corresponding file in explorer to the same name as class in editor (Get -> GetNode), there is a BUG, because the class in editor is automaticly renamed to GetNodeNode and it is not in synchronization with explorer 3. rename constructor of class in editor to GetNodeNode (now the classname and constructor are consistent AND it does lead to synchronization with explorer, so node in explorer is automaticaly renamed to GetNodeNode) 4. try to save this file -> FSException will occur
Created attachment 988 [details] Proposed fix of FileEntry.java
The problem is not just in Java sources, but is general. 1. Create a text file 2. Open and edit it 3. Rename it in explorer (while document is modified) 4. Try to save the content of document You'll receive the exception. My fix should solve the worst type of problem and I think it is suitable for 3.2, but for new versions. But it is not bulletproof, probably we need better implementation with better synchronization for next versions.
Fixed. Fix will be in dev build #161 and release32 build #21 (rename(), move() and delete() methods modified to don't release lock, if file was locked previously)
*** Issue 8666 has been marked as a duplicate of this issue. ***
verified.
Resolved for 3.4.x or earlier, no new info since then -> closing.