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 208657 - VCSInterceptor.beforeEdit should throw IOException if VCS operation failed
Summary: VCSInterceptor.beforeEdit should throw IOException if VCS operation failed
Status: RESOLVED FIXED
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.2
Hardware: All All
: P2 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-20 16:38 UTC by Vladimir Voskresensky
Modified: 2012-03-17 10:38 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
suggested changes (6.43 KB, patch)
2012-02-28 14:10 UTC, Tomas Stupka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Voskresensky 2012-02-20 16:38:59 UTC
File system during getting lock (i.e. first typing in editor) calls beforeEdit which is delegated into VCSInterceptor.beforeEdit => ade should checkout file. But checkout can fail => VCS impl should notify about failed beforeEdit activity. The easiest way is to follow the same style as in other do* methods and add throw IOException into signature
Comment 1 Tomas Stupka 2012-02-24 15:55:09 UTC
we can change versioning.core.spi.VCSInterceptor.beforeEdit() and VCSFilesystemInterceptor.fileLoecked() as suggested, but that woud also imply changes in masterfs.

jarda - please evaluate
Comment 2 Jaroslav Tulach 2012-02-27 12:58:48 UTC
Changing a method in masterfs to throw IOException is source incompatible, but binary compatible. As masterfs friends are always compiled at the same time as masterfs, and even if they will not, they will link (as the change is binary compatible), feel free to modify existing method to throw IOException.
Comment 3 Vladimir Voskresensky 2012-02-27 16:09:38 UTC
VCSInterceptor.beforeEdit is new SPI not used by anyone except ADE as I know, right?
Comment 4 Tomas Stupka 2012-02-27 16:13:51 UTC
(In reply to comment #3)
> VCSInterceptor.beforeEdit is new SPI not used by anyone except ADE as I know,
> right?
yes
Comment 5 Vladimir Voskresensky 2012-02-27 16:57:06 UTC
btw, what is the public API method in masterfs which have to change signature due to change in VCSInterceptor.beforeEdit?
Comment 6 Tomas Stupka 2012-02-27 17:40:16 UTC
(In reply to comment #5)
> btw, what is the public API method in masterfs which have to change signature
> due to change in VCSInterceptor.beforeEdit?
masterfs isn't public. but what has to change there in the first place is ProvidedExtensions.fileLocked()
Comment 7 Tomas Stupka 2012-02-28 14:10:50 UTC
Created attachment 116182 [details]
suggested changes

attached suggested changes in vcs and masterfs.

i'm not very familiar with masterfs, jarda please have a look on ProvidedExtensions, ProvidedExtensionsProxy and on what is going on in FileObj.lock().

tried to emulate the requested behavior by throwing IOE from vcs in .beforeEdit() and the raised exception was:

java.lang.Throwable: Locked by:
	at org.openide.filesystems.FileLock.<init>(FileLock.java:85)
	at org.netbeans.modules.masterfs.filebasedfs.fileobjects.LockForFile.<init>(LockForFile.java:91)
	at org.netbeans.modules.masterfs.filebasedfs.fileobjects.LockForFile.tryLock(LockForFile.java:102)
	at org.netbeans.modules.masterfs.filebasedfs.fileobjects.FileObj.lock(FileObj.java:360)
	at org.openide.loaders.MultiDataObject$Entry.takeLock(MultiDataObject.java:1352)
	at org.netbeans.modules.openide.loaders.SimpleES$Environment.takeLock(SimpleES.java:188)
	at org.openide.text.DataEditorSupport$Env.markModified(DataEditorSupport.java:951)
	at org.openide.text.CloneableEditorSupport.notifyModified(CloneableEditorSupport.java:2001)
	at org.netbeans.modules.openide.loaders.SimpleES.notifyModified(SimpleES.java:123)
	at org.openide.text.CloneableEditorSupport.callNotifyModified(CloneableEditorSupport.java:1974)
	at org.openide.text.CloneableEditorSupport$Listener.vetoableChange(CloneableEditorSupport.java:2836)
	at org.netbeans.editor.BaseDocument.atomicLockImpl(BaseDocument.java:1633)
	at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:343)
	at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1151)
	at org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:1076)
	at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:339)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1645)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2886)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
	at java.awt.Component.processEvent(Component.java:6150)
	at java.awt.Container.processEvent(Container.java:2085)
	at java.awt.Component.dispatchEventImpl(Component.java:4735)
	at java.awt.Container.dispatchEventImpl(Container.java:2143)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:712)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:990)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:855)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:676)
	at java.awt.Component.dispatchEventImpl(Component.java:4607)
	at java.awt.Container.dispatchEventImpl(Container.java:2143)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:679)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:638)
	at java.awt.EventQueue$1.run(EventQueue.java:636)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:652)
	at java.awt.EventQueue$2.run(EventQueue.java:650)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:649)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:162)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
[catch] at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

thanks
Comment 8 Jaroslav Tulach 2012-03-02 09:12:01 UTC
I've put the masterfs changes into ergonomics#6bf35b6df318. I wrote a test that should eliminate the above exception caused by already locked file, imho. Back to version control now.
Comment 9 Quality Engineering 2012-03-11 11:07:42 UTC
Integrated into 'main-golden', will be available in build *201203110400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6bf35b6df318
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #208657: The masterfs part of the changes. With documentation and test to verify the 'lock' state when IOException is thrown
Comment 10 Tomas Stupka 2012-03-13 13:50:17 UTC
fixed in core-main #5686e0db4f7d
Comment 11 Quality Engineering 2012-03-17 10:38:33 UTC
Integrated into 'main-golden', will be available in build *201203170400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5686e0db4f7d
User: Tomas Stupka <tstupka@netbeans.org>
Log: Issue #208657 - VCSInterceptor.beforeEdit should throw IOException if VCS operation failed