Skip to content

Commit

Permalink
Merge pull request #81 from arteam/dependabot/maven/io.dropwizard-dro…
Browse files Browse the repository at this point in the history
…pwizard-dependencies-3.0.7

Bump io.dropwizard:dropwizard-dependencies from 2.1.4 to 3.0.7
  • Loading branch information
arteam authored May 13, 2024
2 parents 84f10c5 + 7def134 commit c252455
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 76 deletions.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-dependencies</artifactId>
<version>2.1.4</version>
<version>3.0.7</version>
</parent>

<name>Dropwizard Integration with Jetty HTTP/2 client</name>
Expand Down Expand Up @@ -107,6 +107,12 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.HttpConversation;
import org.eclipse.jetty.client.HttpRequest;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import java.net.URI;

Expand All @@ -24,11 +23,10 @@ public class InstrumentedHttpClient extends HttpClient {

public InstrumentedHttpClient(
HttpClientTransport transport,
SslContextFactory sslContextFactory,
MetricRegistry metricRegistry,
NameStrategy nameStrategy
) {
super(transport, sslContextFactory);
super(transport);
this.metricRegistry = metricRegistry;
this.nameStrategy = nameStrategy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import com.github.arteam.dropwizard.http2.client.names.NameStrategy;
import com.github.arteam.dropwizard.http2.client.transport.ClientTransportFactory;
import com.google.common.base.Strings;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.setup.Environment;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.util.HttpCookieStore;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -40,8 +39,7 @@ public HttpClient build(@Nullable String name) {
ClientTransportFactory connectionFactoryBuilder = configuration.getConnectionFactoryBuilder();

final NameStrategy naming = NameStrategies.prefixedStrategy(HttpClient.class, name, NameStrategies.HOST);
HttpClient httpClient = new InstrumentedHttpClient(connectionFactoryBuilder.httpClientTransport(),
connectionFactoryBuilder.sslContextFactory(), environment.metrics(), naming);
HttpClient httpClient = new InstrumentedHttpClient(connectionFactoryBuilder.httpClientTransport(), environment.metrics(), naming);
httpClient.setConnectTimeout(configuration.getConnectionTimeout().toMilliseconds());
httpClient.setIdleTimeout(configuration.getIdleTimeout().toMilliseconds());
httpClient.setFollowRedirects(configuration.isFollowRedirects());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import io.dropwizard.jackson.Discoverable;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import javax.annotation.Nullable;

/**
* Date: 11/26/15
Expand All @@ -21,14 +18,6 @@
defaultImpl = Http2ClientTransportFactory.class)
public interface ClientTransportFactory extends Discoverable {

/**
* Configures the SSL context for an HTTP/2 client.
*
* @return a configured {@link SslContextFactory}
*/
@Nullable
SslContextFactory sslContextFactory();

/**
* Configures the transport implementation for an HTTP/2 client
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import javax.annotation.Nullable;

/**
* Date: 11/26/15
Expand All @@ -25,17 +21,10 @@
@JsonTypeName("h2c")
public class Http2ClearClientTransportFactory implements ClientTransportFactory {

@Override
@Nullable
public SslContextFactory sslContextFactory() {
return null;
}

@Override
public HttpClientTransport httpClientTransport() {
// Explicitly set the HTTP/2 connection factory, because we don't need SSL and ALPN.
final HTTP2Client client = new HTTP2Client();
client.setClientConnectionFactory(new HTTP2ClientConnectionFactory());
return new HttpClientTransportOverHTTP2(client);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package com.github.arteam.dropwizard.http2.client.transport;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.hibernate.validator.constraints.NotEmpty;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;

/**
Expand All @@ -38,10 +32,9 @@ public class Http2ClientTransportFactory extends HttpsClientFactory implements C

@Override
public HttpClientTransport httpClientTransport() {
// If we don't specify a connection factory, an SSL connection factory with
// ALPN and HTTP/2 will be used by default. The configured SslContextFactory
// will be passed from HttpClient.
HTTP2Client http2Client = new HTTP2Client();
ClientConnector connector = new ClientConnector();
connector.setSslContextFactory(sslContextFactory());
HTTP2Client http2Client = new HTTP2Client(connector);
http2Client.setExecutor(executor);
http2Client.setByteBufferPool(byteBufferPool);
return new HttpClientTransportOverHTTP2(http2Client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@
import com.google.common.base.MoreObjects;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import javax.annotation.Nullable;

@JsonTypeName("http")
public class HttpClientTransportFactory implements ClientTransportFactory {
@Nullable
@Override
public SslContextFactory sslContextFactory() {
return null;
}

@Override
public HttpClientTransport httpClientTransport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class HttpsClientFactory {
private String jceProvider;

private boolean trustAll = false;
private String endpointIdentificationAlgorithm = "HTTPS";

@JsonProperty
public boolean isValidatePeers() {
Expand Down Expand Up @@ -196,9 +197,19 @@ public void setTrustAll(boolean trustAll) {
this.trustAll = trustAll;
}

@JsonProperty
public String getEndpointIdentificationAlgorithm() {
return endpointIdentificationAlgorithm;
}

@JsonProperty
public void setEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm) {
this.endpointIdentificationAlgorithm = endpointIdentificationAlgorithm;
}

@Nullable
public SslContextFactory sslContextFactory() {
SslContextFactory factory = new SslContextFactory.Client(trustAll);
public SslContextFactory.Client sslContextFactory() {
SslContextFactory.Client factory = new SslContextFactory.Client(trustAll);
if (keyStorePath != null) {
factory.setKeyStorePath(keyStorePath);
}
Expand Down Expand Up @@ -247,6 +258,7 @@ public SslContextFactory sslContextFactory() {
if (jceProvider != null) {
factory.setProvider(jceProvider);
}
factory.setEndpointIdentificationAlgorithm(endpointIdentificationAlgorithm);

return factory;
}
Expand All @@ -269,6 +281,7 @@ public String toString() {
.add("validateCerts", validateCerts)
.add("validatePeers", validatePeers)
.add("jceProvider", jceProvider)
.add("endpointIdentificationAlgorithm", endpointIdentificationAlgorithm)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import com.google.common.base.MoreObjects;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.io.ClientConnector;

@JsonTypeName("https")
public class HttpsClientTransportFactory extends HttpsClientFactory implements ClientTransportFactory {
@Override
public HttpClientTransport httpClientTransport() {
return new HttpClientTransportOverHTTP();
ClientConnector connector = new ClientConnector();
connector.setSslContextFactory(sslContextFactory());
return new HttpClientTransportOverHTTP(connector);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.arteam.dropwizard.http2.client;

import com.codahale.metrics.health.HealthCheck;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.Application;
import io.dropwizard.core.setup.Environment;
import org.eclipse.jetty.client.HttpClient;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.arteam.dropwizard.http2.client;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;

/**
* @author Artem Prigoda (a.prigoda)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.health.HealthCheckRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.jersey.validation.Validators;
import io.dropwizard.logging.BootstrapLogging;
import io.dropwizard.setup.Environment;
import io.dropwizard.logging.common.BootstrapLogging;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.arteam.dropwizard.http2.client.transport.Http2ClearClientTransportFactory;
import com.github.arteam.dropwizard.http2.client.transport.Http2ClientTransportFactory;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.lifecycle.setup.LifecycleEnvironment;
import io.dropwizard.logging.BootstrapLogging;
import io.dropwizard.setup.Environment;
import io.dropwizard.logging.common.BootstrapLogging;
import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.FixtureHelpers;
import io.dropwizard.testing.ResourceHelpers;
import io.dropwizard.testing.junit5.DropwizardAppExtension;
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport;
Expand Down Expand Up @@ -80,7 +79,7 @@ public void testH2c() throws Exception {
String response = client.GET(String.format("http://127.0.0.1:%d/application/greet", h2c.getLocalPort()))
.getContentAsString();
assertThat(objectMapper.readTree(response))
.isEqualTo(objectMapper.readTree(FixtureHelpers.fixture("server_response.json")));
.isEqualTo(objectMapper.readTree(getClass().getResource("/server_response.json")));
}

@Test
Expand All @@ -91,6 +90,7 @@ public void testH2() throws Exception {
h2transport.setTrustStorePassword("h2_client");
h2transport.setValidatePeers(false);
h2transport.setTrustAll(true);
h2transport.setEndpointIdentificationAlgorithm(null);
h2conf.setConnectionFactoryBuilder(h2transport);

HttpClient client = new JettyClientBuilder(environment)
Expand All @@ -99,6 +99,6 @@ public void testH2() throws Exception {
String response = client.GET(String.format("https://127.0.0.1:%d/application/greet", h2.getLocalPort()))
.getContentAsString();
assertThat(objectMapper.readTree(response))
.isEqualTo(objectMapper.readTree(FixtureHelpers.fixture("server_response.json")));
.isEqualTo(objectMapper.readTree(getClass().getResource("/server_response.json")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import com.codahale.metrics.health.HealthCheckRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.arteam.dropwizard.http2.client.transport.Http2ClientTransportFactory;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.jersey.validation.Validators;
import io.dropwizard.logging.BootstrapLogging;
import io.dropwizard.setup.Environment;
import io.dropwizard.logging.common.BootstrapLogging;
import org.conscrypt.OpenSSLProvider;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public void after() throws Exception {

@Test
public void testInstrumentation() throws Exception {
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(),
null, metrics, NameStrategies.prefixedStrategy(MetricRegistry.name(HTTP2Client.class), NameStrategies.HOST));
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(), metrics, NameStrategies.prefixedStrategy(MetricRegistry.name(HTTP2Client.class), NameStrategies.HOST));
client.start();
client.GET(String.format("http://127.0.0.1:%d/application/greet-chunk", rule.getLocalPort())).getContentAsString();
final Timer ttfb = metrics.getTimers().get("org.eclipse.jetty.http2.client.HTTP2Client.127.0.0.1.time-to-first-byte");
Expand Down Expand Up @@ -75,8 +74,7 @@ public void testInstrumentation() throws Exception {
@Test
public void testMethodStrategy() throws Exception {
final MetricRegistry metrics = new MetricRegistry();
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(),
null, metrics, NameStrategies.METHOD);
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(), metrics, NameStrategies.METHOD);
client.start();
client.GET(String.format("http://127.0.0.1:%d/application/greet-chunk", rule.getLocalPort())).getContentAsString();
assertThat(metrics.getTimers()).containsKey("GET.time-to-first-byte");
Expand All @@ -85,8 +83,7 @@ public void testMethodStrategy() throws Exception {
@Test
public void testFullNameStrategy() throws Exception {
final MetricRegistry metrics = new MetricRegistry();
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(),
null, metrics, NameStrategies.FULL);
client = new InstrumentedHttpClient(new HttpClientTransportOverHTTP(), metrics, NameStrategies.FULL);
client.start();
client.GET(String.format("http://127.0.0.1:%d/application/greet-chunk", rule.getLocalPort())).getContentAsString();
assertThat(metrics.getTimers()).containsKey("127.0.0.1.GET./application/greet-chunk.time-to-first-byte");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.dropwizard.configuration.YamlConfigurationFactory;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.jersey.validation.Validators;
import io.dropwizard.logging.BootstrapLogging;
import io.dropwizard.logging.common.BootstrapLogging;
import io.dropwizard.util.Duration;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.arteam.dropwizard.http2.client;

import com.codahale.metrics.health.HealthCheck;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.Application;
import io.dropwizard.core.setup.Environment;

/**
* Date: 1/4/16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.arteam.dropwizard.http2.client;

import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;

/**
* Date: 1/4/16
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/http2-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ server:
keyStorePassword: 'h2_server'
validateCerts: false
validatePeers: false
disableSniHostCheck: true

0 comments on commit c252455

Please sign in to comment.