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 204226 - core.startup.preferences.PropertiesStorage.outputStream may not properly close the stream
Summary: core.startup.preferences.PropertiesStorage.outputStream may not properly clos...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Options&Settings (show other bugs)
Version: 7.0
Hardware: All All
: P2 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords: 8.1_WAIVER_APPROVED
Depends on:
Blocks:
 
Reported: 2011-10-25 15:55 UTC by bedomon
Modified: 2017-03-30 21:07 UTC (History)
24 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 178949


Attachments
stacktrace (2.42 KB, text/plain)
2011-10-25 15:55 UTC, bedomon
Details
stacktrace (2.42 KB, text/plain)
2011-12-04 04:51 UTC, jleicht
Details
stacktrace (2.42 KB, text/plain)
2013-03-13 03:54 UTC, alied
Details
stacktrace (2.42 KB, text/plain)
2013-04-24 19:01 UTC, alied
Details
Code that simulates problematic antivirus (5.32 KB, text/plain)
2015-11-05 14:54 UTC, Jaroslav Havlin
Details
Unsuccessful patch (4.25 KB, patch)
2015-11-05 15:12 UTC, Jaroslav Havlin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bedomon 2011-10-25 15:55:13 UTC
Build: NetBeans IDE Dev (Build 201109260601)
VM: Java HotSpot(TM) Client VM, 17.1-b03, Java(TM) SE Runtime Environment, 1.6.0_22-b04
OS: Windows XP

User Comments:
cpeltier: The problem occured as I was typing php code.
It happened on the last "=" of the code:
$myarray = array(
	"value1" => $value1,
	...
	"valueN" =
);

bedomon: I was doing ... nothing....

psusen: Select regex text and copied.




Stacktrace: 
java.lang.Exception
   at org.openide.filesystems.StreamPool$NotifyOutputStream.<init>(StreamPool.java:359)
   at org.openide.filesystems.StreamPool.createOutputStream(StreamPool.java:138)
   at org.openide.filesystems.AbstractFileObject.getOutputStream(AbstractFileObject.java:244)
   at org.openide.filesystems.AbstractFileObject.getOutputStream(AbstractFileObject.java:226)
   at org.openide.filesystems.MultiFileObject.getOutputStream(MultiFileObject.java:685)
   at org.openide.filesystems.MultiFileObject.getOutputStream(MultiFileObject.java:685)
Comment 1 bedomon 2011-10-25 15:55:22 UTC
Created attachment 112414 [details]
stacktrace
Comment 2 jleicht 2011-12-04 04:51:46 UTC
Created attachment 113799 [details]
stacktrace

1)opened existing project:  HTMLEditorSample (obtained from: http://docs.oracle.com/javafx/2.0/ui_controls/overview.htm#)
2)opened new project (proven FX2.0 platform) named HTMLEditorSample2
3)moved HTMLEditorSample.java into new project HTMLEditorSample2
4)copied imports from original to new project
5)copied all lines from after class declaration to end from original into and overlaying same in new proj.
6)deleted original project.
7)saved HTMLEditorSample2, then Shift F11.
8)F6
9)Enclosed error occurred...........
Comment 3 Exceptions Reporter 2011-12-22 18:37:27 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=178949
Comment 4 alied 2013-03-13 03:54:41 UTC
Created attachment 132541 [details]
stacktrace

after cut (Ctrl+X) ina a VisualDesign JME source file
Comment 5 alied 2013-04-24 19:01:16 UTC
Created attachment 133773 [details]
stacktrace

happened again and just keep popping and popping.
Comment 6 soldatov 2014-12-07 22:41:21 UTC
On http://statistics.netbeans.org/exceptions/detail.do?id=178949 page I see 118 duplicates.
Comment 7 Theofanis Oikonomou 2015-09-11 15:23:11 UTC
All reports after 22.02.2014 (8.0 beta) refer to already locked Preferences/org/netbeans/modules/uihandler.properties. Only report #783278 refers to Preferences/org/netbeans/api/search/FindDialogMemory.properties
Comment 8 Theofanis Oikonomou 2015-09-24 13:50:16 UTC
This is really difficult to reproduce. On Linux I actually had to delete uihandler.properties file right after it got created while debugging. In the majority of the latest reports there is this stacktrace that seems to be causing the problem:

