Skip to content

Commit f76c9e3

Browse files
committed
PrefService: fix prefs access on Windows
We were mistakenly using Preferences.systemRoot() to access our preferences paths. This caused terrible test failures on Windows for Jenkins, due to attempting to modify system registry entires. The intent of the PrefService was always to manage preferences at a per-user level, thus all Preferences should come from the userRoot instead.
1 parent 1bc9272 commit f76c9e3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/org/scijava/prefs/DefaultPrefService.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,8 @@ public void clear(final Class<?> c) {
226226
@Override
227227
public void clearAll() {
228228
try {
229-
final String[] childNames = Preferences.userRoot().childrenNames();
230-
for (final String name : childNames)
231-
Preferences.userRoot().node(name).removeNode();
229+
for (final String name : allPrefs())
230+
prefs(name).removeNode();
232231
}
233232
catch (final BackingStoreException e) {
234233
// do nothing
@@ -465,8 +464,12 @@ private Preferences prefs(final Class<?> c) {
465464
return Preferences.userNodeForPackage(c == null ? PrefService.class : c);
466465
}
467466

467+
private String[] allPrefs() throws BackingStoreException {
468+
return Preferences.userRoot().childrenNames();
469+
}
470+
468471
private Preferences prefs(final String absolutePath) {
469-
return Preferences.systemRoot().node(absolutePath);
472+
return Preferences.userRoot().node(absolutePath);
470473
}
471474

472475
private String key(final Class<?> c, final String name) {

0 commit comments

Comments
 (0)