Skip to content
Merged
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
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
## Release Notes

`1.3.0`

- Added Jackson 3 support to `SpringJson` via `Jackson3SpringJson` for `JacksonJsonHttpMessageConverter`.
- Upgraded `httpclient5` to `5.6.5`.
- Upgraded OkHttp to `4.12.1`.
- Upgraded Jackson 2 to `2.21.7`.
- Upgraded Jackson 3 to `3.1.7`.
- Upgraded Spring Boot to `4.1.2` for `apiphany-spring`.
- Upgraded Spring to `7.0.10` for `apiphany-spring`.
- Upgraded Micrometer to `1.17.2`.
- Upgraded SLF4J to `2.0.20`.
- Upgraded `spring-security-oauth2-client` to `7.1.2`.
- Upgraded `nimbus-jose-jwt` to `10.10`.
- Upgraded `mockito-core` to `5.24.0`.
- Upgraded `logback-core` to `1.5.38`.
- Upgraded `testcontainers-keycloak` to `4.4.0`.
- Upgraded `pitest-maven` to `1.30.1`.
- Upgraded `maven-compiler-plugin` to `3.16.0`.
- Upgraded `maven-surefire-plugin` to `3.6.1`.
- Upgraded `maven-failsafe-plugin` to `3.6.1`.
- Upgraded `jacoco-maven-plugin` to `0.8.16`.
- Upgraded `spotless-maven-plugin` to `3.10.4`.
- Upgraded `maven-deploy-plugin` to `3.2.0`.
- Upgraded `exec-maven-plugin ` to `3.6.4`.

---

`1.2.23`

- Added `ApiResponse.isFailed()` to report whether the response status is an error, mirroring `isSuccessful()`.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Support is being developed for other HTTP clients like Netty, Jersey, etc. If yo

### Releases

Current release `1.2.23`
Current release `1.3.0`

### Getting Started

Expand All @@ -62,7 +62,7 @@ Maven: add this dependency to your `pom.xml`
<dependency>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion apiphany-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany-parent</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</parent>

<artifactId>apiphany</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion apiphany-httpclient5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany-parent</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</parent>

<artifactId>apiphany-httpclient5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ApacheHC5Library {
* <p>
* A newer runtime version is outside the tested range and is rejected by {@link #verifyVersion()}.
*/
private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 5, 6, 4);
private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 5, 6, 5);

/**
* The Apache HttpClient 5 CloseableHttpClient class name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
class ApacheHC5LibraryTest {

public static final String MIN_SUPPORTED_VERSION = "5.5.0";
public static final String MAX_SUPPORTED_VERSION = "5.6.5";

@Nested
class IsPresentTests {

Expand Down Expand Up @@ -84,7 +87,7 @@ class MinimumVersionTests {

@Test
void shouldReturnMinimumRequiredVersion() {
assertThat(ApacheHC5Library.minimumVersion().value(), equalTo("5.5.0"));
assertThat(ApacheHC5Library.minimumVersion().value(), equalTo(MIN_SUPPORTED_VERSION));
}

@Test
Expand All @@ -98,7 +101,7 @@ class MaximumVersionTests {

@Test
void shouldReturnMaximumSupportedVersion() {
assertThat(ApacheHC5Library.maximumVersion().value(), equalTo("5.6.4"));
assertThat(ApacheHC5Library.maximumVersion().value(), equalTo(MAX_SUPPORTED_VERSION));
}
}

Expand Down
2 changes: 1 addition & 1 deletion apiphany-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany-parent</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</parent>

<artifactId>apiphany-integration-tests</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ void shouldNotGetNameIfSSLIsNotInitialized() throws Exception {

assertNotNull(exception);
assertThat(exception.getClass(), equalTo(HttpException.class));
assertThat(exception.getMessage(), equalTo(HttpException.message(null, "Remote host terminated the handshake")));

Throwable cause = exception.getCause();
assertThat(cause.getClass(), equalTo(SSLHandshakeException.class));
assertThat(exception.getMessage(), equalTo(HttpException.message(null, cause.getMessage())));
}

static class SimpleApiClient extends ApiClient {
Expand Down
2 changes: 1 addition & 1 deletion apiphany-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany-parent</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</parent>

<artifactId>apiphany-okhttp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public class OkHttpLibrary {
private static final LibraryVersion MINIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 9, 0);

/**
* The maximum OkHttp version this module supports, i.e. the highest version it was tested against: <code>4.12.0</code>.
* The maximum OkHttp version this module supports, i.e. the highest version it was tested against: <code>4.12.1</code>.
* <p>
* A newer runtime version is outside the tested range and is rejected by {@link #verifyVersion()}.
*/
private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 12, 0);
private static final LibraryVersion MAXIMUM_VERSION = LibraryVersion.of(CLIENT_NAME, 4, 12, 1);

