From c1839938ea42cd444be4d678b13ea04847960ed0 Mon Sep 17 00:00:00 2001 From: Kamil Doroszkiewicz Date: Tue, 25 Mar 2025 10:37:29 +0100 Subject: [PATCH] Add support for "application/*+x-protobuf" media type See gh-34645 Signed-off-by: Kamil Doroszkiewicz --- .../ProtobufHttpMessageConverter.java | 22 ++++++++++++------- .../ProtobufHttpMessageConverterTests.java | 3 +++ ...ufJsonFormatHttpMessageConverterTests.java | 3 +++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java index c8fc030aa29..4fcbf0d34c6 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java @@ -41,7 +41,6 @@ import org.springframework.http.converter.AbstractHttpMessageConverter; import org.springframework.http.converter.HttpMessageConversionException; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.http.converter.HttpMessageNotWritableException; -import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; @@ -55,8 +54,8 @@ import static org.springframework.http.MediaType.TEXT_PLAIN; * *

To generate {@code Message} Java classes, you need to install the {@code protoc} binary. * - *

This converter supports by default {@code "application/x-protobuf"} and {@code "text/plain"} - * with the official {@code "com.google.protobuf:protobuf-java"} library. + *

This converter supports by default {@code "application/x-protobuf"}, {@code "application/*+x-protobuf"} + * and {@code "text/plain"} with the official {@code "com.google.protobuf:protobuf-java"} library. * The {@code "application/json"} format is also supported with the {@code "com.google.protobuf:protobuf-java-util"} * dependency. See {@link ProtobufJsonFormatHttpMessageConverter} for a configurable variant. * @@ -66,6 +65,7 @@ import static org.springframework.http.MediaType.TEXT_PLAIN; * @author Brian Clozel * @author Juergen Hoeller * @author Sebastien Deleuze + * @author Kamil Doroszkiewicz * @since 4.1 * @see JsonFormat * @see ProtobufJsonFormatHttpMessageConverter @@ -82,6 +82,11 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter