From f0f29c89f0fc03d5cea9c58e0c739ab29e019af8 Mon Sep 17 00:00:00 2001 From: Jonas Olsson Date: Mon, 27 May 2024 09:12:28 +0200 Subject: [PATCH 01/10] Improved HttpClientConfig - timeoutMs - followRedirect - path of URL used as API root --- .../reactivewizard/client/HttpClient.java | 23 ++++++++++++-- .../client/HttpClientConfig.java | 30 +++++++++++++++++++ .../client/ReactorRxClientProvider.java | 2 +- .../client/HttpClientConfigTest.java | 23 ++++++++++++++ .../reactivewizard/client/HttpClientTest.java | 17 +++++++++++ client/src/test/resources/httpconfig.yml | 2 ++ 6 files changed, 93 insertions(+), 4 deletions(-) diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java index 1b8414d3..acb51a03 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java @@ -79,6 +79,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static reactor.core.Exceptions.isRetryExhausted; import static reactor.core.publisher.Mono.just; +import static se.fortnox.reactivewizard.client.HttpClientConfig.DEFAULT_TIMEOUT_MS; public class HttpClient implements InvocationHandler { private static final Logger LOG = LoggerFactory.getLogger(HttpClient.class); @@ -103,8 +104,8 @@ public class HttpClient implements InvocationHandler { private final RequestLogger requestLogger; private final Map, List> beanParamCache = new ConcurrentHashMap<>(); private final Map jaxRsMetaMap = new ConcurrentHashMap<>(); - private int timeout = 10; - private TemporalUnit timeoutUnit = ChronoUnit.SECONDS; + private int timeout = DEFAULT_TIMEOUT_MS; + private TemporalUnit timeoutUnit = ChronoUnit.MILLIS; private final Duration retryDuration; @Inject @@ -131,6 +132,7 @@ public HttpClient(HttpClientConfig config, collector = new ByteBufCollector(config.getMaxResponseSize()); this.preRequestHooks = preRequestHooks; this.retryDuration = Duration.ofMillis(config.getRetryDelayMs()); + setTimeout(config.getTimeoutMs(), ChronoUnit.MILLIS); } public HttpClient(HttpClientConfig config) { @@ -534,7 +536,22 @@ protected RequestBuilder createRequest(Method method, Object[] arguments) { JaxRsMeta meta = getJaxRsMeta(method); RequestBuilder request = new RequestBuilder(serverInfo, meta.getHttpMethod(), meta.getFullPath()); - request.setUri(getPath(method, arguments, meta)); + + String root = config.getRoot(); + String path = getPath(method, arguments, meta); + if (root == null || root.isEmpty()) { + request.setUri(path); + } else { + if (root.endsWith("/")) { + root = root.substring(0, root.length() - 1); + } + if (path.startsWith("/")) { + request.setUri(root + path); + } else { + request.setUri(root + "/" + path); + } + } + setHeaderParams(request, method, arguments); addCustomParams(request, method, arguments); diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClientConfig.java b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClientConfig.java index f31355b9..034831fe 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClientConfig.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClientConfig.java @@ -19,6 +19,8 @@ @Config("httpClient") public class HttpClientConfig { + public static final int DEFAULT_TIMEOUT_MS = 10_000; + @Valid @JsonProperty("port") private int port = 80; @@ -33,6 +35,7 @@ public class HttpClientConfig { private int maxConnections = 1000; private String url; + private String root; private InetSocketAddress devServerInfo; @Size(min = 1) private String devCookie; @@ -44,10 +47,12 @@ public class HttpClientConfig { private boolean isHttps; private int retryCount = 3; private int retryDelayMs = 1000; + private int timeoutMs = DEFAULT_TIMEOUT_MS; private int readTimeoutMs = 10000; private int poolAcquireTimeoutMs = 10000; @JsonProperty("validateCertificates") private boolean isValidateCertificates = true; + private boolean followRedirect = false; private long connectionMaxIdleTimeInMs = TimeUnit.MILLISECONDS.convert(10, MINUTES); private int numberOfConnectionFailuresAllowed = 10; @@ -88,6 +93,7 @@ public void setUrl(String url) throws URISyntaxException { } URI uri = new URI(this.url); setHost(uri.getHost()); + setRoot(uri.getPath()); isHttps = "https".equals(uri.getScheme()); port = uri.getPort(); @@ -100,6 +106,14 @@ public void setUrl(String url) throws URISyntaxException { } } + public void setRoot(String root) { + this.root = root; + } + + public String getRoot() { + return root; + } + public InetSocketAddress getDevServerInfo() { return devServerInfo; } @@ -161,6 +175,14 @@ public void setHost(String host) { } } + public int getTimeoutMs() { + return timeoutMs; + } + + public void setTimeoutMs(int timeoutMs) { + this.timeoutMs = timeoutMs; + } + public int getReadTimeoutMs() { return readTimeoutMs; } @@ -177,6 +199,14 @@ public void setValidateCertificates(boolean value) { isValidateCertificates = value; } + public boolean isFollowRedirect() { + return followRedirect; + } + + public void setFollowRedirect(boolean value) { + followRedirect = value; + } + public BasicAuthConfig getBasicAuth() { return basicAuth; } diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/ReactorRxClientProvider.java b/client/src/main/java/se/fortnox/reactivewizard/client/ReactorRxClientProvider.java index ca5b5ea6..2755f1b3 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/ReactorRxClientProvider.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/ReactorRxClientProvider.java @@ -75,7 +75,7 @@ private HttpClient buildClient(InetSocketAddress socketAddress) { .doOnError((httpClientRequest, throwable) -> { healthRecorder.logStatus(connectionProvider, errorCount.incrementAndGet() <= config.getNumberOfConnectionFailuresAllowed()); }, (httpClientResponse, throwable) -> { }) - .followRedirect(false); + .followRedirect(config.isFollowRedirect()); if (config.isHttps()) { return setupSsl(client, config.isValidateCertificates()); diff --git a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientConfigTest.java b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientConfigTest.java index 25fae64b..db14640b 100644 --- a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientConfigTest.java +++ b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientConfigTest.java @@ -32,11 +32,14 @@ void shouldInitializeFromConfig() { assertThat(config.getRetryCount()).isEqualTo(15); assertThat(config.getRetryDelayMs()).isEqualTo(200); assertThat(config.getMaxResponseSize()).isEqualTo(512); + assertThat(config.getTimeoutMs()).isEqualTo(60 * 1000); + assertThat(config.isFollowRedirect()).isTrue(); assertThat(config.getDevCookie()).isEqualTo("TEST=123"); assertThat(config.getDevServerInfo().getHostString()).isEqualTo("mymachine"); assertThat(config.getDevServerInfo().getPort()).isEqualTo(9090); assertThat(config.getDevHeaders()).contains(entry("Host", "localhost")); + } @Test @@ -83,6 +86,14 @@ void shouldSetPort() throws URISyntaxException { assertThat(config.getHost()).isEqualTo("localhost"); } + @Test + void shouldSetRoot() throws URISyntaxException { + assertThat(new HttpClientConfig("http://localhost:8080").getRoot()).isEqualTo(""); + assertThat(new HttpClientConfig("http://localhost:8080/").getRoot()).isEqualTo("/"); + assertThat(new HttpClientConfig("http://localhost:8080/root/path").getRoot()).isEqualTo("/root/path"); + assertThat(new HttpClientConfig("http://localhost:8080/root/path/").getRoot()).isEqualTo("/root/path/"); + } + @Test void shouldSetHttpsFromProtocolEvenIfPortIsSupplied() throws URISyntaxException { HttpClientConfig config = new HttpClientConfig("https://localhost:8080"); @@ -121,4 +132,16 @@ void shouldNotBeInsecureByDefault() throws URISyntaxException { assertThat(httpClientConfig.isHttps()).isTrue(); assertThat(httpClientConfig.isValidateCertificates()).isTrue(); } + + @Test + void shouldNotFollowRedirectByDefault() throws URISyntaxException { + HttpClientConfig httpClientConfig = new HttpClientConfig("http://example.com"); + assertThat(httpClientConfig.isFollowRedirect()).isFalse(); + } + + @Test + void shouldDefaultToTenSecondTimeout() throws URISyntaxException { + HttpClientConfig httpClientConfig = new HttpClientConfig("http://example.com"); + assertThat(httpClientConfig.getTimeoutMs()).isEqualTo(10 * 1000); + } } diff --git a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java index 6735ca50..8edf97cd 100644 --- a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java +++ b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java @@ -308,6 +308,23 @@ protected JaxRsMeta getJaxRsMeta(Method method) { assertThat(jaxRsMetas.get(2)).isSameAs(jaxRsMetas.get(3)); } + @Test + void shouldAddRootToRequestUri() throws URISyntaxException, NoSuchMethodException { + + assertAddedRoot("localhost", "/hello"); + assertAddedRoot("localhost/", "/hello"); + assertAddedRoot("localhost/root", "/root/hello"); + assertAddedRoot("localhost/root/", "/root/hello"); + } + + private void assertAddedRoot(String url, String expected) throws URISyntaxException, NoSuchMethodException { + HttpClient httpClient = new HttpClient(new HttpClientConfig(url)); + + Method getHello = TestResource.class.getMethod("getHello"); + + assertThat(httpClient.createRequest(getHello, new Object[0]).getUri()).isEqualTo(expected); + } + @Test void shouldRetryIfEmptyReturnedOnGet() { diff --git a/client/src/test/resources/httpconfig.yml b/client/src/test/resources/httpconfig.yml index 817897a1..1cd1438d 100644 --- a/client/src/test/resources/httpconfig.yml +++ b/client/src/test/resources/httpconfig.yml @@ -9,3 +9,5 @@ httpClient: retryCount: 15 retryDelayMs: 200 maxResponseSize: 512 + timeoutMs: 60000 + followRedirect: true From 1e01c30cd532afaa8c314583113f6665d12eb71d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:42:06 +0000 Subject: [PATCH 02/10] Bump com.h2database:h2 from 2.2.224 to 2.3.232 Bumps [com.h2database:h2](https://github.com/h2database/h2database) from 2.2.224 to 2.3.232. - [Release notes](https://github.com/h2database/h2database/releases) - [Commits](https://github.com/h2database/h2database/compare/version-2.2.224...version-2.3.232) --- updated-dependencies: - dependency-name: com.h2database:h2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6e893904..29916826 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ 2.0.13 4.13.2 5.10.3 - 2.2.224 + 2.3.232 2.2 8.0.1.Final 3.1.0 From 083dbb0a8ace525700328ab9a47c8873dba63f91 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:16:33 +0000 Subject: [PATCH 03/10] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.5.0 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.0...surefire-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6e893904..4442507b 100644 --- a/pom.xml +++ b/pom.xml @@ -102,7 +102,7 @@ 1.0.9.RELEASE 3.2.4 - 3.3.0 + 3.5.0 1.7.0 3.13.0 3.5.0 From 411754b2273b38b92b6626689d919ea7d207ad96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:26:35 +0000 Subject: [PATCH 04/10] Bump io.swagger.core.v3:swagger-annotations from 2.2.22 to 2.2.23 Bumps io.swagger.core.v3:swagger-annotations from 2.2.22 to 2.2.23. --- updated-dependencies: - dependency-name: io.swagger.core.v3:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4d81d1b7..731c03f1 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,7 @@ 1.14.18 2.0.1 1.78.1 - 2.2.22 + 2.2.23 https://sonarcloud.io fortnoxab From 75a09a67775554d7e35492c8d9377c13df8d9a2e Mon Sep 17 00:00:00 2001 From: Henrik Cooke Date: Mon, 9 Sep 2024 16:17:09 +0200 Subject: [PATCH 05/10] Change client request failed logging to info for 404 responses --- .../reactivewizard/client/HttpClient.java | 15 ++++++- .../reactivewizard/client/HttpClientTest.java | 43 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java index acb51a03..8f74a314 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java @@ -261,7 +261,7 @@ public static Mono> getFullResponse(Mono source) { private Mono convertError(RequestBuilder fullReq, Throwable throwable) { String request = format("%s, headers: %s", fullReq.getFullUrl(), requestLogger.getHeaderValuesOrRedactClient(fullReq.getHeaders())); - LOG.warn("Failed request. Url: {}", request, throwable); + logFailedRequest(throwable, request); if (isRetryExhausted(throwable)) { throwable = throwable.getCause(); @@ -277,6 +277,19 @@ private Mono convertError(RequestBuilder fullReq, Throwable throwable) { return Mono.error(throwable); } + private static void logFailedRequest(Throwable throwable, String request) { + var logAsInfo = throwable instanceof WebException webException && + webException.getStatus().code() == HttpResponseStatus.NOT_FOUND.code() && + !"resource.not.found".equals(webException.getError()); + + String message = "Failed request. Url: {}"; + if (logAsInfo) { + LOG.info(message, request, throwable); + } else { + LOG.warn(message, request, throwable); + } + } + protected Flux parseResponseSingle(Method method, RwHttpClientResponse response) { if (expectsByteArrayResponse(method)) { return Flux.from(collector.collectBytes(response.getContent())); diff --git a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java index 8edf97cd..f713b925 100644 --- a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java +++ b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java @@ -702,6 +702,49 @@ void shouldApplyHeaderTransformerInLogsAndExceptionMessage() throws Exception { loggingVerifier.verify(WARN, "Failed request. Url: localhost:" + server.port() + "/hello, headers: [Host=localhost, someHeader=ABCD]"); } + @Test + void shouldLogWarnOnErrorResponse() throws Exception { + server = startServer(BAD_REQUEST, ""); + HttpClientConfig config = new HttpClientConfig("localhost:" + server.port()); + TestResource resource = getHttpProxy(config); + + assertThatExceptionOfType(WebException.class) + .isThrownBy(() -> resource.getHello() + .toBlocking() + .single()); + + loggingVerifier.verify(WARN, "Failed request. Url: localhost:" + server.port() + "/hello, headers: [Host=localhost]"); + } + + @Test + void shouldLogInfoOnNotFoundResponse() throws Exception { + server = startServer(NOT_FOUND, ""); + HttpClientConfig config = new HttpClientConfig("localhost:" + server.port()); + TestResource resource = getHttpProxy(config); + + assertThatExceptionOfType(WebException.class) + .isThrownBy(() -> resource.getHello() + .toBlocking() + .single()); + + loggingVerifier.verify(INFO, "Failed request. Url: localhost:" + server.port() + "/hello, headers: [Host=localhost]"); + } + + @Test + void shouldLogWarnOnNotFoundResource() throws Exception { + server = startServer(NOT_FOUND, "{\"error\":\"resource.not.found\"}"); + HttpClientConfig config = new HttpClientConfig("localhost:" + server.port()); + TestResource resource = getHttpProxy(config); + + assertThatExceptionOfType(WebException.class) + .isThrownBy(() -> resource.getHello() + .toBlocking() + .single()); + + loggingVerifier.verify(WARN, "Failed request. Url: localhost:" + server.port() + "/hello, headers: [Host=localhost]"); + } + + @Test void shouldRedactSensitiveHeaderInLogsAndExceptionMessage() throws Exception { server = startServer(BAD_REQUEST, "someError"); From ddf075174e102f94f64f1073f5db20bceabc7cd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:09:22 +0000 Subject: [PATCH 06/10] Bump org.apache.maven.plugins:maven-jxr-plugin from 3.4.0 to 3.5.0 Bumps [org.apache.maven.plugins:maven-jxr-plugin](https://github.com/apache/maven-jxr) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/apache/maven-jxr/releases) - [Commits](https://github.com/apache/maven-jxr/compare/jxr-3.4.0...jxr-3.5.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jxr-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4d81d1b7..0689053f 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ 3.13.0 3.5.0 3.3.1 - 3.4.0 + 3.5.0 3.7.0 3.4.0 3.4.2 From d4cf94fac52edcb1b1d90cda8667d1aa759bfc29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:36:10 +0000 Subject: [PATCH 07/10] Bump org.assertj:assertj-core from 3.26.0 to 3.26.3 Bumps [org.assertj:assertj-core](https://github.com/assertj/assertj) from 3.26.0 to 3.26.3. - [Release notes](https://github.com/assertj/assertj/releases) - [Commits](https://github.com/assertj/assertj/compare/assertj-build-3.26.0...assertj-build-3.26.3) --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4d81d1b7..537cb378 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ 7.0.0 1.1.1 - 3.26.0 + 3.26.3 5.12.0 0.8.12 1.0.1 From 688055f322fe8661a1f7686c82942b2e85ededee Mon Sep 17 00:00:00 2001 From: Hamza Hajderovic Date: Thu, 12 Sep 2024 11:56:39 +0200 Subject: [PATCH 08/10] Upgrading some dependencies --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4d81d1b7..920d409a 100644 --- a/pom.xml +++ b/pom.xml @@ -80,12 +80,12 @@ 2023.0.8 4.1.111.Final 2.17.2 - 33.2.1-jre + 33.3.0-jre 1.3.8 5.1.0 - 2.0.13 + 2.0.16 4.13.2 - 5.10.3 + 5.11.0 2.3.232 2.2 8.0.1.Final @@ -120,7 +120,7 @@ 4.0.2 2.1.1 3.1.2 - 1.14.18 + 1.15.0 2.0.1 1.78.1 2.2.22 From fc80dd02f9e6288e8e0a02ca353e0112c840f30e Mon Sep 17 00:00:00 2001 From: Henrik Cooke Date: Thu, 12 Sep 2024 13:52:31 +0200 Subject: [PATCH 09/10] Clarify implementation and fix failing test --- .../se/fortnox/reactivewizard/client/HttpClient.java | 11 ++++------- .../fortnox/reactivewizard/client/HttpClientTest.java | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java index 8f74a314..e0e1157a 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java @@ -16,6 +16,7 @@ import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.event.Level; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -278,16 +279,12 @@ private Mono convertError(RequestBuilder fullReq, Throwable throwable) { } private static void logFailedRequest(Throwable throwable, String request) { - var logAsInfo = throwable instanceof WebException webException && + var isExpectedError = throwable instanceof WebException webException && webException.getStatus().code() == HttpResponseStatus.NOT_FOUND.code() && !"resource.not.found".equals(webException.getError()); - String message = "Failed request. Url: {}"; - if (logAsInfo) { - LOG.info(message, request, throwable); - } else { - LOG.warn(message, request, throwable); - } + var level = isExpectedError ? Level.INFO : Level.WARN; + LOG.atLevel(level).log("Failed request. Url: {}", request, throwable); } protected Flux parseResponseSingle(Method method, RwHttpClientResponse response) { diff --git a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java index f713b925..b2bc78f4 100644 --- a/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java +++ b/client/src/test/java/se/fortnox/reactivewizard/client/HttpClientTest.java @@ -1671,7 +1671,7 @@ void shouldLogConfiguredIpAddressOnFailedRequest() throws URISyntaxException { .cause().cause() .satisfies(exception -> assertThat(exception) .hasMessageContaining("URL: %s:%s/hello", host, server.port()))); - loggingVerifier.verify(WARN, "Failed request. Url: %1$s:%2$s/hello, headers: [Host=%1$s]".formatted(host, server.port())); + loggingVerifier.verify(INFO, "Failed request. Url: %1$s:%2$s/hello, headers: [Host=%1$s]".formatted(host, server.port())); } @Test From 565e3bd2ad430d5f8863b461059e0254d0ba9cab Mon Sep 17 00:00:00 2001 From: Henrik Cooke Date: Thu, 12 Sep 2024 17:09:17 +0200 Subject: [PATCH 10/10] Fix incorrect logging of cause --- .../main/java/se/fortnox/reactivewizard/client/HttpClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java index e0e1157a..66a8ad82 100644 --- a/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java +++ b/client/src/main/java/se/fortnox/reactivewizard/client/HttpClient.java @@ -284,7 +284,7 @@ private static void logFailedRequest(Throwable throwable, String request) { !"resource.not.found".equals(webException.getError()); var level = isExpectedError ? Level.INFO : Level.WARN; - LOG.atLevel(level).log("Failed request. Url: {}", request, throwable); + LOG.atLevel(level).setCause(throwable).log("Failed request. Url: {}", request); } protected Flux parseResponseSingle(Method method, RwHttpClientResponse response) {