File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
main/java/org/springframework/http/codec/support
test/java/org/springframework/http/codec/support Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,10 @@ protected static final class DefaultCustomCodecs implements CustomCodecs {
142
142
* @since 5.1.12
143
143
*/
144
144
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 );
149
149
}
150
150
151
151
@ Override
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ public void encoderDecoderOverrides() {
279
279
}
280
280
281
281
@ Test
282
- public void cloneCustomCodecs () {
282
+ public void cloneEmptyCustomCodecs () {
283
283
this .configurer .registerDefaults (false );
284
284
CodecConfigurer clone = this .configurer .clone ();
285
285
@@ -294,6 +294,22 @@ public void cloneCustomCodecs() {
294
294
assertThat (clone .getWriters ().size ()).isEqualTo (2 );
295
295
}
296
296
297
+ @ Test
298
+ public void cloneCustomCodecs () {
299
+ CodecConfigurer from = new TestCodecConfigurer ();
300
+ from .registerDefaults (false );
301
+ from .customCodecs ().register (new Jackson2JsonEncoder ());
302
+ from .customCodecs ().register (new Jackson2JsonDecoder ());
303
+ from .customCodecs ().register (new ServerSentEventHttpMessageReader ());
304
+ from .customCodecs ().register (new ServerSentEventHttpMessageWriter ());
305
+
306
+ CodecConfigurer clone = from .clone ();
307
+ assertThat (from .getReaders ().size ()).isEqualTo (2 );
308
+ assertThat (from .getWriters ().size ()).isEqualTo (2 );
309
+ assertThat (clone .getReaders ().size ()).isEqualTo (2 );
310
+ assertThat (clone .getWriters ().size ()).isEqualTo (2 );
311
+ }
312
+
297
313
@ Test
298
314
public void cloneDefaultCodecs () {
299
315
CodecConfigurer clone = this .configurer .clone ();
You can’t perform that action at this time.
0 commit comments