Skip to content

Commit 967478b

Browse files
committed
Merge branch '5.2.x'
2 parents d706899 + 3201671 commit 967478b

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -142,10 +142,10 @@ protected static final class DefaultCustomCodecs implements CustomCodecs {
142142
* @since 5.1.12
143143
*/
144144
DefaultCustomCodecs(DefaultCustomCodecs other) {
145-
other.typedReaders.putAll(this.typedReaders);
146-
other.typedWriters.putAll(this.typedWriters);
147-
other.objectReaders.putAll(this.objectReaders);
148-
other.objectWriters.putAll(this.objectWriters);
145+
this.typedReaders.putAll(other.typedReaders);
146+
this.typedWriters.putAll(other.typedWriters);
147+
this.objectReaders.putAll(other.objectReaders);
148+
this.objectWriters.putAll(other.objectWriters);
149149
}
150150

151151
@Override

spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@
6969
* @author Rossen Stoyanchev
7070
* @author Sebastien Deleuze
7171
*/
72-
public class CodecConfigurerTests {
72+
class CodecConfigurerTests {
7373

7474
private final CodecConfigurer configurer = new TestCodecConfigurer();
7575

7676
private final AtomicInteger index = new AtomicInteger(0);
7777

7878

7979
@Test
80-
public void defaultReaders() {
80+
void defaultReaders() {
8181
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
8282
assertThat(readers.size()).isEqualTo(12);
8383
assertThat(getNextDecoder(readers).getClass()).isEqualTo(ByteArrayDecoder.class);
@@ -95,7 +95,7 @@ public void defaultReaders() {
9595
}
9696

9797
@Test
98-
public void defaultWriters() {
98+
void defaultWriters() {
9999
List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
100100
assertThat(writers.size()).isEqualTo(11);
101101
assertThat(getNextEncoder(writers).getClass()).isEqualTo(ByteArrayEncoder.class);
@@ -112,7 +112,7 @@ public void defaultWriters() {
112112
}
113113

114114
@Test
115-
public void defaultAndCustomReaders() {
115+
void defaultAndCustomReaders() {
116116
Decoder<?> customDecoder1 = mock(Decoder.class);
117117
Decoder<?> customDecoder2 = mock(Decoder.class);
118118

@@ -153,7 +153,7 @@ public void defaultAndCustomReaders() {
153153
}
154154

155155
@Test
156-
public void defaultAndCustomWriters() {
156+
void defaultAndCustomWriters() {
157157
Encoder<?> customEncoder1 = mock(Encoder.class);
158158
Encoder<?> customEncoder2 = mock(Encoder.class);
159159

@@ -193,7 +193,7 @@ public void defaultAndCustomWriters() {
193193
}
194194

195195
@Test
196-
public void defaultsOffCustomReaders() {
196+
void defaultsOffCustomReaders() {
197197
Decoder<?> customDecoder1 = mock(Decoder.class);
198198
Decoder<?> customDecoder2 = mock(Decoder.class);
199199

@@ -224,7 +224,7 @@ public void defaultsOffCustomReaders() {
224224
}
225225

226226
@Test
227-
public void defaultsOffWithCustomWriters() {
227+
void defaultsOffWithCustomWriters() {
228228
Encoder<?> customEncoder1 = mock(Encoder.class);
229229
Encoder<?> customEncoder2 = mock(Encoder.class);
230230

@@ -255,7 +255,7 @@ public void defaultsOffWithCustomWriters() {
255255
}
256256

257257
@Test
258-
public void encoderDecoderOverrides() {
258+
void encoderDecoderOverrides() {
259259
Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
260260
Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder();
261261
Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder();
@@ -285,23 +285,45 @@ public void encoderDecoderOverrides() {
285285
}
286286

287287
@Test
288-
public void cloneCustomCodecs() {
288+
void cloneEmptyCustomCodecs() {
289289
this.configurer.registerDefaults(false);
290-
CodecConfigurer clone = this.configurer.clone();
290+
assertThat(this.configurer.getReaders()).isEmpty();
291+
assertThat(this.configurer.getWriters()).isEmpty();
291292

293+
CodecConfigurer clone = this.configurer.clone();
292294
clone.customCodecs().register(new Jackson2JsonEncoder());
293295
clone.customCodecs().register(new Jackson2JsonDecoder());
294296
clone.customCodecs().register(new ServerSentEventHttpMessageReader());
295297
clone.customCodecs().register(new ServerSentEventHttpMessageWriter());
296298

297-
assertThat(this.configurer.getReaders().size()).isEqualTo(0);
298-
assertThat(this.configurer.getWriters().size()).isEqualTo(0);
299-
assertThat(clone.getReaders().size()).isEqualTo(2);
300-
assertThat(clone.getWriters().size()).isEqualTo(2);
299+
assertThat(this.configurer.getReaders()).isEmpty();
300+
assertThat(this.configurer.getWriters()).isEmpty();
301+
assertThat(clone.getReaders()).hasSize(2);
302+
assertThat(clone.getWriters()).hasSize(2);
303+
}
304+
305+
@Test
306+
void cloneCustomCodecs() {
307+
this.configurer.registerDefaults(false);
308+
assertThat(this.configurer.getReaders()).isEmpty();
309+
assertThat(this.configurer.getWriters()).isEmpty();
310+
311+
this.configurer.customCodecs().register(new Jackson2JsonEncoder());
312+
this.configurer.customCodecs().register(new Jackson2JsonDecoder());
313+
this.configurer.customCodecs().register(new ServerSentEventHttpMessageReader());
314+
this.configurer.customCodecs().register(new ServerSentEventHttpMessageWriter());
315+
assertThat(this.configurer.getReaders()).hasSize(2);
316+
assertThat(this.configurer.getWriters()).hasSize(2);
317+
318+
CodecConfigurer clone = this.configurer.clone();
319+
assertThat(this.configurer.getReaders()).hasSize(2);
320+
assertThat(this.configurer.getWriters()).hasSize(2);
321+
assertThat(clone.getReaders()).hasSize(2);
322+
assertThat(clone.getWriters()).hasSize(2);
301323
}
302324

303325
@Test
304-
public void cloneDefaultCodecs() {
326+
void cloneDefaultCodecs() {
305327
CodecConfigurer clone = this.configurer.clone();
306328

307329
Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();

0 commit comments

Comments
 (0)