Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Java preference API for storing preferences #41

Open
tofi86 opened this issue May 28, 2018 · 2 comments
Open

Use Java preference API for storing preferences #41

tofi86 opened this issue May 28, 2018 · 2 comments

Comments

@tofi86
Copy link
Collaborator

tofi86 commented May 28, 2018

https://dev.to/argherna/the-java-preferences-api-is-a-little-thing-thats-a-huge-benefit-13ac

Saving string:

String newUrl = "https://secure.example.com/";
Preferences myConnectionPrefs = Preferences.userRoot().node("com/github/argherna/MyApplication/connections");

// Save the newUrl.
myConnectionPrefs.put("url", newUrl);

Reading strings:

Preferences myConnectionPrefs = Preferences.userRoot().node("com/github/argherna/MyApplication/connections");
String url = myConnectionPrefs.get("url", "http://example.com");

This rewrite would require to migrate the existing textfiles currently used for configuration storage.

@tofi86 tofi86 added this to the Version 1.8.0 milestone Dec 11, 2018
@tofi86
Copy link
Collaborator Author

tofi86 commented Jan 22, 2019

encountered some issues on Mac OS. Moving to next milestone.

@tofi86 tofi86 modified the milestones: Version 1.8.0, Next release Jan 22, 2019
@tofi86
Copy link
Collaborator Author

tofi86 commented Feb 7, 2019

Preferences API seems not to work in shutdown hooks:

Exception in thread "Thread-0" java.lang.IllegalStateException: Shutdown in progress
	at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
	at java.lang.Runtime.addShutdownHook(Runtime.java:211)
	at java.util.prefs.MacOSXPreferencesFile.timer(MacOSXPreferencesFile.java:344)
	at java.util.prefs.MacOSXPreferencesFile.markChanged(MacOSXPreferencesFile.java:282)
	at java.util.prefs.MacOSXPreferencesFile.addNode(MacOSXPreferencesFile.java:354)
	at java.util.prefs.MacOSXPreferences.<init>(MacOSXPreferences.java:107)
	at java.util.prefs.MacOSXPreferences.<init>(MacOSXPreferences.java:77)
	at java.util.prefs.MacOSXPreferences.getUserRoot(MacOSXPreferences.java:58)
	at java.util.prefs.MacOSXPreferencesFactory.userRoot(MacOSXPreferencesFactory.java:30)
	at java.util.prefs.Preferences.userRoot(Preferences.java:457)
	at de.paginagmbh.epubchecker.PreferenceManager.savePref(PreferenceManager.java:20)
	at de.paginagmbh.epubchecker.PaginaEPUBChecker$1.run(PaginaEPUBChecker.java:136)

I pushed the current code to a new branch test/41-java-prefs-api

tofi86 added a commit that referenced this issue Feb 7, 2019
@tofi86 tofi86 removed this from the Next release milestone Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant