From 93fc277aa1b9a04de367a9ab13abd1aafa496e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20R=C5=BCysko?= Date: Tue, 16 Jan 2024 15:01:28 +0100 Subject: [PATCH] Upgrade spring boot to 3.2.1 (#1813) --- build.gradle | 8 ++--- hermes-client/build.gradle | 1 + hermes-consumers/build.gradle | 2 +- .../config/ConsumerSenderConfiguration.java | 2 +- .../oauth/client/OAuthHttpClient.java | 29 ++++++++++++------- .../consumer/sender/MessageSendingResult.java | 2 +- .../sender/SingleMessageSendingResult.java | 2 +- .../sender/http/BatchHttpRequestFactory.java | 2 +- .../http/DefaultBatchHttpRequestFactory.java | 15 ++++------ .../http/DefaultHttpMetadataAppender.java | 4 +-- .../http/DefaultHttpRequestFactory.java | 14 ++++----- .../DefaultHttpRequestFactoryProvider.java | 4 +-- .../http/DefaultSendingResultHandlers.java | 4 +-- .../sender/http/HttpClientsFactory.java | 10 +++---- .../http/HttpClientsWorkloadReporter.java | 2 +- .../sender/http/HttpRequestFactory.java | 2 +- .../http/HttpRequestFactoryProvider.java | 2 +- .../http/JettyBroadCastMessageSender.java | 2 +- .../http/JettyBroadCastResponseListener.java | 4 +-- .../http/JettyHttpMessageSenderProvider.java | 2 +- .../sender/http/JettyMessageBatchSender.java | 4 +-- .../sender/http/JettyMessageSender.java | 2 +- .../sender/http/JettyResponseListener.java | 4 +-- .../sender/http/SendingResultHandlers.java | 4 +-- .../HttpClientsWorkloadReporterTest.groovy | 4 +-- .../JettyBroadCastMessageSenderTest.groovy | 6 ++-- .../config/console/ConsoleConfiguration.java | 20 +++++++++++-- hermes-mock/build.gradle | 2 +- .../tech/hermes/mock/HermesMockDefine.java | 2 +- .../tech/hermes/mock/HermesMockQuery.java | 2 +- .../tech/hermes/mock/exchange/Response.java | 4 +-- .../mock/matching/StartsWithPattern.java | 2 +- 32 files changed, 89 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index be812a0157..02013d9f32 100644 --- a/build.gradle +++ b/build.gradle @@ -52,22 +52,22 @@ allprojects { guava : '23.0', jackson : '2.15.2', jersey : '3.1.2', - jetty : '11.0.15', + jetty : '12.0.5', curator : '5.4.0', dropwizard_metrics: '4.1.0', micrometer_metrics: '1.11.1', - wiremock : '3.0.1', + wiremock : '3.3.1', spock : '2.4-M1-groovy-4.0', groovy : '4.0.12', avro : '1.9.1', json2avro : '0.2.14', okhttp : '3.9.1', undertow : '2.0.29.Final', - spring_web : '6.0.8', + spring_web : '6.1.2', failsafe : '2.3.1', junit_jupiter : '5.8.2', testcontainers : '1.18.1', - spring : '3.0.6', + spring : '3.2.1', assertj : '3.22.0' ] diff --git a/hermes-client/build.gradle b/hermes-client/build.gradle index 4839a6e378..01d5625a15 100644 --- a/hermes-client/build.gradle +++ b/hermes-client/build.gradle @@ -25,6 +25,7 @@ dependencies { testImplementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: versions.jersey testImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: versions.jersey testImplementation group: 'org.springframework', name: 'spring-web', version: versions.spring_web + testImplementation group: 'org.springframework', name: 'spring-context', version: versions.spring_web testImplementation group: 'org.springframework', name: 'spring-webflux', version: versions.spring_web testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp testImplementation group: 'io.projectreactor.netty', name: 'reactor-netty', version: '1.0.25' diff --git a/hermes-consumers/build.gradle b/hermes-consumers/build.gradle index 44c66d5dc3..292efde6fe 100644 --- a/hermes-consumers/build.gradle +++ b/hermes-consumers/build.gradle @@ -17,7 +17,7 @@ dependencies { api group: 'org.springframework.boot', name: 'spring-boot-starter', version: versions.spring api group: 'org.eclipse.jetty', name: 'jetty-alpn-java-client', version: versions.jetty - api group: 'org.eclipse.jetty.http2', name: 'http2-http-client-transport', version: versions.jetty + api group: 'org.eclipse.jetty.http2', name: 'jetty-http2-client-transport', version: versions.jetty implementation group: 'org.jctools', name: 'jctools-core', version: '1.2' diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/config/ConsumerSenderConfiguration.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/config/ConsumerSenderConfiguration.java index 1958e4bff0..97d76ff8e8 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/config/ConsumerSenderConfiguration.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/config/ConsumerSenderConfiguration.java @@ -11,7 +11,7 @@ import com.google.common.collect.ImmutableSet; import jakarta.inject.Named; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/oauth/client/OAuthHttpClient.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/oauth/client/OAuthHttpClient.java index 338085a1b0..cc0dc18849 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/oauth/client/OAuthHttpClient.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/oauth/client/OAuthHttpClient.java @@ -2,9 +2,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.entity.ContentType; +import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; @@ -40,21 +40,28 @@ private Request createHttpRequest(OAuthTokenRequest request) { .timeout(request.getRequestTimeout(), TimeUnit.MILLISECONDS) .idleTimeout(request.getSocketTimeout(), TimeUnit.MILLISECONDS) .method(HttpMethod.POST) - .header(HttpHeader.KEEP_ALIVE, "true") - .header(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) - .param(OAuthTokenRequest.Param.GRANT_TYPE, request.getGrantType()) - .param(OAuthTokenRequest.Param.SCOPE, request.getScope()) - .param(OAuthTokenRequest.Param.CLIENT_ID, request.getClientId()) - .param(OAuthTokenRequest.Param.CLIENT_SECRET, request.getClientSecret()); + .headers(headers -> { + headers.add(HttpHeader.KEEP_ALIVE, "true"); + headers.add(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); + }); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.GRANT_TYPE, request.getGrantType()); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.SCOPE, request.getScope()); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.CLIENT_ID, request.getClientId()); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.CLIENT_SECRET, request.getClientSecret()); if (OAuthTokenRequest.GrantTypeValue.RESOURCE_OWNER_USERNAME_PASSWORD.equals(request.getGrantType())) { - httpRequest - .param(OAuthTokenRequest.Param.USERNAME, request.getUsername()) - .param(OAuthTokenRequest.Param.PASSWORD, request.getPassword()); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.USERNAME, request.getUsername()); + addParamIfNotNull(httpRequest, OAuthTokenRequest.Param.PASSWORD, request.getPassword()); } return httpRequest; } + private void addParamIfNotNull(Request request, String name, String value) { + if (value != null) { + request.param(name, value); + } + } + private ContentResponse performHttpRequest(OAuthTokenRequest request) { try { return createHttpRequest(request).send(); diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/MessageSendingResult.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/MessageSendingResult.java index c5458fbaee..6ce56cfa0a 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/MessageSendingResult.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/MessageSendingResult.java @@ -1,6 +1,6 @@ package pl.allegro.tech.hermes.consumers.consumer.sender; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; import pl.allegro.tech.hermes.consumers.consumer.sender.resolver.EndpointAddressResolutionException; import java.net.URI; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/SingleMessageSendingResult.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/SingleMessageSendingResult.java index 0690740b76..5ca3c26236 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/SingleMessageSendingResult.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/SingleMessageSendingResult.java @@ -3,7 +3,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import jakarta.ws.rs.core.Response; -import org.eclipse.jetty.client.api.Result; +import org.eclipse.jetty.client.Result; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import pl.allegro.tech.hermes.common.exception.InternalProcessingException; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/BatchHttpRequestFactory.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/BatchHttpRequestFactory.java index b5d31e5f07..737576ba15 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/BatchHttpRequestFactory.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/BatchHttpRequestFactory.java @@ -1,6 +1,6 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.consumers.consumer.batch.MessageBatch; import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.HttpRequestHeaders; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultBatchHttpRequestFactory.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultBatchHttpRequestFactory.java index a2bd0ab2f8..5a76d1646d 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultBatchHttpRequestFactory.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultBatchHttpRequestFactory.java @@ -1,8 +1,8 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; +import org.eclipse.jetty.client.ByteBufferRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.ByteBufferContentProvider; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpMethod; import pl.allegro.tech.hermes.common.exception.InternalProcessingException; import pl.allegro.tech.hermes.consumers.consumer.batch.MessageBatch; @@ -19,16 +19,11 @@ public DefaultBatchHttpRequestFactory(HttpClient client) { } public Request buildRequest(MessageBatch message, URI uri, HttpRequestHeaders headers, int requestTimeout) { - Request request = client.newRequest(uri) + return client.newRequest(uri) .method(HttpMethod.POST) .timeout(requestTimeout, TimeUnit.MILLISECONDS) - .content(new ByteBufferContentProvider(message.getContent())); - - - headers.asMap() - .forEach(request::header); - - return request; + .body(new ByteBufferRequestContent(message.getContent())) + .headers(httpHeaders -> headers.asMap().forEach(httpHeaders::add)); } private static HttpClient started(HttpClient httpClient) { diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpMetadataAppender.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpMetadataAppender.java index a982c5c814..804eebe17c 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpMetadataAppender.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpMetadataAppender.java @@ -1,6 +1,6 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.consumers.consumer.Message; import pl.allegro.tech.hermes.consumers.consumer.trace.MetadataAppender; @@ -8,7 +8,7 @@ public class DefaultHttpMetadataAppender implements MetadataAppender { @Override public Request append(Request target, Message message) { - message.getExternalMetadata().forEach(target::header); + target.headers(httpFields -> message.getExternalMetadata().forEach(httpFields::add)); return target; } } diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactory.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactory.java index 65e3886f7b..db1a88d7c9 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactory.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactory.java @@ -1,8 +1,8 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; +import org.eclipse.jetty.client.BytesRequestContent; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.util.BytesContentProvider; +import org.eclipse.jetty.client.Request; import org.eclipse.jetty.http.HttpMethod; import pl.allegro.tech.hermes.consumers.consumer.Message; import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.HttpRequestHeaders; @@ -46,12 +46,8 @@ private class HttpRequestBuilder { } Request build() { - Request request = baseRequest(); - - headers.asMap() - .forEach(request::header); - - return request; + return baseRequest() + .headers(httpHeaders -> headers.asMap().forEach(httpHeaders::add)); } private Request baseRequest() { @@ -59,7 +55,7 @@ private Request baseRequest() { .method(HttpMethod.POST) .timeout(timeout, TimeUnit.MILLISECONDS) .idleTimeout(socketTimeout, TimeUnit.MILLISECONDS) - .content(new BytesContentProvider(message.getData())); + .body(new BytesRequestContent(message.getData())); metadataAppender.append(baseRequest, message); diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactoryProvider.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactoryProvider.java index 6b34c2a983..6cba998e03 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactoryProvider.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultHttpRequestFactoryProvider.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.api.Subscription; import pl.allegro.tech.hermes.consumers.consumer.trace.MetadataAppender; @@ -19,6 +19,4 @@ public HttpRequestFactory provideRequestFactory(Subscription subscription, metadataAppender ); } - - } diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultSendingResultHandlers.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultSendingResultHandlers.java index d7c25c94ed..1d435a62f2 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultSendingResultHandlers.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/DefaultSendingResultHandlers.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Response; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult; import pl.allegro.tech.hermes.consumers.consumer.sender.SingleMessageSendingResult; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsFactory.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsFactory.java index 8784afb9bc..b6b79becf1 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsFactory.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsFactory.java @@ -1,11 +1,11 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP; +import org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP; +import org.eclipse.jetty.http.HttpCookieStore; import org.eclipse.jetty.http2.client.HTTP2Client; -import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; +import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; import org.eclipse.jetty.io.ClientConnector; -import org.eclipse.jetty.util.HttpCookieStore; import pl.allegro.tech.hermes.common.metric.executor.InstrumentedExecutorServiceFactory; import java.util.concurrent.ExecutorService; @@ -36,7 +36,7 @@ public HttpClient createClientForHttp1(String name, Http1ClientParameters http1C client.setExecutor(executor); client.setMaxConnectionsPerDestination(http1ClientParameters.getMaxConnectionsPerDestination()); client.setMaxRequestsQueuedPerDestination(http1ClientParameters.getMaxRequestsQueuedPerDestination()); - client.setCookieStore(new HttpCookieStore.Empty()); + client.setHttpCookieStore(new HttpCookieStore.Empty()); client.setIdleTimeout(http1ClientParameters.getIdleTimeout().toMillis()); client.setFollowRedirects(http1ClientParameters.isFollowRedirectsEnabled()); client.setConnectTimeout(http1ClientParameters.getConnectionTimeout().toMillis()); @@ -62,7 +62,7 @@ public HttpClient createClientForHttp2(String name, Http2ClientParameters http2C HttpClient client = new HttpClient(transport); client.setMaxRequestsQueuedPerDestination(http2ClientParameters.getMaxRequestsQueuedPerDestination()); - client.setCookieStore(new HttpCookieStore.Empty()); + client.setHttpCookieStore(new HttpCookieStore.Empty()); client.setIdleTimeout(http2ClientParameters.getIdleTimeout().toMillis()); client.setFollowRedirects(http2ClientParameters.isFollowRedirectsEnabled()); client.setConnectTimeout(http2ClientParameters.getConnectionTimeout().toMillis()); diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporter.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporter.java index f6d36ba6ec..2692c3d7c5 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporter.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporter.java @@ -3,8 +3,8 @@ import org.eclipse.jetty.client.ConnectionPool; import org.eclipse.jetty.client.DuplexConnectionPool; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.MultiplexConnectionPool; +import org.eclipse.jetty.client.transport.HttpDestination; import pl.allegro.tech.hermes.common.metric.MetricsFacade; import java.util.Queue; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactory.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactory.java index dcd432d4c3..d31e7354a8 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactory.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactory.java @@ -1,6 +1,6 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.consumers.consumer.Message; import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.HttpRequestHeaders; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactoryProvider.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactoryProvider.java index 7e0ffe4408..7cb84395a9 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactoryProvider.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpRequestFactoryProvider.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.api.Subscription; import pl.allegro.tech.hermes.consumers.consumer.trace.MetadataAppender; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSender.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSender.java index 07ec0a5536..3b1607d3be 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSender.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSender.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; import com.google.common.collect.ImmutableList; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.consumers.consumer.Message; import pl.allegro.tech.hermes.consumers.consumer.ResilientMessageSender; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSender; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastResponseListener.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastResponseListener.java index 980ea7a3f8..a0be25467c 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastResponseListener.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastResponseListener.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Result; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult; import pl.allegro.tech.hermes.consumers.consumer.sender.SingleMessageSendingResult; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyHttpMessageSenderProvider.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyHttpMessageSenderProvider.java index ab0eaf966b..809e456c4a 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyHttpMessageSenderProvider.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyHttpMessageSenderProvider.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableSet; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pl.allegro.tech.hermes.api.EndpointAddress; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageBatchSender.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageBatchSender.java index 21ef73498b..386a449feb 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageBatchSender.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageBatchSender.java @@ -2,8 +2,8 @@ import org.apache.http.entity.ContentType; import org.apache.http.protocol.HTTP; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Request; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pl.allegro.tech.hermes.api.EndpointAddress; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageSender.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageSender.java index 03b7a36264..dc2690af06 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageSender.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyMessageSender.java @@ -1,6 +1,6 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.Request; import pl.allegro.tech.hermes.consumers.consumer.Message; import pl.allegro.tech.hermes.consumers.consumer.sender.CompletableFutureAwareMessageSender; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyResponseListener.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyResponseListener.java index e6c2bdfc40..fd6d7bb6d4 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyResponseListener.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyResponseListener.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.Result; -import org.eclipse.jetty.client.util.BufferingResponseListener; +import org.eclipse.jetty.client.BufferingResponseListener; +import org.eclipse.jetty.client.Result; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult; import java.util.concurrent.CompletableFuture; diff --git a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/SendingResultHandlers.java b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/SendingResultHandlers.java index d8b252f4bb..80fdc90f59 100644 --- a/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/SendingResultHandlers.java +++ b/hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/SendingResultHandlers.java @@ -1,7 +1,7 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http; -import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Response.CompleteListener; +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.Response.CompleteListener; import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult; import pl.allegro.tech.hermes.consumers.consumer.sender.SingleMessageSendingResult; diff --git a/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporterTest.groovy b/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporterTest.groovy index e573c84281..8f653948f8 100644 --- a/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporterTest.groovy +++ b/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/HttpClientsWorkloadReporterTest.groovy @@ -1,8 +1,8 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http import org.eclipse.jetty.client.HttpClient -import org.eclipse.jetty.client.HttpDestination -import org.eclipse.jetty.client.HttpExchange +import org.eclipse.jetty.client.transport.HttpDestination +import org.eclipse.jetty.client.transport.HttpExchange import pl.allegro.tech.hermes.common.metric.MetricsFacade import spock.lang.Specification diff --git a/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSenderTest.groovy b/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSenderTest.groovy index b565f11801..7445574d47 100644 --- a/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSenderTest.groovy +++ b/hermes-consumers/src/test/groovy/pl/allegro/tech/hermes/consumers/consumer/sender/http/JettyBroadCastMessageSenderTest.groovy @@ -2,17 +2,17 @@ package pl.allegro.tech.hermes.consumers.consumer.sender.http import com.github.tomakehurst.wiremock.WireMockServer import org.eclipse.jetty.client.HttpClient -import org.eclipse.jetty.util.HttpCookieStore +import org.eclipse.jetty.http.HttpCookieStore import pl.allegro.tech.hermes.api.EndpointAddress import pl.allegro.tech.hermes.api.EndpointAddressResolverMetadata import pl.allegro.tech.hermes.api.Subscription import pl.allegro.tech.hermes.api.SubscriptionName import pl.allegro.tech.hermes.consumers.consumer.Message +import pl.allegro.tech.hermes.consumers.consumer.ResilientMessageSender import pl.allegro.tech.hermes.consumers.consumer.rate.ConsumerRateLimiter import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSender import pl.allegro.tech.hermes.consumers.consumer.sender.MessageSendingResult import pl.allegro.tech.hermes.consumers.consumer.sender.MultiMessageSendingResult -import pl.allegro.tech.hermes.consumers.consumer.ResilientMessageSender import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.AuthHeadersProvider import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.HermesHeadersProvider import pl.allegro.tech.hermes.consumers.consumer.sender.http.headers.Http1HeadersProvider @@ -61,7 +61,7 @@ class JettyBroadCastMessageSenderTest extends Specification { wireMockServers.forEach { it.start() } client = new HttpClient() - client.setCookieStore(new HttpCookieStore.Empty()) + client.setHttpCookieStore(new HttpCookieStore.Empty()) client.setConnectTimeout(1000) client.setIdleTimeout(1000) client.start() diff --git a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/console/ConsoleConfiguration.java b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/console/ConsoleConfiguration.java index 9faa8cabc8..e9f589414e 100644 --- a/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/console/ConsoleConfiguration.java +++ b/hermes-management/src/main/java/pl/allegro/tech/hermes/management/config/console/ConsoleConfiguration.java @@ -1,6 +1,9 @@ package pl.allegro.tech.hermes.management.config.console; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.core5.http.io.SocketConfig; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; @@ -13,6 +16,8 @@ import pl.allegro.tech.hermes.management.infrastructure.console.HttpConsoleConfigurationRepository; import pl.allegro.tech.hermes.management.infrastructure.console.SpringConfigConsoleConfigurationRepository; +import java.util.concurrent.TimeUnit; + @Configuration @EnableConfigurationProperties({ConsoleConfigProperties.class, ConsoleProperties.class}) public class ConsoleConfiguration { @@ -40,9 +45,18 @@ ConsoleConfigurationRepository consoleConfigurationRepository( } private ConsoleConfigurationRepository httpConsoleConfigurationRepository(ConsoleConfigProperties properties) { - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - requestFactory.setConnectTimeout((int) properties.getHttpClient().getConnectTimeout().toMillis()); - requestFactory.setReadTimeout((int) properties.getHttpClient().getReadTimeout().toMillis()); + var httpClientProperties = properties.getHttpClient(); + var socketConfig = SocketConfig.custom() + .setSoTimeout((int) httpClientProperties.getReadTimeout().toMillis(), TimeUnit.MILLISECONDS) + .build(); + var connectionManager = PoolingHttpClientConnectionManagerBuilder.create() + .setDefaultSocketConfig(socketConfig) + .build(); + var client = HttpClientBuilder.create() + .setConnectionManager(connectionManager) + .build(); + HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(client); + requestFactory.setConnectTimeout(properties.getHttpClient().getConnectTimeout()); RestTemplate restTemplate = new RestTemplate(requestFactory); return new HttpConsoleConfigurationRepository(properties, restTemplate); } diff --git a/hermes-mock/build.gradle b/hermes-mock/build.gradle index 1bb8e4c147..f88ff3671b 100644 --- a/hermes-mock/build.gradle +++ b/hermes-mock/build.gradle @@ -6,7 +6,7 @@ plugins { dependencies { implementation group: 'junit', name: 'junit', version: '4.11' - api group: 'org.wiremock', name: 'wiremock', version: versions.wiremock + api group: 'org.wiremock', name: 'wiremock-standalone', version: versions.wiremock implementation group: 'com.jayway.awaitility', name: 'awaitility', version: '1.6.1' api group: 'org.apache.avro', name: 'avro', version: versions.avro implementation group: 'tech.allegro.schema.json2avro', name: 'converter', version: versions.json2avro diff --git a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockDefine.java b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockDefine.java index 6d522b1f79..8fadfc3378 100644 --- a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockDefine.java +++ b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockDefine.java @@ -4,9 +4,9 @@ import com.github.tomakehurst.wiremock.matching.ValueMatcher; import com.github.tomakehurst.wiremock.stubbing.StubMapping; import org.apache.avro.Schema; -import org.apache.hc.core5.http.HttpStatus; import pl.allegro.tech.hermes.mock.exchange.Response; import pl.allegro.tech.hermes.mock.matching.ContentMatchers; +import wiremock.org.apache.hc.core5.http.HttpStatus; import java.util.function.Predicate; diff --git a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockQuery.java b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockQuery.java index f8afb82789..9b7af13069 100644 --- a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockQuery.java +++ b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/HermesMockQuery.java @@ -1,9 +1,9 @@ package pl.allegro.tech.hermes.mock; import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder; -import com.google.common.collect.Lists; import org.apache.avro.Schema; import pl.allegro.tech.hermes.mock.exchange.Request; +import wiremock.com.google.common.collect.Lists; import java.util.List; import java.util.Optional; diff --git a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/exchange/Response.java b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/exchange/Response.java index 9703618549..725006af6e 100644 --- a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/exchange/Response.java +++ b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/exchange/Response.java @@ -1,8 +1,6 @@ package pl.allegro.tech.hermes.mock.exchange; - - -import org.apache.hc.core5.http.HttpStatus; +import wiremock.org.apache.hc.core5.http.HttpStatus; import java.time.Duration; diff --git a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/matching/StartsWithPattern.java b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/matching/StartsWithPattern.java index 64f31af075..2783d91c69 100644 --- a/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/matching/StartsWithPattern.java +++ b/hermes-mock/src/main/java/pl/allegro/tech/hermes/mock/matching/StartsWithPattern.java @@ -1,8 +1,8 @@ package pl.allegro.tech.hermes.mock.matching; -import com.fasterxml.jackson.annotation.JsonProperty; import com.github.tomakehurst.wiremock.matching.MatchResult; import com.github.tomakehurst.wiremock.matching.StringValuePattern; +import wiremock.com.fasterxml.jackson.annotation.JsonProperty; public class StartsWithPattern extends StringValuePattern {