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 200114 - Changes to NbPreferences occasionally not saved due to a sync problem
Summary: Changes to NbPreferences occasionally not saved due to a sync problem
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Options&Settings (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks: 198665
  Show dependency tree
 
Reported: 2011-07-13 15:08 UTC by Ondrej Vrabec
Modified: 2012-03-06 10:57 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test (1.88 KB, patch)
2011-07-13 15:21 UTC, Ondrej Vrabec
Details | Diff
a simple fix (1.39 KB, text/x-diff)
2011-07-13 15:31 UTC, Ondrej Vrabec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Vrabec 2011-07-13 15:08:42 UTC
Product Version = NetBeans IDE Dev (Build 20110711-19a9d9a0205b)
Operating System = Linux version 2.6.37.6-0.5-desktop running on amd64
Java; VM; Vendor = 1.6.0_26
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.1-b02

Since the fix for #198665 our tests (in versioning) started failing occasionally. After a long digging and debugging NbPreferences' code i came across a probable cause. If i understand correctly, modifying prefs comes in the following steps:
1) value is stored in memory in a map of properties
2) an async task is run after 200 ms that takes the map and persists it on disk in a preferences file
3) at the end of the async task FS fires a fileChanged event that results in calling NbPreferences.stateChanged method that empties the whole property map kept in memory

Now what happens when someone calls NbPreferences.put(...) right between 2) and 3)? Unless i am mistaken, the change is not stored and instead dropped into a black hole. I'll attaching a test demonstrating the problem (but it's an artificial one).
Hard to say if this may affect something other than unit tests, but you should definitely at least know about this.
Comment 1 Ondrej Vrabec 2011-07-13 15:21:42 UTC
Created attachment 109421 [details]
test
Comment 2 Ondrej Vrabec 2011-07-13 15:31:05 UTC
maybe something like this could help, although it's probably not a 100% bulletproof fix
Comment 3 Ondrej Vrabec 2011-07-13 15:31:10 UTC
Created attachment 109422 [details]
a simple fix
Comment 4 Yulia Novozhilova 2011-07-18 13:04:56 UTC
Thank you, Ondrej. Will be fixed together with #198665 and #197594 .
Comment 5 Theofanis Oikonomou 2012-03-06 10:57:23 UTC
This should be fixed now. See 197594#c40