This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/log-http-error-body in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit faba5ac9e070a6e79d6be66e34e8a5114421c309 Author: Konrad Windszus <[email protected]> AuthorDate: Sat Jul 11 10:17:06 2026 +0200 Expose body for non RFC 9457 error responses Log only on DEBUG level This closes #1844 --- maven-resolver-spi/pom.xml | 9 +++++++++ .../connector/transport/http/RFC9457/RFC9457Reporter.java | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/maven-resolver-spi/pom.xml b/maven-resolver-spi/pom.xml index f987a74f3..487bca3a8 100644 --- a/maven-resolver-spi/pom.xml +++ b/maven-resolver-spi/pom.xml @@ -39,6 +39,10 @@ </properties> <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> <dependency> <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-api</artifactId> @@ -52,6 +56,11 @@ <artifactId>junit-jupiter-api</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/http/RFC9457/RFC9457Reporter.java b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/http/RFC9457/RFC9457Reporter.java index 7fb51a945..82bbc2c4a 100644 --- a/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/http/RFC9457/RFC9457Reporter.java +++ b/maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/http/RFC9457/RFC9457Reporter.java @@ -19,6 +19,10 @@ package org.eclipse.aether.spi.connector.transport.http.RFC9457; import java.io.IOException; +import java.io.UncheckedIOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A reporter for RFC 9457 messages. @@ -35,6 +39,7 @@ import java.io.IOException; * @see <a href=https://www.rfc-editor.org/rfc/rfc9457#section-3-7>RFC 9457</a> */ public abstract class RFC9457Reporter<T, E extends Exception, R> { + private static final Logger LOGGER = LoggerFactory.getLogger(RFC9457Reporter.class); public static final String CONTENT_TYPE_PROBLEM_DETAILS_JSON = "application/problem+json"; public static final String CONTENT_TYPE_PROBLEM_DETAILS_JSON_AND_ANY = "application/problem+json,*/*"; @@ -92,6 +97,15 @@ public abstract class RFC9457Reporter<T, E extends Exception, R> { throw new HttpRFC9457Exception(statusCode, reasonPhrase, rfc9457Payload); } throw new HttpRFC9457Exception(statusCode, reasonPhrase, RFC9457Payload.INSTANCE); + } else { + try { + LOGGER.debug( + "Received a response (not RFC 9457 compliant) with status code {}: {}", + statusCode, + getBody(response)); + } catch (IOException e) { + throw new UncheckedIOException("Failed to read response body", e); + } } baseException.accept(statusCode, reasonPhrase); }
