Skip to content

Commit 2d5d988

Browse files
committed
Polishing contribution
Closes gh-34645
1 parent c183993 commit 2d5d988

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

spring-web/src/main/java/org/springframework/http/codec/protobuf/ProtobufCodecSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ public abstract class ProtobufCodecSupport {
3333

3434
static final MimeType[] MIME_TYPES = new MimeType[]{
3535
new MimeType("application", "x-protobuf"),
36+
new MimeType("application", "*+x-protobuf"),
3637
new MimeType("application", "octet-stream"),
3738
new MimeType("application", "vnd.google.protobuf")
3839
};

spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void extensionRegistryNull() {
7070
public void canDecode() {
7171
assertThat(this.decoder.canDecode(forClass(Msg.class), null)).isTrue();
7272
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_PROTOBUF)).isTrue();
73+
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf"))).isTrue();
7374
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_OCTET_STREAM)).isTrue();
7475
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_JSON)).isFalse();
7576
assertThat(this.decoder.canDecode(forClass(Object.class), MediaType.APPLICATION_PROTOBUF)).isFalse();

spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,10 +45,10 @@ class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
4545

4646
private static final MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
4747

48-
private Msg msg1 =
48+
private final Msg msg1 =
4949
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
5050

51-
private Msg msg2 =
51+
private final Msg msg2 =
5252
Msg.newBuilder().setFoo("Bar").setBlah(SecondMsg.newBuilder().setBlah(456).build()).build();
5353

5454

@@ -61,6 +61,7 @@ public ProtobufEncoderTests() {
6161
protected void canEncode() {
6262
assertThat(this.encoder.canEncode(forClass(Msg.class), null)).isTrue();
6363
assertThat(this.encoder.canEncode(forClass(Msg.class), PROTOBUF_MIME_TYPE)).isTrue();
64+
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf"))).isTrue();
6465
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.APPLICATION_OCTET_STREAM)).isTrue();
6566
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.APPLICATION_JSON)).isFalse();
6667
assertThat(this.encoder.canEncode(forClass(Object.class), PROTOBUF_MIME_TYPE)).isFalse();

spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class ProtobufHttpMessageConverterTests {
4545

4646
private ProtobufHttpMessageConverter converter = new ProtobufHttpMessageConverter();
4747

48-
private ExtensionRegistry extensionRegistry = mock();
48+
private final ExtensionRegistry extensionRegistry = mock();
4949

50-
private Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
51-
private MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
50+
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
51+
private final MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
5252

5353

5454
@Test

spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ProtobufJsonFormatHttpMessageConverterTests {
4242
JsonFormat.parser(), JsonFormat.printer());
4343

4444
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
45-
private MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.examle.public.v1+x-protobuf");
45+
private final MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
4646

4747

4848
@Test

0 commit comments

Comments
 (0)