views:

275

answers:

1

I have a system that is using java.util.prefs to cache the tiny/simple result of a (on-startup) SOAP call

Java's automatic sync is intermittently failing (1% of time using default JVM 30s backing store sync) dumping the following the exception:

Jan 8, 2010 12:30:07 PM java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.

I orginally suspected this bug but this was fixed in 1.5(tiger-b40) and our java 5 on this box is "1.5.0_16-b02"

I now suspect that it might be because we have multiple JVMs sharing this Backing Store, although this doesn't seem to happen on our other machines.

Can anyone confirm this? What are the risks, if any?

+1  A: 

"I now suspect that it might be because we have multiple JVMs sharing this Backing Store"

This could absolutely be the case! If two JVMs attempt to lock the file at the same then this is what you'll see.

The exact details will depend on the type of lock, operating system and file system.

You might want to try wrapping the operation that causes this in a try/catch block, then retry the operation if it fails.

Kevin Wright
Thanks for your reply. Unforunately the problem is that the the sync thread for Java Preferences is out of our control, so cannot catch Exceptions. Good critique here: http://www.allaboutbalance.com/articles/disableprefs/
HaveAGuess