From 5b505006e7187fd8c49594ae4eca1cc2a133e0b6 Mon Sep 17 00:00:00 2001 From: Gus Heck Date: Tue, 16 May 2023 15:48:43 -0400 Subject: [PATCH] Improve error message if codec not found Fixes #12300 --- .../java/org/apache/lucene/util/NamedSPILoader.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java b/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java index 62055aac3c7..6bc1fcf341d 100644 --- a/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java +++ b/lucene/core/src/java/org/apache/lucene/util/NamedSPILoader.java @@ -99,6 +99,8 @@ public final class NamedSPILoader implements return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9'); } + @SuppressWarnings("removal") + @SuppressForbidden(reason = "security manager") public S lookup(String name) { final S service = services.get(name); if (service != null) return service; @@ -110,7 +112,13 @@ public final class NamedSPILoader implements + "' does not exist." + " You need to add the corresponding JAR file supporting this SPI to your classpath." + " The current classpath supports the following names: " - + availableServices()); + + availableServices() + + ((System.getSecurityManager() == null) + ? "" + : "We have detected that a security manager is installed so it is also possible " + + "that the jar containing the codec is inaccessible under the current " + + "security policy. (Java does not throw SecurityException if this is the " + + "case, it just ignores the jar!)")); } public Set availableServices() {