RFR: JDK-8314272: Improve java.util.prefs.BackingStoreException: Couldn't get file lock.

Alan Bateman alanb at openjdk.org
Wed Aug 16 14:44:09 UTC 2023


On Wed, 16 Aug 2023 13:36:38 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> We run into some BackingStoreException: Couldn't get file lock. e.g. here :
> 
> [JShell] Exception in thread "main" java.lang.IllegalStateException: java.util.prefs.BackingStoreException: Couldn't get file lock.
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder$PreferencesStorage.flush(JShellToolBuilder.java:313)
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellTool$ReplayableHistory.storeHistory(JShellTool.java:692)
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:1008)
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:261)
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
> [JShell] Caused by: java.util.prefs.BackingStoreException: Couldn't get file lock.
> [JShell] at java.prefs/java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:769)
> [JShell] at java.prefs/java.util.prefs.FileSystemPreferences.flush(FileSystemPreferences.java:864)
> [JShell] at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder$PreferencesStorage.flush(JShellToolBuilder.java:311)
> [JShell] ... 4 more
> 
> The BackingStoreException should be enhanced e.g. by adding the errno/errorCode that is already available in the coding

I don't object to improving  exception message but please try to keep the code consistent style if you can.

I think the main question with this change is whether it's okay from a security point of view as to whether an interesting file path might leak into a stack trace served up by a HTTP server. In other words, this one probably needs security input on whether it should be opt-in with jdk.includeInExceptions security config. It's somewhat awkward here as it's the java.prefs module, a faraway (and little used) module that java.base would rather not export anything to.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15308#issuecomment-1680742906


More information about the core-libs-dev mailing list