From de625e7bb5ebc85618aa9908442fda170974794e Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Thu, 4 Jan 2024 09:45:36 +0100 Subject: [PATCH] Proper exception in PreferencesService#setDefaultLookupOrder() #464 PreferencesService#setDefaultLookupOrder(String, String, String[]) has recently been changed to now throwing a NullPointerException instead of an IllegalArgumentException in case of any of its order arguments being null. This is incompatible with the API documentation in IPreferencesService. This change restores the existing behavior of throwing an IllegalArgumentException in the mentioned case. Fixes https://github.com/eclipse-equinox/equinox/issues/464 --- .../eclipse/core/internal/preferences/PreferencesService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java index a51a77c1083..35049cb84a2 100644 --- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java +++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java @@ -901,7 +901,9 @@ public void setDefaultLookupOrder(String qualifier, String key, String[] order) if (order == null) { DEFAULTS_REGISTRY.remove(registryKey); } else { - Arrays.asList(order).forEach(Objects::requireNonNull); + if (Arrays.stream(order).anyMatch(Objects::isNull)) { + throw new IllegalArgumentException(); + } DEFAULTS_REGISTRY.put(registryKey, order); } }