Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Sep 14, 2023
1 parent 2a172b4 commit 4319499
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.plugins;

import java.util.Locale;
import java.util.ServiceLoader;
import java.util.function.Supplier;

Expand Down Expand Up @@ -39,8 +40,8 @@ public static <T> T loadSingleton(ServiceLoader<T> loader, Supplier<T> fallback)
// in effectively twice in the call site, once to ServiceLoader, and then to this method directly as well.
// It's annoying that ServiceLoader hangs onto the service class, but does not expose it. It does at least
// print the service class from its toString, which is better tha nothing
throw new IllegalStateException("More than one extension found for %s".formatted(loader));
} else if (extensions.size() == 0) {
throw new IllegalStateException(String.format(Locale.ROOT, "More than one extension found for %s", loader));
} else if (extensions.isEmpty()) {
return fallback.get();
}
return extensions.get(0).get();
Expand Down

0 comments on commit 4319499

Please sign in to comment.