diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90258a9c..420ed083 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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()`.
diff --git a/README.md b/README.md
index 05123e43..20b47faa 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -62,7 +62,7 @@ Maven: add this dependency to your `pom.xml`
io.github.radukingapiphany
- 1.2.23
+ 1.3.0
```
diff --git a/apiphany-core/pom.xml b/apiphany-core/pom.xml
index 0a49bb74..10f3d7d6 100644
--- a/apiphany-core/pom.xml
+++ b/apiphany-core/pom.xml
@@ -8,7 +8,7 @@
io.github.radukingapiphany-parent
- 1.2.23
+ 1.3.0apiphany
diff --git a/apiphany-httpclient5/pom.xml b/apiphany-httpclient5/pom.xml
index ec5a7a94..a0ac0eae 100644
--- a/apiphany-httpclient5/pom.xml
+++ b/apiphany-httpclient5/pom.xml
@@ -8,7 +8,7 @@
io.github.radukingapiphany-parent
- 1.2.23
+ 1.3.0apiphany-httpclient5
diff --git a/apiphany-httpclient5/src/main/java/org/apiphany/http/ApacheHC5Library.java b/apiphany-httpclient5/src/main/java/org/apiphany/http/ApacheHC5Library.java
index e6d71cb2..14651ce3 100644
--- a/apiphany-httpclient5/src/main/java/org/apiphany/http/ApacheHC5Library.java
+++ b/apiphany-httpclient5/src/main/java/org/apiphany/http/ApacheHC5Library.java
@@ -31,7 +31,7 @@ public class ApacheHC5Library {
*
* 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.
diff --git a/apiphany-httpclient5/src/test/java/org/apiphany/http/ApacheHC5LibraryTest.java b/apiphany-httpclient5/src/test/java/org/apiphany/http/ApacheHC5LibraryTest.java
index 05e9fdcd..425b2791 100644
--- a/apiphany-httpclient5/src/test/java/org/apiphany/http/ApacheHC5LibraryTest.java
+++ b/apiphany-httpclient5/src/test/java/org/apiphany/http/ApacheHC5LibraryTest.java
@@ -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 {
@@ -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
@@ -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));
}
}
diff --git a/apiphany-integration-tests/pom.xml b/apiphany-integration-tests/pom.xml
index c26835a0..ef69df6b 100644
--- a/apiphany-integration-tests/pom.xml
+++ b/apiphany-integration-tests/pom.xml
@@ -8,7 +8,7 @@
io.github.radukingapiphany-parent
- 1.2.23
+ 1.3.0apiphany-integration-tests
diff --git a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ssl/client/SSLClientIT.java b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ssl/client/SSLClientIT.java
index 56ce4c7b..dc82ed92 100644
--- a/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ssl/client/SSLClientIT.java
+++ b/apiphany-integration-tests/src/test/java/org/apiphany/tests/security/ssl/client/SSLClientIT.java
@@ -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 {
diff --git a/apiphany-okhttp/pom.xml b/apiphany-okhttp/pom.xml
index 09f33260..64a80fcc 100644
--- a/apiphany-okhttp/pom.xml
+++ b/apiphany-okhttp/pom.xml
@@ -8,7 +8,7 @@
io.github.radukingapiphany-parent
- 1.2.23
+ 1.3.0apiphany-okhttp
diff --git a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java
index 31a81554..6698338d 100644
--- a/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java
+++ b/apiphany-okhttp/src/main/java/org/apiphany/http/OkHttpLibrary.java
@@ -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: 4.12.0.
+ * The maximum OkHttp version this module supports, i.e. the highest version it was tested against: 4.12.1.
*
- * A JSON-capable {@code HttpMessageConverter} contributes the mapper Spring built from the application's JSON library
- * configuration. That mapper writes JSON request bodies as-is. A builder with no such converter has no converter, and
- * the exchange client falls back to {@link JsonBuilder}.
+ * A JSON-capable {@link HttpMessageConverter} may expose a mapper configured by Spring (for example, from the
+ * application's Jackson configuration). When present, that converter is used by the Spring-based exchange clients to
+ * write JSON request bodies. If no usable JSON converter is found, the exchange client falls back to
+ * {@link JsonBuilder}.
*
- * This class is library-agnostic. It verifies {@link Jackson2Library#isPresent()} before consulting
- * {@link Jackson2SpringJson} for each JSON-capable message converter found on the builder. That presence check is what
- * allows {@link Jackson2SpringJson} to use Jackson 2 types directly instead of reflection.
+ * This class resolves Jackson 2 and Jackson 3 converters. It verifies each library's presence before delegating to the
+ * corresponding resolver, allowing the library-specific code to reference Jackson types directly without reflective
+ * class loading.
*
* @author Radu Sebastian LAZIN
*/
public final class SpringJson {
/**
- * Field that holds the converters configured on a Spring client builder.
+ * Namespace class for field names.
+ *
+ * @author Radu Sebastian LAZIN
*/
- private static final String MESSAGE_CONVERTERS_FIELD_NAME = "messageConverters";
+ public static class FieldName {
+
+ /**
+ * Field name holding the message converters configured on a Spring client builder.
+ */
+ private static final String MESSAGE_CONVERTERS = "messageConverters";
+
+ /**
+ * Field name holding the converters configurer on a {@link RestClient.Builder}.
+ */
+ private static final String CONVERTERS_CONFIGURER = "convertersConfigurer";
+
+ /**
+ * Field name holding the JSON converter on a {@link HttpMessageConverters.ClientBuilder}.
+ */
+ private static final String JSON_CONVERTER = "jsonConverter";
+
+ /**
+ * Hide constructor.
+ */
+ private FieldName() {
+ throw Constructors.unsupportedOperationException();
+ }
+ }
+
+ /**
+ * Resolver function that resolves the appropriate content converter based on a Spring HTTP message converter.
+ *
+ * @param type that the content converter knows to convert
+ *
+ * @author Radu Sebastian LAZIN
+ */
+ @FunctionalInterface
+ private interface ResolverFunction extends Function, ContentConverter> {
+ // empty
+ }
/**
* Maps each optional JSON library to the function that resolves a Spring message converter to a
* {@link ContentConverter}. A resolver is used only when its library is present.
*/
- private static final Map, Function, ContentConverter>>> CONVERTER_RESOLVERS_MAP = Map.of(
- Jackson2Library.DESCRIPTOR, Jackson2SpringJson::converter);
+ private static final Map, ResolverFunction>> CONVERTER_RESOLVERS_MAP = Map.of(
+ Jackson2Library.DESCRIPTOR, Jackson2SpringJson::converter,
+ Jackson3Library.DESCRIPTOR, Jackson3SpringJson::converter);
/**
* Returns the JSON request converter configured on the given {@link RestClient.Builder}, or {@code null} when the
* builder has no usable JSON converter.
+ *
+ * This method supports both the traditional approach (where message converters are directly set on the builder via
+ * {@code messageConverters(...)}) and the new Spring Framework 7 approach (where converters are configured via
+ * {@link HttpMessageConverters.ClientBuilder} through a configurer).
*
* @param the content type the converter knows to convert
- *
* @param restClientBuilder the REST client builder
* @return the JSON request converter, or {@code null}
*/
public static ContentConverter converter(final RestClient.Builder restClientBuilder) {
- return converter(messageConverters(restClientBuilder));
+ Iterable> messageConverters = messageConverters(restClientBuilder);
+ if (null != messageConverters) {
+ return converter(messageConverters);
+ }
+ Consumer convertersConfigurer = convertersConfigurer(restClientBuilder);
+ if (null == convertersConfigurer) {
+ return null;
+ }
+ HttpMessageConverters.ClientBuilder clientBuilder = HttpMessageConverters.forClient();
+ convertersConfigurer.accept(clientBuilder);
+ HttpMessageConverter> jsonConverter = jsonConverter(clientBuilder);
+ return resolveContentConverter(jsonConverter);
}
/**
@@ -63,7 +120,6 @@ public static ContentConverter converter(final RestClient.Builder restCli
* builder has no usable JSON converter.
*
* @param the content type the converter knows to convert
- *
* @param restTemplateBuilder the REST template builder
* @return the JSON request converter, or {@code null}
*/
@@ -83,7 +139,7 @@ public static ContentConverter converter(final RestTemplateBuilder restTe
static ContentConverter converter(final Iterable> messageConverters) {
for (HttpMessageConverter> messageConverter : Iterables.safe(messageConverters)) {
if (supportsJson(messageConverter)) {
- ContentConverter resolved = resolvedConverter(messageConverter);
+ ContentConverter resolved = resolveContentConverter(messageConverter);
if (resolved != null) {
return resolved;
}
@@ -93,19 +149,19 @@ static ContentConverter converter(final Iterable>
}
/**
- * Returns the resolved content converter.
+ * Returns the resolved content converter from the given Spring message converter, or {@code null} if the converter is
+ * not a supported JSON converter.
*
* @param the content type the converter knows to convert
- *
* @param messageConverter any Spring message converter
- * @return the resolved content converter
+ * @return the resolved content converter, or {@code null}
*/
- private static ContentConverter resolvedConverter(final HttpMessageConverter> messageConverter) {
- for (Map.Entry, Function, ContentConverter>>> entry : CONVERTER_RESOLVERS_MAP.entrySet()) {
+ private static ContentConverter resolveContentConverter(final HttpMessageConverter> messageConverter) {
+ for (Map.Entry, ResolverFunction>> entry : CONVERTER_RESOLVERS_MAP.entrySet()) {
OptionalLibrary> optionalLibrary = entry.getKey();
if (optionalLibrary.isPresent()) {
- Function, ContentConverter>> resolverFunction = entry.getValue();
- ContentConverter resolved = JavaObjects.cast(resolverFunction.apply(messageConverter));
+ ResolverFunction resolverFunction = JavaObjects.cast(entry.getValue());
+ ContentConverter resolved = resolverFunction.apply(messageConverter);
if (null != resolved) {
return resolved;
}
@@ -115,24 +171,13 @@ private static ContentConverter resolvedConverter(final HttpMessageConver
}
/**
- * Returns the converters already set on the builder. A builder that has not been given converters keeps a {@code null}
- * field, and this method does not initialize the builder's defaults.
- *
- * @param builder the Spring client builder
- * @return the configured converters, or {@code null}
- */
- private static Iterable> messageConverters(final Object builder) {
- if (null == builder) {
- return Collections.emptyList();
- }
- return Fields.IgnoreAccess.get(builder, MESSAGE_CONVERTERS_FIELD_NAME);
- }
-
- /**
- * Returns {@code true} when the converter writes JSON.
+ * Returns {@code true} when the converter supports JSON media types.
+ *
+ * A converter is considered to support JSON if any of its supported media types has subtype {@code json} or ends with
+ * {@code +json} (case-insensitive).
*
* @param converter the message converter
- * @return {@code true} when one of the supported media types is JSON
+ * @return {@code true} when the converter supports JSON, {@code false} otherwise
*/
private static boolean supportsJson(final Object converter) {
if (!(converter instanceof HttpMessageConverter> httpMessageConverter)) {
@@ -147,6 +192,41 @@ private static boolean supportsJson(final Object converter) {
return false;
}
+ /**
+ * Returns the converters already set on the builder. A builder that has not been given converters keeps a {@code null}
+ * field, and this method does not initialize the builder's defaults.
+ *
+ * @param builder the Spring client builder
+ * @return the configured converters, or {@code null}
+ */
+ private static Iterable> messageConverters(final Object builder) {
+ return Nullables.