SEVERE [org.openide.util.Exceptions]
java.io.FileNotFoundException: C:\Users\Ed\AppData\Roaming\NetBeans\8.1beta\config\Preferences\org\netbeans\modules\uihandler.properties (The requested operation cannot be performed on a file with a user-mapped section open)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
	at org.openide.filesystems.LocalFileSystem.outputStream(LocalFileSystem.java:446)
	at org.openide.filesystems.LocalFileSystem$Impl.outputStream(LocalFileSystem.java:678)
	at org.openide.filesystems.StreamPool.createOutputStream(StreamPool.java:142)
	at org.openide.filesystems.AbstractFileObject.getOutputStream(AbstractFileObject.java:254)
	at org.openide.filesystems.AbstractFileObject.getOutputStream(AbstractFileObject.java:236)
	at org.openide.filesystems.MultiFileObject.getOutputStream(MultiFileObject.java:692)
	at org.openide.filesystems.MultiFileObject.getOutputStream(MultiFileObject.java:692)
	at org.netbeans.core.startup.preferences.PropertiesStorage.outputStream(PropertiesStorage.java:268)
	at org.netbeans.core.startup.preferences.PropertiesStorage.save(PropertiesStorage.java:238)
	at org.netbeans.core.startup.preferences.NbPreferences.flushSpi(NbPreferences.java:244)
Caused: java.util.prefs.BackingStoreException
	at org.netbeans.core.startup.preferences.NbPreferences.flushSpi(NbPreferences.java:247)
[catch] at org.netbeans.core.startup.preferences.NbPreferences$1$1.run(NbPreferences.java:86)
	at org.netbeans.core.startup.preferences.PropertiesStorage$3.run(PropertiesStorage.java:355)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:499)
	at org.netbeans.core.startup.preferences.PropertiesStorage.runAtomic(PropertiesStorage.java:353)
	at org.netbeans.core.startup.preferences.NbPreferences$1.run(NbPreferences.java:81)
	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)

All recent reports are from windows, are about uihandler.properties and have similar stacktraces. NbPreferences code that calls PropertiesStorage functions are in a synchronized block which is using the same lock as AbstractPreferences. Maybe the issue is somewhere in filesystems? Need to investigate further. It is really tricky to try a fix this late for 8.1, so asking for the waiver. Thank you
Comment 9 Jiri Kovalsky 2015-09-30 13:27:50 UTC
Bug waiver for 8.1 approved.
Comment 10 Theofanis Oikonomou 2015-10-08 16:03:08 UTC
I need some help from filesystems. Jardo, please see my comment 8. 

It seems that PropertiesStorage.outputStream successfully acquires a lock on the FO of the properties file but then when filesystem is asked to open the file it throws the FNFE initialized from LocalFileSystem.outputStream. 

This yields the question how I could obtain the lock on the FO if the file was deleted? Or maybe if it got deleted after I got the lock how to survive this? Could the fix be as simple as trying to determine if it actually exists before trying to open it? Thank you
Comment 11 Jaroslav Havlin 2015-10-27 14:46:50 UTC
Some other process may lock the file.

Reporters, do you use some anti-virus software?
Thank you.
Comment 12 alied 2015-10-28 02:54:23 UTC
By the time I reported it I was indeed using an antivirus (I was in Windows back in those days)
Comment 13 jan.kurnatowski 2015-10-29 09:19:55 UTC
I was using Kaspersky Internet Security for Windows
Comment 14 Jaroslav Havlin 2015-11-05 14:54:59 UTC
Created attachment 157163 [details]
Code that simulates problematic antivirus

Sample code that adds file listeners to some directory (NetBeans userdir) and create file-mapped memory buffer if some file is changed (antivirus software probably does something similar to check new file contents).
(Note: The directory path is hardcoded.)
Comment 15 Jaroslav Havlin 2015-11-05 15:12:30 UTC
Created attachment 157164 [details]
Unsuccessful patch

I've tried to fix the bug by allowing several attempts when getting the input or output stream in LocalFileSystem. Unfortunately, this did not help much. Sometimes the number of tries or wait time was not enough, and there was quite a lot of some other I/O errors.
(But maybe our fake anti-virus is too aggressive, and the fix would work in the real world. We'll need to test it, but I haven't managed to set the environment yet.)

I'm not sure this is fixable in NetBeans. The anti-virus software should be configured to skip NetBeans directories. It would very probably help.