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 258285

Summary: huge amount of IOException in message.log files
Product: cnd Reporter: Alexander Simon <alexvsimon>
Component: RemoteAssignee: Vladimir Kvashin <vkvashin>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: PC   
OS: Solaris   
Issue Type: DEFECT Exception Reporter:

Description Alexander Simon 2016-03-09 09:30:37 UTC
I'm trying to work with open JDK 8 project and see a lot of exceptions in message log:

 Can not download file tester@perf-linux:/export/home/tester/test_projects/jdk8/common/nb_native/nbproject/private/#Linux_64.properties#:
No such file
File does not exist: Can not download file tester@perf-linux:/export/home/tester/test_projects/jdk8/common/nb_native/nbproject/private/#Linux_64.properties#:
No such file
INFO [org.netbeans.modules.openide.filesystems.declmime.MIMEResolverImpl]: IOException in resolver FileElement(fast-check(magic:6e4270526f46694c6552mask:ffffffffffffffffffff) null Result:application/x-netbeans-profiler

msg
msg
Caused: java.io.IOException: Can not download file tester@perf-linux:/export/home/tester/test_projects/jdk8/common/nb_native/nbproject/private/#Linux_64.properties#:
No such file
	at org.netbeans.modules.remote.impl.fs.RemoteExceptions.createIOException(RemoteExceptions.java:65)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.ensureChildSync(RemoteDirectory.java:1589)
	at org.netbeans.modules.remote.impl.fs.RemotePlainFile.getInputStream(RemotePlainFile.java:364)
Caused: java.io.FileNotFoundException: File does not exist: Can not download file tester@perf-linux:/export/home/tester/test_projects/jdk8/common/nb_native/nbproject/private/#Linux_64.properties#:
No such file
	at org.netbeans.modules.remote.impl.fs.RemoteExceptions.createFileNotFoundException(RemoteExceptions.java:102)
	at org.netbeans.modules.remote.impl.fs.RemotePlainFile.newFileNotFoundException(RemotePlainFile.java:386)
	at org.netbeans.modules.remote.impl.fs.RemotePlainFile.getInputStream(RemotePlainFile.java:381)
	at org.netbeans.modules.remote.impl.fs.RemoteFileObject.getInputStream(RemoteFileObject.java:393)
	at org.openide.filesystems.MIMESupport$CachedFileObject.getInputStream(MIMESupport.java:402)
	at org.netbeans.modules.openide.filesystems.declmime.FileElement$Type.accept(FileElement.java:586)
	at org.netbeans.modules.openide.filesystems.declmime.FileElement$Type.access$300(FileElement.java:156)
[catch] at org.netbeans.modules.openide.filesystems.declmime.FileElement.resolve(FileElement.java:99)
	at org.netbeans.modules.openide.filesystems.declmime.MIMEResolverImpl$Impl.findMIMEType(MIMEResolverImpl.java:450)
	at org.openide.filesystems.MIMESupport$CachedFileObject.resolveMIME(MIMESupport.java:371)
	at org.openide.filesystems.MIMESupport$CachedFileObject.getMIMEType(MIMESupport.java:312)
	at org.openide.filesystems.MIMESupport.findMIMEType(MIMESupport.java:136)
	at org.openide.filesystems.FileUtil.getMIMEType(FileUtil.java:1311)
	at org.openide.filesystems.FileObject.getMIMEType(FileObject.java:667)
	at org.netbeans.modules.remote.impl.fs.RemoteFileObject.getMIMEType(RemoteFileObject.java:137)
	at org.netbeans.modules.cnd.modelimpl.platform.CsmEventDispatcher.isCOrCpp(CsmEventDispatcher.java:399)
	at org.netbeans.modules.cnd.modelimpl.platform.CsmEventDispatcher.isCOrCppOrInvalid(CsmEventDispatcher.java:410)
	at org.netbeans.modules.cnd.modelimpl.platform.CsmEventDispatcher.access$900(CsmEventDispatcher.java:87)
	at org.netbeans.modules.cnd.modelimpl.platform.CsmEventDispatcher$FileListener.fileDataCreated(CsmEventDispatcher.java:504)
	at org.openide.filesystems.FCLSupport$DispatchEventWrapper.dispatchEventImpl(FCLSupport.java:172)
	at org.openide.filesystems.FCLSupport$DispatchEventWrapperMulti.dispatchAllEventsSync(FCLSupport.java:248)
	at org.openide.filesystems.FCLSupport$DispatchEventWrapper.dispatchEvent(FCLSupport.java:137)
	at org.openide.filesystems.FCLSupport.dispatchEvent(FCLSupport.java:112)
	at org.openide.filesystems.FileObject$ED.dispatch(FileObject.java:1435)
	at org.openide.filesystems.FileSystem$EventDispatcher.run(FileSystem.java:795)
	at org.openide.filesystems.EventControl.dispatchEvent(EventControl.java:84)
	at org.openide.filesystems.FileSystem.dispatchEvent(FileSystem.java:554)
	at org.openide.filesystems.FileObject.dispatchEvent(FileObject.java:644)
	at org.openide.filesystems.FileObject.fireFileDataCreatedEvent(FileObject.java:596)
	at org.netbeans.modules.remote.impl.fs.RemoteFileObject.fireFileDataCreatedEvent(RemoteFileObject.java:191)
	at org.netbeans.modules.remote.impl.fs.RemoteFileObjectBase.fireFileDataCreatedEvent(RemoteFileObjectBase.java:152)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.fireRemoteFileObjectCreated(RemoteDirectory.java:433)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.updateChildren(RemoteDirectory.java:1323)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.getDirectoryStorageImpl(RemoteDirectory.java:1159)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.refreshDirectoryStorage(RemoteDirectory.java:545)
	at org.netbeans.modules.remote.impl.fs.RemoteDirectory.refreshImpl(RemoteDirectory.java:1691)
	at org.netbeans.modules.remote.impl.fs.RemoteFileObjectBase.refreshImpl(RemoteFileObjectBase.java:558)
	at org.netbeans.modules.remote.impl.fs.RefreshManager$RefreshWorker.run(RefreshManager.java:109)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
Comment 1 Vladimir Kvashin 2016-07-22 14:58:03 UTC
Bug reason
-----------

When a RemotePlainFile is written, it's first written to a temporary file (it's name is original file name that is prefixed and postfixed with "#"). Then it is renamed (on remote site) to original file name. This is done to lower the risk of data loss, see issue #227936.

But if another thread reads or refreshes this directory, this #$origname# file is added to directory content, notifications are sent, sniffing MIME resolvers try reading it... and at that moment it is already disappeared.

The fix
-------

Just filter out #$origname# files in the case the $origname is in the state of being written. 

Ideally this needs synchronization (for example, it might happen that it is not already being written, but it was when the directory content was read on remote site). But adding more sync here is very risky; the least problem it will introduce is slowness, more dangerous are possible deadlocks. So I left this without any synchronization, keeping in mind that file writing is slow, so the probability of getting such situation again is very low. The test that I wrote shows this. For that reason it can fail from time to time. But all my test runs succeeded so far.

fix:
http://hg.netbeans.org/cnd-main/rev/d21fcea771d1
test:
http://hg.netbeans.org/cnd-main/rev/d64c6082f3b9
Comment 2 Quality Engineering 2016-08-02 01:58:41 UTC
Integrated into 'main-silver', will be available in build *201608020002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d21fcea771d1
User: Vladimir Kvashin <vkvashin@netbeans.org>
Log: fix for #258285 - huge amount of IOException in message.log files