Issue #4340 - always pass in ServiceLoader to ServiceLoaderUtil
this prevents errors where jetty-util must declare it uses the provider class in module.info Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
81424f1f44
commit
a7f4d2606b
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.alpn.client;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.Executor;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class ALPNClientConnectionFactory extends NegotiatingClientConnectionFact
|
|||
IllegalStateException failure = new IllegalStateException("No Client ALPNProcessors!");
|
||||
|
||||
// Use a for loop on iterator so load exceptions can be caught and ignored
|
||||
for (Client processor : ServiceLoaderUtil.load(Client.class))
|
||||
for (Client processor : ServiceLoaderUtil.load(ServiceLoader.load(Client.class)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.alpn.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
|
@ -50,7 +51,7 @@ public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFact
|
|||
|
||||
IllegalStateException failure = new IllegalStateException("No Server ALPNProcessors!");
|
||||
// Use a for loop on iterator so load exceptions can be caught and ignored
|
||||
for (Server processor : ServiceLoaderUtil.load(Server.class))
|
||||
for (Server processor : ServiceLoaderUtil.load(ServiceLoader.load(Server.class)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -811,7 +812,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
long start = 0;
|
||||
if (LOG.isDebugEnabled())
|
||||
start = System.nanoTime();
|
||||
List<ServletContainerInitializer> scis = ServiceLoaderUtil.load(ServletContainerInitializer.class);
|
||||
List<ServletContainerInitializer> scis = ServiceLoaderUtil.load(ServiceLoader.load(ServletContainerInitializer.class));
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Service loaders found in {}ms", (TimeUnit.MILLISECONDS.convert((System.nanoTime() - start), TimeUnit.NANOSECONDS)));
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PreEncodedHttpField extends HttpField
|
|||
static
|
||||
{
|
||||
List<HttpFieldPreEncoder> encoders = new ArrayList<>();
|
||||
List<HttpFieldPreEncoder> discoveredEncoders = ServiceLoaderUtil.load(HttpFieldPreEncoder.class);
|
||||
List<HttpFieldPreEncoder> discoveredEncoders = ServiceLoaderUtil.load(ServiceLoader.load(HttpFieldPreEncoder.class));
|
||||
for (HttpFieldPreEncoder encoder : discoveredEncoders)
|
||||
{
|
||||
if (index(encoder.getHttpVersion()) >= 0)
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Enumeration;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -76,7 +77,7 @@ public abstract class SecurityHandler extends HandlerWrapper implements Authenti
|
|||
|
||||
static
|
||||
{
|
||||
__knownAuthenticatorFactories.addAll(ServiceLoaderUtil.load(Authenticator.Factory.class));
|
||||
__knownAuthenticatorFactories.addAll(ServiceLoaderUtil.load(ServiceLoader.load(Authenticator.Factory.class)));
|
||||
__knownAuthenticatorFactories.add(new DefaultAuthenticatorFactory());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,15 +36,15 @@ public class ServiceLoaderUtil
|
|||
* Uses the {@link ServiceLoader} to assemble the service providers into a list.
|
||||
* If loading a service type throws {@link ServiceConfigurationError},
|
||||
* it warns and continues iterating through the service loader.
|
||||
* @param service The interface or abstract class representing the service.
|
||||
* @param <T> The class of the service type.
|
||||
* @param serviceLoader The service loader to use.
|
||||
* @return a list of the loaded service providers.
|
||||
* @throws ServiceConfigurationError If the number of errors exceeds {@link #MAX_ERRORS}
|
||||
*/
|
||||
public static <T> List<T> load(Class<T> service)
|
||||
public static <T> List<T> load(ServiceLoader<T> serviceLoader)
|
||||
{
|
||||
List<T> list = new ArrayList<>();
|
||||
Iterator<T> iterator = ServiceLoader.load(service).iterator();
|
||||
Iterator<T> iterator = serviceLoader.iterator();
|
||||
|
||||
int errors = 0;
|
||||
while (true)
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.Serializable;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.eclipse.jetty.util.ServiceLoaderUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
@ -43,7 +44,7 @@ public abstract class Credential implements Serializable
|
|||
{
|
||||
private static final long serialVersionUID = -7760551052768181572L;
|
||||
private static final Logger LOG = Log.getLogger(Credential.class);
|
||||
private static final List<CredentialProvider> CREDENTIAL_PROVIDERS = ServiceLoaderUtil.load(CredentialProvider.class);
|
||||
private static final List<CredentialProvider> CREDENTIAL_PROVIDERS = ServiceLoaderUtil.load(ServiceLoader.load(CredentialProvider.class));
|
||||
|
||||
/**
|
||||
* Check a credential
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -74,7 +75,7 @@ public class Configurations extends AbstractList<Configuration> implements Dumpa
|
|||
{
|
||||
if (__known.isEmpty())
|
||||
{
|
||||
List<Configuration> configs = ServiceLoaderUtil.load(Configuration.class);
|
||||
List<Configuration> configs = ServiceLoaderUtil.load(ServiceLoader.load(Configuration.class));
|
||||
for (Configuration configuration : configs)
|
||||
{
|
||||
if (!configuration.isAvailable())
|
||||
|
|
|
@ -96,7 +96,7 @@ public class XmlConfiguration
|
|||
{
|
||||
ArrayList.class, HashSet.class, Queue.class, List.class, Set.class, Collection.class
|
||||
};
|
||||
private static final List<ConfigurationProcessorFactory> PROCESSOR_FACTORIES = ServiceLoaderUtil.load(ConfigurationProcessorFactory.class);
|
||||
private static final List<ConfigurationProcessorFactory> PROCESSOR_FACTORIES = ServiceLoaderUtil.load(ServiceLoader.load(ConfigurationProcessorFactory.class));
|
||||
private static final XmlParser PARSER = initParser();
|
||||
private static final Comparator<Executable> EXECUTABLE_COMPARATOR = (o1, o2) ->
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue