Update Jetty to 9.4.30.v20200611. (#10098)

* Update Jetty to 9.4.30.v20200611.

This is the latest version currently available in the 9.4.x line.

* Various adjustments.

* Class name fixes.

* Remove unused HttpClientModule code.

* Add coverage suppressions.

* Another coverage suppression.

* Fix wildcards.
This commit is contained in:
Gian Merlino 2020-07-07 14:24:02 -07:00 committed by GitHub
parent 98ac7dfeff
commit eeaf609fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 139 deletions

View File

@ -96,7 +96,10 @@ public class FriendlyServersTest
final HttpClient client = HttpClientInit.createClient(config, lifecycle);
final StatusResponseHolder response = client
.go(
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))),
new Request(
HttpMethod.GET,
new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))
),
StatusResponseHandler.getInstance()
).get();
@ -155,7 +158,10 @@ public class FriendlyServersTest
final HttpClient client = HttpClientInit.createClient(config, lifecycle);
final StatusResponseHolder response = client
.go(
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))),
new Request(
HttpMethod.GET,
new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))
),
StatusResponseHandler.getInstance()
).get();
@ -180,7 +186,7 @@ public class FriendlyServersTest
HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = new SslContextFactory();
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(keyStorePath);
sslContextFactory.setKeyStorePassword("abc123");
sslContextFactory.setKeyManagerPassword("abc123");

View File

@ -1661,7 +1661,7 @@ name: Jetty
license_category: binary
module: java-core
license_name: Apache License version 2.0
version: 9.4.12.v20180830
version: 9.4.30.v20200611
libraries:
- org.eclipse.jetty: jetty-client
- org.eclipse.jetty: jetty-continuation

View File

