diff --git a/router-protobuf/build.gradle.kts b/router-protobuf/build.gradle.kts index b43c9bbe..dfdd730e 100644 --- a/router-protobuf/build.gradle.kts +++ b/router-protobuf/build.gradle.kts @@ -1,8 +1,5 @@ -import com.google.protobuf.gradle.protobuf -import com.google.protobuf.gradle.protoc - plugins { - id("com.google.protobuf") version "0.8.19" + id("com.google.protobuf") version "0.9.4" } repositories { @@ -25,12 +22,4 @@ dependencies { testImplementation("io.mockk:mockk:1.13.11") testImplementation("org.slf4j:slf4j-simple:2.0.13") testImplementation("com.jayway.jsonpath:json-path:2.9.0") -} - - -protobuf { - protoc { - // The artifact spec for the Protobuf Compiler - artifact = "com.google.protobuf:protoc:4.27.2" - } -} +} \ No newline at end of file diff --git a/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoDeserializationHandler.kt b/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoDeserializationHandler.kt index 36a163aa..40ff196a 100644 --- a/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoDeserializationHandler.kt +++ b/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoDeserializationHandler.kt @@ -19,7 +19,7 @@ class ProtoDeserializationHandler : DeserializationHandler { if (input.contentType() == null) { false } else { - MediaType.parse(input.contentType()).let { proto.isCompatibleWith(it) || protoStructuredSuffixWildcard.isCompatibleWith(it) } + MediaType.parse(input.contentType()!!).let { proto.isCompatibleWith(it) || protoStructuredSuffixWildcard.isCompatibleWith(it) } } override fun deserialize( diff --git a/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoSerializationHandler.kt b/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoSerializationHandler.kt index e6fd932c..4a041bd0 100644 --- a/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoSerializationHandler.kt +++ b/router-protobuf/src/main/kotlin/io/moia/router/proto/ProtoSerializationHandler.kt @@ -1,7 +1,7 @@ package io.moia.router.proto import com.google.common.net.MediaType -import com.google.protobuf.GeneratedMessageV3 +import com.google.protobuf.GeneratedMessage import io.moia.router.SerializationHandler import isCompatibleWith import java.util.Base64 @@ -13,13 +13,13 @@ class ProtoSerializationHandler : SerializationHandler { override fun supports( acceptHeader: MediaType, body: Any, - ): Boolean = body is GeneratedMessageV3 + ): Boolean = body is GeneratedMessage override fun serialize( acceptHeader: MediaType, body: Any, ): String { - val message = body as GeneratedMessageV3 + val message = body as GeneratedMessage return if (json.isCompatibleWith(acceptHeader) || jsonStructuredSuffixWildcard.isCompatibleWith(acceptHeader)) { ProtoBufUtils.toJsonWithoutWrappers(message) } else { diff --git a/router-protobuf/src/test/proto/Sample.proto b/router-protobuf/src/test/proto/Sample.proto index 95c164ba..7fb40b79 100644 --- a/router-protobuf/src/test/proto/Sample.proto +++ b/router-protobuf/src/test/proto/Sample.proto @@ -2,6 +2,10 @@ syntax = "proto3"; package io.moia.router.proto.sample; +option java_multiple_files = false; +option java_outer_classname = "SampleOuterClass"; +option java_package = "io.moia.router.proto.sample"; + import "google/protobuf/wrappers.proto"; message Sample {