/**
* The OkHttp OkHttpClient class name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
class OkHttpLibraryTest {

private static final String MIN_SUPPORTED_VERSION = "4.9.0";
private static final String MAX_SUPPORTED_VERSION = "4.12.1";

@Nested
class IsPresentTests {

Expand Down Expand Up @@ -83,7 +86,7 @@ class MinimumVersionTests {

@Test
void shouldReturnMinimumRequiredVersion() {
assertThat(OkHttpLibrary.minimumVersion().value(), equalTo("4.9.0"));
assertThat(OkHttpLibrary.minimumVersion().value(), equalTo(MIN_SUPPORTED_VERSION));
}

@Test
Expand All @@ -97,7 +100,7 @@ class MaximumVersionTests {

@Test
void shouldReturnMaximumSupportedVersion() {
assertThat(OkHttpLibrary.maximumVersion().value(), equalTo("4.12.0"));
assertThat(OkHttpLibrary.maximumVersion().value(), equalTo(MAX_SUPPORTED_VERSION));
}
}

Expand Down
8 changes: 2 additions & 6 deletions apiphany-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.github.raduking</groupId>
<artifactId>apiphany-parent</artifactId>
<version>1.2.23</version>
<version>1.3.0</version>
</parent>

<artifactId>apiphany-spring</artifactId>
Expand Down Expand Up @@ -40,7 +40,6 @@

<properties>
<!-- Module specific versions -->
<spring.boot.version>3.5.16</spring.boot.version>
<dependency.check.maven.version>13.0.0</dependency.check.maven.version>

<!--
Expand Down Expand Up @@ -89,9 +88,8 @@
</dependency>

<dependency>
<!-- needed for RestTemplateBuilder -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<artifactId>spring-boot-restclient</artifactId>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -149,15 +147,13 @@
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson3.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>tools.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson3.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ protected <T> HttpEntity<T> createHttpEntity(final ApiRequest<T> apiRequest, fin
* @return the API response object
*/
protected <T, U> ApiResponse<U> buildResponse(final ApiRequest<T> apiRequest, final ResponseEntity<U> responseEntity) {
Map<String, List<String>> headers = responseEntity.getHeaders();
Map<String, List<String>> headers = SpringHttpSupport.toHttpHeadersMap(responseEntity.getHeaders());
HttpStatus httpStatus = HttpStatus.fromCode(responseEntity.getStatusCode().value());
if (isTerminalRedirectWithLocation(httpStatus, headers)) {
throw HttpException.builder().redirectLoop(httpStatus).build();
Expand Down Expand Up @@ -367,7 +367,7 @@ protected String extractResponseBody(final Throwable throwable) {
@Override
protected Map<String, List<String>> extractResponseHeaders(final Throwable throwable) {
return switch (throwable) {
case HttpStatusCodeException httpStatusCodeException -> Maps.safe(httpStatusCodeException.getResponseHeaders());
case HttpStatusCodeException httpStatusCodeException -> SpringHttpSupport.toHttpHeadersMap(httpStatusCodeException.getResponseHeaders());
default -> super.extractResponseHeaders(throwable);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.apiphany.http.ResponseEntityExtractor;
import org.apiphany.http.SpringHttpSupport;
import org.apiphany.json.SpringJson;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.restclient.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RequestCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ private RestClient.Builder customize(final RestClient.Builder restClientBuilder)
if (null == SpringHttpSupport.getRequestFactory(restClientBuilder)) {
restClientBuilder.requestFactory(getRequestFactory());
}
return restClientBuilder.messageConverters(getMessageConverters());
return restClientBuilder.configureMessageConverters(clientBuilder -> {
clientBuilder.disableDefaults();
clientBuilder.configureMessageConvertersList(converters -> {
converters.clear();
converters.addAll(getMessageConverters());
});
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ public static CloseableHttpRequestFactory create(final ClientProperties clientPr
// build the HTTP client and create the request factory with the appropriate settings from the client properties
HttpClient httpClient = httpClientBuilder.build();
JdkClientHttpRequestFactory requestFactory = new JdkClientHttpRequestFactory(httpClient);
requestFactory.enableCompression(false);
requestFactory.setReadTimeout(JavaNetHttpClients.getTimeout(clientProperties.getTimeout(), Timeout::getRequest));
return CloseableHttpRequestFactory.of(requestFactory, httpClient);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apiphany.io.OneShotInputStreamSupplier;
import org.morphix.reflection.Constructors;
import org.morphix.reflection.Fields;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.restclient.RestTemplateBuilder;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpEntity;
Expand All @@ -18,6 +20,7 @@
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.web.client.RestClient;

/**
Expand Down Expand Up @@ -151,6 +154,21 @@ public static boolean hasRequestFactory(final RestTemplateBuilder restTemplateBu
return null != Fields.IgnoreAccess.get(restTemplateBuilder, "requestFactoryBuilder");
}

/**
* Transforms an {@link HttpHeaders} object to a map of headers.
*
* @param headers source headers
* @return HTTP headers
*/
public static Map<String, List<String>> toHttpHeadersMap(final HttpHeaders headers) {
Map<String, List<String>> httpHeaders = new LinkedCaseInsensitiveMap<>();
if (null == headers) {
return httpHeaders;
}
headers.forEach((key, values) -> httpHeaders.put(key, new ArrayList<>(values)));
return httpHeaders;
}

/**
* Hide constructor.
*/
Expand Down
Loading
Loading