@ -91,7 +91,7 @@
<guava.version>16.0.1</guava.version>
<guice.version>4.1.0</guice.version>
<hamcrest.version>1.3</hamcrest.version>
<jetty.version>9.4.12.v20180830</jetty.version>
<jetty.version>9.4.30.v20200611</jetty.version>
<jersey.version>1.19.3</jersey.version>
<jackson.version>2.10.2</jackson.version>
<codehaus.jackson.version>1.9.13</codehaus.jackson.version>
@ -1268,6 +1268,9 @@
<!-- Ignore initialization classes, these are tested by the integration tests. -->
<exclude>org/apache/druid/cli/Cli*</exclude>
<exclude>org/apache/druid/cli/*JettyServerInitializer*</exclude>
<exclude>org/apache/druid/server/initialization/*Module*</exclude>
<exclude>org/apache/druid/server/initialization/jetty/*Module*</exclude>
<exclude>org/apache/druid/guice/http/*</exclude>
<!-- Ignore generated code -->
<exclude>org/apache/druid/math/expr/antlr/Expr*</exclude> <!-- core -->

View File

@ -19,6 +19,7 @@
package org.apache.druid.guice.http;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.inject.Binding;
import com.google.inject.Inject;
@ -32,6 +33,7 @@ import javax.net.ssl.SSLContext;
import java.lang.annotation.Annotation;
/**
*
*/
public abstract class AbstractHttpClientProvider<HttpClientType> implements Provider<HttpClientType>
{
@ -40,28 +42,10 @@ public abstract class AbstractHttpClientProvider<HttpClientType> implements Prov
private Injector injector;
public AbstractHttpClientProvider()
{
configKey = Key.get(
new TypeLiteral<Supplier<DruidHttpClientConfig>>()
{
}
);
sslContextKey = Key.get(SSLContext.class);
}
public AbstractHttpClientProvider(Annotation annotation)
{
configKey = Key.get(
new TypeLiteral<Supplier<DruidHttpClientConfig>>()
{
}, annotation
);
sslContextKey = Key.get(SSLContext.class, annotation);
}
public AbstractHttpClientProvider(Class<? extends Annotation> annotation)
{
Preconditions.checkNotNull(annotation, "annotation");
configKey = Key.get(
new TypeLiteral<Supplier<DruidHttpClientConfig>>()
{
@ -76,20 +60,11 @@ public abstract class AbstractHttpClientProvider<HttpClientType> implements Prov
this.injector = injector;
}
public Key<Supplier<DruidHttpClientConfig>> getConfigKey()
{
return configKey;
}
public Key<SSLContext> getSslContextKey()
{
return sslContextKey;
}
public Provider<Supplier<DruidHttpClientConfig>> getConfigProvider()
{
return injector.getProvider(configKey);
}
public Provider<Lifecycle> getLifecycleProvider()
{
return injector.getProvider(Lifecycle.class);

View File

@ -19,8 +19,10 @@
package org.apache.druid.guice.http;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Binder;
import com.google.inject.Binding;
import com.google.inject.Inject;
import com.google.inject.Module;
import org.apache.druid.guice.JsonConfigProvider;
@ -34,10 +36,12 @@ import org.apache.druid.java.util.http.client.HttpClientConfig;
import org.apache.druid.java.util.http.client.HttpClientInit;
import org.apache.druid.server.security.Escalator;
import javax.net.ssl.SSLContext;
import java.lang.annotation.Annotation;
import java.util.Set;
/**
*
*/
public class HttpClientModule implements Module
{
@ -55,68 +59,32 @@ public class HttpClientModule implements Module
ImmutableSet.of(EscalatedGlobal.class, EscalatedClient.class);
private final String propertyPrefix;
private Annotation annotation = null;
private Class<? extends Annotation> annotationClazz = null;
private boolean isEscalated = false;
private final Class<? extends Annotation> annotationClazz;
private final boolean isEscalated;
public HttpClientModule(String propertyPrefix)
public HttpClientModule(String propertyPrefix, Class<? extends Annotation> annotationClazz)
{
this.propertyPrefix = propertyPrefix;
}
this.propertyPrefix = Preconditions.checkNotNull(propertyPrefix, "propertyPrefix");
this.annotationClazz = Preconditions.checkNotNull(annotationClazz, "annotationClazz");
public HttpClientModule(String propertyPrefix, Class<? extends Annotation> annotation)
{
this.propertyPrefix = propertyPrefix;
this.annotationClazz = annotation;
isEscalated = ESCALATING_ANNOTATIONS.contains(annotationClazz);
}
public HttpClientModule(String propertyPrefix, Annotation annotation)
{
this.propertyPrefix = propertyPrefix;
this.annotation = annotation;
isEscalated = ESCALATING_ANNOTATIONS.contains(this.annotationClazz);
}
@Override
public void configure(Binder binder)
{
if (annotation != null) {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class, annotation);
binder.bind(HttpClient.class)
.annotatedWith(annotation)
.toProvider(new HttpClientProvider(annotation, isEscalated))
.in(LazySingleton.class);
} else if (annotationClazz != null) {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class, annotationClazz);
binder.bind(HttpClient.class)
.annotatedWith(annotationClazz)
.toProvider(new HttpClientProvider(annotationClazz, isEscalated))
.in(LazySingleton.class);
} else {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class);
binder.bind(HttpClient.class)
.toProvider(new HttpClientProvider(isEscalated))
.in(LazySingleton.class);
}
}
public static class HttpClientProvider extends AbstractHttpClientProvider<HttpClient>
{
private boolean isEscalated;
private final boolean isEscalated;
private Escalator escalator;
public HttpClientProvider(boolean isEscalated)
{
this.isEscalated = isEscalated;
}
public HttpClientProvider(Annotation annotation, boolean isEscalated)
{
super(annotation);
this.isEscalated = isEscalated;
}
public HttpClientProvider(Class<? extends Annotation> annotationClazz, boolean isEscalated)
{
super(annotationClazz);
@ -144,8 +112,10 @@ public class HttpClientModule implements Module
)
.withUnusedConnectionTimeoutDuration(config.getUnusedConnectionTimeout());
if (getSslContextBinding() != null) {
builder.withSslContext(getSslContextBinding().getProvider().get());
final Binding<SSLContext> sslContextBinding = getSslContextBinding();
if (sslContextBinding != null) {
builder.withSslContext(sslContextBinding.getProvider().get());
}
HttpClient client = HttpClientInit.createClient(

View File

@ -19,7 +19,9 @@
package org.apache.druid.guice.http;
import com.google.common.base.Preconditions;
import com.google.inject.Binder;
import com.google.inject.Binding;
import com.google.inject.Module;
import org.apache.druid.guice.JsonConfigProvider;
import org.apache.druid.guice.LazySingleton;
@ -29,10 +31,12 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import javax.net.ssl.SSLContext;
import java.lang.annotation.Annotation;
import java.util.concurrent.TimeUnit;
/**
*
*/
public class JettyHttpClientModule implements Module
{
@ -44,60 +48,26 @@ public class JettyHttpClientModule implements Module
}
private final String propertyPrefix;
private Annotation annotation = null;
private Class<? extends Annotation> annotationClazz = null;
private final Class<? extends Annotation> annotationClazz;
public JettyHttpClientModule(String propertyPrefix)
public JettyHttpClientModule(String propertyPrefix, Class<? extends Annotation> annotationClazz)
{
this.propertyPrefix = propertyPrefix;
}
public JettyHttpClientModule(String propertyPrefix, Class<? extends Annotation> annotation)
{
this.propertyPrefix = propertyPrefix;
this.annotationClazz = annotation;
}
public JettyHttpClientModule(String propertyPrefix, Annotation annotation)
{
this.propertyPrefix = propertyPrefix;
this.annotation = annotation;
this.propertyPrefix = Preconditions.checkNotNull(propertyPrefix, "propertyPrefix");
this.annotationClazz = Preconditions.checkNotNull(annotationClazz, "annotationClazz");
}
@Override
public void configure(Binder binder)
{
if (annotation != null) {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class, annotation);
binder.bind(HttpClient.class)
.annotatedWith(annotation)
.toProvider(new HttpClientProvider(annotation))
.in(LazySingleton.class);
} else if (annotationClazz != null) {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class, annotationClazz);
binder.bind(HttpClient.class)
.annotatedWith(annotationClazz)
.toProvider(new HttpClientProvider(annotationClazz))
.in(LazySingleton.class);
} else {
JsonConfigProvider.bind(binder, propertyPrefix, DruidHttpClientConfig.class);
binder.bind(HttpClient.class)
.toProvider(new HttpClientProvider())
.in(LazySingleton.class);
}
}
public static class HttpClientProvider extends AbstractHttpClientProvider<HttpClient>
{
public HttpClientProvider()
{
}
public HttpClientProvider(Annotation annotation)
{
super(annotation);
}
public HttpClientProvider(Class<? extends Annotation> annotation)
{
super(annotation);
@ -109,9 +79,10 @@ public class JettyHttpClientModule implements Module
final DruidHttpClientConfig config = getConfigProvider().get().get();
final HttpClient httpClient;
if (getSslContextBinding() != null) {
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(getSslContextBinding().getProvider().get());
final Binding<SSLContext> sslContextBinding = getSslContextBinding();
if (sslContextBinding != null) {
final SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
sslContextFactory.setSslContext(sslContextBinding.getProvider().get());
httpClient = new HttpClient(sslContextFactory);
} else {
httpClient = new HttpClient();

View File

@ -106,7 +106,7 @@ public class ChatHandlerServerModule implements Module
node,
config,
TLSServerConfig,
injector.getExistingBinding(Key.get(SslContextFactory.class)),
injector.getExistingBinding(Key.get(SslContextFactory.Server.class)),
injector.getInstance(TLSCertificateChecker.class)
);
}

View File

@ -132,7 +132,7 @@ public class CliIndexerServerModule implements Module
node,
makeAdjustedServerConfig(config),
TLSServerConfig,
injector.getExistingBinding(Key.get(SslContextFactory.class)),
injector.getExistingBinding(Key.get(SslContextFactory.Server.class)),
injector.getInstance(TLSCertificateChecker.class)
);
}

View File

@ -94,6 +94,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
/**
*
*/
public class JettyServerModule extends JerseyServletModule
{
@ -168,7 +169,7 @@ public class JettyServerModule extends JerseyServletModule
node,
config,
TLSServerConfig,
injector.getExistingBinding(Key.get(SslContextFactory.class)),
injector.getExistingBinding(Key.get(SslContextFactory.Server.class)),
injector.getInstance(TLSCertificateChecker.class)
);
}
@ -197,7 +198,7 @@ public class JettyServerModule extends JerseyServletModule
DruidNode node,
ServerConfig config,
TLSServerConfig tlsServerConfig,
Binding<SslContextFactory> sslContextFactoryBinding,
Binding<SslContextFactory.Server> sslContextFactoryBinding,
TLSCertificateChecker certificateChecker
)
{
@ -245,7 +246,8 @@ public class JettyServerModule extends JerseyServletModule
serverConnectors.add(connector);
}
final SslContextFactory sslContextFactory;
final SslContextFactory.Server sslContextFactory;
if (node.isEnableTlsPort()) {
log.info("Creating https connector with port [%d]", node.getTlsPort());
if (sslContextFactoryBinding == null) {
@ -498,7 +500,7 @@ public class JettyServerModule extends JerseyServletModule
}
}
private static class IdentityCheckOverrideSslContextFactory extends SslContextFactory
private static class IdentityCheckOverrideSslContextFactory extends SslContextFactory.Server
{
private final TLSServerConfig tlsServerConfig;
private final TLSCertificateChecker certificateChecker;
@ -508,7 +510,7 @@ public class JettyServerModule extends JerseyServletModule
TLSCertificateChecker certificateChecker
)
{
super(false);
super();
this.tlsServerConfig = tlsServerConfig;
this.certificateChecker = certificateChecker;
}