From 79dbdd5f2aea954e38c77660235374ec099dfd5e Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 07:38:00 +0200 Subject: [PATCH 1/8] Remove erroneously added quarkus version from kotlin integration test --- integration-tests/kotlin-serialization/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-tests/kotlin-serialization/pom.xml b/integration-tests/kotlin-serialization/pom.xml index e72059383f116..239f554b4e600 100644 --- a/integration-tests/kotlin-serialization/pom.xml +++ b/integration-tests/kotlin-serialization/pom.xml @@ -22,7 +22,6 @@ io.quarkus quarkus-resteasy-reactive-kotlin-serialization - 999-SNAPSHOT From 883edd315dac905009405ab2ea6c7a51b020a1b4 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 07:42:10 +0200 Subject: [PATCH 2/8] Fix Arc issue with Kotlin Serialization in RESTEasy Reactive and REST Client Fixes: #22712 --- .../deployment/pom.xml | 6 ++++- .../KotlinSerializationCommonProcessor.java | 23 +++++++++++++++++++ .../runtime/pom.xml | 6 ++++- .../KotlinSerializationProcessor.java | 17 -------------- ...tReactiveKotlinSerializationProcessor.java | 17 -------------- .../kotlin-serialization/pom.xml | 1 + .../pom.xml | 17 ++++++++++++++ 7 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/src/main/java/io/quarkus/kotlin/serialization/KotlinSerializationCommonProcessor.java diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/pom.xml b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/pom.xml index 163d021e52c7f..e2407d7417aeb 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/pom.xml +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/pom.xml @@ -18,6 +18,10 @@ io.quarkus quarkus-resteasy-reactive-kotlin-serialization-common + + io.quarkus + quarkus-arc-deployment + io.quarkus quarkus-kotlin-deployment @@ -40,4 +44,4 @@ - \ No newline at end of file + diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/src/main/java/io/quarkus/kotlin/serialization/KotlinSerializationCommonProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/src/main/java/io/quarkus/kotlin/serialization/KotlinSerializationCommonProcessor.java new file mode 100644 index 0000000000000..709daad17ba35 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/deployment/src/main/java/io/quarkus/kotlin/serialization/KotlinSerializationCommonProcessor.java @@ -0,0 +1,23 @@ +package io.quarkus.kotlin.serialization; + +import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; + +import javax.inject.Singleton; + +import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.Record; +import kotlinx.serialization.json.Json; + +public class KotlinSerializationCommonProcessor { + + @BuildStep + @Record(STATIC_INIT) + public SyntheticBeanBuildItem createJson(KotlinSerializerRecorder recorder, KotlinSerializationConfig config) { + return SyntheticBeanBuildItem + .configure(Json.class) + .scope(Singleton.class) + .supplier(recorder.configFactory(config)) + .unremovable().done(); + } +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/pom.xml b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/pom.xml index c0ebec3f5cf6f..0e4fe6f1b61a4 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/pom.xml +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/pom.xml @@ -97,6 +97,10 @@ io.quarkus quarkus-kotlin + + io.quarkus + quarkus-arc + org.jetbrains.kotlinx kotlinx-serialization-json @@ -108,4 +112,4 @@ - \ No newline at end of file + diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java index 24b8d37e71bb3..b88789d81190a 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java @@ -1,28 +1,21 @@ package io.quarkus.kotlin.serialization.deployment; import static io.quarkus.deployment.Feature.RESTEASY_REACTIVE_KOTLIN_SERIALIZATION; -import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; import static io.quarkus.resteasy.reactive.common.deployment.ServerDefaultProducesHandlerBuildItem.json; import java.util.List; -import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.kotlin.serialization.KotlinSerializationConfig; import io.quarkus.kotlin.serialization.KotlinSerializationMessageBodyReader; import io.quarkus.kotlin.serialization.KotlinSerializationMessageBodyWriter; -import io.quarkus.kotlin.serialization.KotlinSerializerRecorder; import io.quarkus.resteasy.reactive.common.deployment.ServerDefaultProducesHandlerBuildItem; import io.quarkus.resteasy.reactive.spi.MessageBodyReaderBuildItem; import io.quarkus.resteasy.reactive.spi.MessageBodyWriterBuildItem; -import kotlinx.serialization.json.Json; public class KotlinSerializationProcessor { @BuildStep @@ -42,16 +35,6 @@ public void additionalProviders( MediaType.APPLICATION_JSON))); } - @BuildStep - @Record(STATIC_INIT) - public SyntheticBeanBuildItem createJson(KotlinSerializerRecorder recorder, KotlinSerializationConfig config) { - return SyntheticBeanBuildItem - .configure(Json.class) - .scope(Singleton.class) - .supplier(recorder.configFactory(config)) - .unremovable().done(); - } - @BuildStep public void feature(BuildProducer feature) { feature.produce(new FeatureBuildItem(RESTEASY_REACTIVE_KOTLIN_SERIALIZATION)); diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java index 877027d12d513..df78465588103 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java @@ -1,26 +1,19 @@ package io.quarkus.rest.client.reactive.kotlin.deployment; import static io.quarkus.deployment.Feature.REST_CLIENT_REACTIVE_KOTLIN_SERIALIZATION; -import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; import java.util.Collections; -import javax.inject.Singleton; import javax.ws.rs.core.MediaType; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.kotlin.serialization.KotlinSerializationConfig; -import io.quarkus.kotlin.serialization.KotlinSerializerRecorder; import io.quarkus.rest.client.reactive.kotlin.runtime.serializers.ClientKotlinMessageBodyReader; import io.quarkus.rest.client.reactive.kotlin.runtime.serializers.ClientKotlinMessageBodyWriter; import io.quarkus.resteasy.reactive.spi.MessageBodyReaderBuildItem; import io.quarkus.resteasy.reactive.spi.MessageBodyWriterBuildItem; -import kotlinx.serialization.json.Json; public class RestClientReactiveKotlinSerializationProcessor { @@ -46,14 +39,4 @@ void additionalProviders( .produce(new MessageBodyWriterBuildItem(ClientKotlinMessageBodyWriter.class.getName(), Object.class.getName(), Collections.singletonList(MediaType.APPLICATION_JSON))); } - - @BuildStep - @Record(STATIC_INIT) - public SyntheticBeanBuildItem createJson(KotlinSerializerRecorder recorder, KotlinSerializationConfig config) { - return SyntheticBeanBuildItem - .configure(Json.class) - .scope(Singleton.class) - .supplier(recorder.configFactory(config)) - .unremovable().done(); - } } diff --git a/integration-tests/kotlin-serialization/pom.xml b/integration-tests/kotlin-serialization/pom.xml index 239f554b4e600..e72059383f116 100644 --- a/integration-tests/kotlin-serialization/pom.xml +++ b/integration-tests/kotlin-serialization/pom.xml @@ -22,6 +22,7 @@ io.quarkus quarkus-resteasy-reactive-kotlin-serialization + 999-SNAPSHOT diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/pom.xml b/integration-tests/rest-client-reactive-kotlin-serialization/pom.xml index e836d40221a5f..49e282a1fb813 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/pom.xml +++ b/integration-tests/rest-client-reactive-kotlin-serialization/pom.xml @@ -12,6 +12,10 @@ Quarkus - Integration Tests - REST Client Reactive Kotlin Serialization + + io.quarkus + quarkus-resteasy-reactive-kotlin-serialization + io.quarkus quarkus-rest-client-reactive-kotlin-serialization @@ -40,6 +44,19 @@ + + io.quarkus + quarkus-resteasy-reactive-kotlin-serialization-deployment + ${project.version} + pom + test + + + * + * + + + io.quarkus quarkus-rest-client-reactive-kotlin-serialization-deployment From 74cebd15ffe5b12ce3ed5da8bfe0f3d70ead35bd Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 07:47:41 +0200 Subject: [PATCH 3/8] Remove erroneous usage of @Inject in Kotlin serialization This didn't prevent things from working, but it did result in an Arc warning --- .../serialization/KotlinSerializationMessageBodyReader.kt | 4 ++-- .../serialization/KotlinSerializationMessageBodyWriter.kt | 2 +- .../runtime/serializers/ClientKotlinMessageBodyReader.kt | 4 ++-- .../runtime/serializers/ClientKotlinMessageBodyWriter.kt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt index 9aed0e44bfb14..b2aed1696b661 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt @@ -15,7 +15,7 @@ import javax.inject.Inject import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap -class KotlinSerializationMessageBodyReader(@Inject var json: Json) : AbstractJsonMessageBodyReader(), ServerMessageBodyReader { +class KotlinSerializationMessageBodyReader(var json: Json) : AbstractJsonMessageBodyReader(), ServerMessageBodyReader { override fun isReadable(type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType) = isReadable(mediaType, type) @@ -42,4 +42,4 @@ class KotlinSerializationMessageBodyReader(@Inject var json: Json) : AbstractJso return if (StreamUtil.isEmpty(entityStream)) null else json.decodeFromStream(serializer(type), entityStream) } -} \ No newline at end of file +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt index ead259f72e5ff..3f7c44cee6046 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt @@ -18,7 +18,7 @@ import javax.ws.rs.core.MultivaluedMap @Produces("application/json", "application/*+json", "text/json") @OptIn(ExperimentalSerializationApi::class) -class KotlinSerializationMessageBodyWriter(@Inject var json: Json) : AllWriteableMessageBodyWriter() { +class KotlinSerializationMessageBodyWriter(var json: Json) : AllWriteableMessageBodyWriter() { override fun writeTo( o: Any, type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType, httpHeaders: MultivaluedMap, entityStream: OutputStream diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt index 82fd3efc8618d..a8fc7c4260c11 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt @@ -13,7 +13,7 @@ import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyReader @OptIn(ExperimentalSerializationApi::class) -class ClientKotlinMessageBodyReader(@Inject val json: Json) : MessageBodyReader { +class ClientKotlinMessageBodyReader(val json: Json) : MessageBodyReader { override fun isReadable(type: Class<*>?, generic: Type?, annotations: Array?, mediaType: MediaType?) = true override fun readFrom( @@ -23,4 +23,4 @@ class ClientKotlinMessageBodyReader(@Inject val json: Json) : MessageBodyReader< return if (StreamUtil.isEmpty(entityStream)) null else json.decodeFromStream(serializer(generic), entityStream) } -} \ No newline at end of file +} diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt index 8996fdfebf25c..d47376670030e 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt @@ -12,7 +12,7 @@ import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyWriter @OptIn(ExperimentalSerializationApi::class) -class ClientKotlinMessageBodyWriter(@Inject val json: Json) : MessageBodyWriter { +class ClientKotlinMessageBodyWriter(val json: Json) : MessageBodyWriter { override fun isWriteable(type: Class<*>, genericType: Type, annotations: Array?, mediaType: MediaType?) = true override fun writeTo( @@ -21,4 +21,4 @@ class ClientKotlinMessageBodyWriter(@Inject val json: Json) : MessageBodyWriter< ) { json.encodeToStream(serializer(genericType), t, entityStream) } -} \ No newline at end of file +} From 139c2ba38aab7dc1e8ae24f7fd01772175854bb1 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 08:09:08 +0200 Subject: [PATCH 4/8] Use proper modifiers for Json field of Kotlin Serialization providers --- .../serialization/KotlinSerializationMessageBodyReader.kt | 2 +- .../serialization/KotlinSerializationMessageBodyWriter.kt | 2 +- .../kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt | 2 +- .../kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt index b2aed1696b661..14096462b0d2d 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt @@ -15,7 +15,7 @@ import javax.inject.Inject import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap -class KotlinSerializationMessageBodyReader(var json: Json) : AbstractJsonMessageBodyReader(), ServerMessageBodyReader { +class KotlinSerializationMessageBodyReader(private val json: Json) : AbstractJsonMessageBodyReader(), ServerMessageBodyReader { override fun isReadable(type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType) = isReadable(mediaType, type) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt index 3f7c44cee6046..28650279d1830 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt @@ -18,7 +18,7 @@ import javax.ws.rs.core.MultivaluedMap @Produces("application/json", "application/*+json", "text/json") @OptIn(ExperimentalSerializationApi::class) -class KotlinSerializationMessageBodyWriter(var json: Json) : AllWriteableMessageBodyWriter() { +class KotlinSerializationMessageBodyWriter(private val json: Json) : AllWriteableMessageBodyWriter() { override fun writeTo( o: Any, type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType, httpHeaders: MultivaluedMap, entityStream: OutputStream diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt index a8fc7c4260c11..a63bd5cc7f7f0 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt @@ -13,7 +13,7 @@ import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyReader @OptIn(ExperimentalSerializationApi::class) -class ClientKotlinMessageBodyReader(val json: Json) : MessageBodyReader { +class ClientKotlinMessageBodyReader(private val json: Json) : MessageBodyReader { override fun isReadable(type: Class<*>?, generic: Type?, annotations: Array?, mediaType: MediaType?) = true override fun readFrom( diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt index d47376670030e..9b2ee6178e290 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt @@ -12,7 +12,7 @@ import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyWriter @OptIn(ExperimentalSerializationApi::class) -class ClientKotlinMessageBodyWriter(val json: Json) : MessageBodyWriter { +class ClientKotlinMessageBodyWriter(private val json: Json) : MessageBodyWriter { override fun isWriteable(type: Class<*>, genericType: Type, annotations: Array?, mediaType: MediaType?) = true override fun writeTo( From 37fcc3528939ebc627d0825c3afc18c51f00a765 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 08:11:00 +0200 Subject: [PATCH 5/8] Remove erroneous deployment to server from client --- .../deployment/pom.xml | 4 ---- .../runtime/pom.xml | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml index c1f9da96b07ff..6a067a40e6ea6 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml @@ -15,10 +15,6 @@ io.quarkus quarkus-rest-client-reactive-kotlin-serialization - - io.quarkus - quarkus-resteasy-reactive-deployment - io.quarkus quarkus-kotlin-deployment diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/pom.xml b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/pom.xml index 8e240163d7402..005a80502dc02 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/pom.xml +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/pom.xml @@ -22,10 +22,6 @@ io.quarkus quarkus-resteasy-reactive-kotlin-serialization-common - - io.quarkus - quarkus-resteasy-reactive - @@ -100,4 +96,4 @@ - \ No newline at end of file + From 245a307cad0c86d7b6d17de9181e539e65b6a9aa Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 08:11:20 +0200 Subject: [PATCH 6/8] Add missing dependency to common module --- .../deployment/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml index 6a067a40e6ea6..9b2ff1af6ea38 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/pom.xml @@ -31,6 +31,10 @@ io.quarkus quarkus-rest-client-reactive-deployment + + io.quarkus + quarkus-resteasy-reactive-kotlin-serialization-common-deployment + From 27f4b8504efabb9b6fa7fe15ff68f00bfd5ce5b4 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 09:16:37 +0200 Subject: [PATCH 7/8] Prevent NPE during Kotlin serialization --- .../serialization/KotlinSerializationMessageBodyReader.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt index 14096462b0d2d..b5a99f7892b61 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt @@ -16,7 +16,7 @@ import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap class KotlinSerializationMessageBodyReader(private val json: Json) : AbstractJsonMessageBodyReader(), ServerMessageBodyReader { - override fun isReadable(type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType) = + override fun isReadable(type: Class<*>, genericType: Type, annotations: Array?, mediaType: MediaType) = isReadable(mediaType, type) override fun isReadable(type: Class<*>, genericType: Type, lazyMethod: ResteasyReactiveResourceInfo, mediaType: MediaType) = From 832a16c7bde345f2e6e42a79d40f50729248d837 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 7 Jan 2022 09:26:00 +0200 Subject: [PATCH 8/8] Ensure Kotlin Serialization providers are limited to the proper runtime type --- .../deployment/KotlinSerializationProcessor.java | 8 ++++++-- .../RestClientReactiveKotlinSerializationProcessor.java | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java index b88789d81190a..192c6e14e51b4 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/kotlin/serialization/deployment/KotlinSerializationProcessor.java @@ -5,6 +5,8 @@ import java.util.List; +import javax.ws.rs.Priorities; +import javax.ws.rs.RuntimeType; import javax.ws.rs.core.MediaType; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; @@ -29,10 +31,12 @@ public void additionalProviders( .setUnremovable().build()); additionalReaders.produce(new MessageBodyReaderBuildItem( KotlinSerializationMessageBodyReader.class.getName(), Object.class.getName(), List.of( - MediaType.APPLICATION_JSON))); + MediaType.APPLICATION_JSON), + RuntimeType.SERVER, true, Priorities.USER)); additionalWriters.produce(new MessageBodyWriterBuildItem( KotlinSerializationMessageBodyWriter.class.getName(), Object.class.getName(), List.of( - MediaType.APPLICATION_JSON))); + MediaType.APPLICATION_JSON), + RuntimeType.SERVER, true, Priorities.USER)); } @BuildStep diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java index df78465588103..c85df4428a142 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment/src/main/java/io/quarkus/rest/client/reactive/kotlin/deployment/RestClientReactiveKotlinSerializationProcessor.java @@ -4,6 +4,8 @@ import java.util.Collections; +import javax.ws.rs.Priorities; +import javax.ws.rs.RuntimeType; import javax.ws.rs.core.MediaType; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; @@ -34,9 +36,9 @@ void additionalProviders( additionalReaders .produce(new MessageBodyReaderBuildItem(ClientKotlinMessageBodyReader.class.getName(), Object.class.getName(), - Collections.singletonList(MediaType.APPLICATION_JSON))); + Collections.singletonList(MediaType.APPLICATION_JSON), RuntimeType.CLIENT, true, Priorities.USER)); additionalWriters .produce(new MessageBodyWriterBuildItem(ClientKotlinMessageBodyWriter.class.getName(), Object.class.getName(), - Collections.singletonList(MediaType.APPLICATION_JSON))); + Collections.singletonList(MediaType.APPLICATION_JSON), RuntimeType.CLIENT, true, Priorities.USER)); } }