Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions maven-resolver-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -35,6 +39,7 @@
* @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,*/*";

Expand Down Expand Up @@ -92,6 +97,15 @@ public void generateException(T response, BiConsumerChecked<Integer, String, E>
throw new HttpRFC9457Exception(statusCode, reasonPhrase, rfc9457Payload);
}
throw new HttpRFC9457Exception(statusCode, reasonPhrase, RFC9457Payload.INSTANCE);
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the Javadoc comment above this is incorrect. baseException should be thrown. I'm not sure if this should be fixed or if the doc needs to be changed, but they should be consistent

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);

@elharo elharo Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not worth throwing this at all if it just means we couldn't log a debug message

}
}
baseException.accept(statusCode, reasonPhrase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ protected String getReasonPhrase(final CloseableHttpResponse response) {

@Override
protected String getBody(final CloseableHttpResponse response) throws IOException {
if (response.getEntity() == null) {
return "";
}
return EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
}
}
Loading