diff --git a/framework-platform/framework-platform.gradle b/framework-platform/framework-platform.gradle index c86bb55850..b2741933bb 100644 --- a/framework-platform/framework-platform.gradle +++ b/framework-platform/framework-platform.gradle @@ -30,8 +30,7 @@ dependencies { api("com.google.code.findbugs:findbugs:3.0.1") api("com.google.code.findbugs:jsr305:3.0.2") api("com.google.code.gson:gson:2.10.1") - api("com.google.protobuf:protobuf-java-util:3.23.2") - api("com.googlecode.protobuf-java-format:protobuf-java-format:1.4") + api("com.google.protobuf:protobuf-java-util:3.24.4") api("com.h2database:h2:2.2.220") api("com.jayway.jsonpath:json-path:2.8.0") api("com.rometools:rome:1.19.0") diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index 7d59e0ff40..c6ab2cb833 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -18,7 +18,6 @@ dependencies { optional("com.fasterxml.woodstox:woodstox-core") optional("com.google.code.gson:gson") optional("com.google.protobuf:protobuf-java-util") - optional("com.googlecode.protobuf-java-format:protobuf-java-format") optional("com.rometools:rome") optional("com.squareup.okhttp3:okhttp") optional("io.reactivex.rxjava3:rxjava") 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 1c20e75774..dbaa8bf475 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +32,6 @@ import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.TextFormat; import com.google.protobuf.util.JsonFormat; -import com.googlecode.protobuf.format.FormatFactory; -import com.googlecode.protobuf.format.ProtobufFormatter; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; @@ -48,8 +46,6 @@ import org.springframework.util.ClassUtils; import org.springframework.util.ConcurrentReferenceHashMap; import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.http.MediaType.APPLICATION_XML; -import static org.springframework.http.MediaType.TEXT_HTML; import static org.springframework.http.MediaType.TEXT_PLAIN; /** @@ -60,26 +56,17 @@ 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. Other formats can be - * supported with one of the following additional libraries on the classpath: - *

+ * 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. * - *

Requires Protobuf 2.6 or higher (and Protobuf Java Format 1.4 or higher for formatting). - * This converter will auto-adapt to Protobuf 3 and its default {@code protobuf-java-util} JSON - * format if the Protobuf 2 based {@code protobuf-java-format} isn't present; however, for more - * explicit JSON setup on Protobuf 3, consider {@link ProtobufJsonFormatHttpMessageConverter}. + *

This converter requires Protobuf 3 or higher as of Spring Framework 6.1. * * @author Alex Antonov * @author Brian Clozel * @author Juergen Hoeller * @author Sebastien Deleuze * @since 4.1 - * @see FormatFactory * @see JsonFormat * @see ProtobufJsonFormatHttpMessageConverter */ @@ -105,18 +92,10 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter, Method> methodCache = new ConcurrentReferenceHashMap<>(); - static { - ClassLoader classLoader = ProtobufHttpMessageConverter.class.getClassLoader(); - protobufFormatFactoryPresent = ClassUtils.isPresent("com.googlecode.protobuf.format.FormatFactory", classLoader); - protobufJsonFormatPresent = ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", classLoader); - } - final ExtensionRegistry extensionRegistry; @@ -146,9 +125,6 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter