Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
49388315
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
49388315
编写于
3月 20, 2019
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Register custom before default codecs
Closes gh-22612
上级
e9819b75
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java
...ringframework/http/codec/support/BaseCodecConfigurer.java
+5
-5
spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java
...ingframework/http/codec/support/CodecConfigurerTests.java
+8
-8
未找到文件。
spring-web/src/main/java/org/springframework/http/codec/support/BaseCodecConfigurer.java
浏览文件 @
49388315
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -72,11 +72,11 @@ class BaseCodecConfigurer implements CodecConfigurer {
public
List
<
HttpMessageReader
<?>>
getReaders
()
{
List
<
HttpMessageReader
<?>>
result
=
new
ArrayList
<>();
result
.
addAll
(
this
.
defaultCodecs
.
getTypedReaders
());
result
.
addAll
(
this
.
customCodecs
.
getTypedReaders
());
result
.
addAll
(
this
.
defaultCodecs
.
getTypedReaders
());
result
.
addAll
(
this
.
defaultCodecs
.
getObjectReaders
());
result
.
addAll
(
this
.
customCodecs
.
getObjectReaders
());
result
.
addAll
(
this
.
defaultCodecs
.
getObjectReaders
());
result
.
addAll
(
this
.
defaultCodecs
.
getCatchAllReaders
());
return
result
;
...
...
@@ -96,11 +96,11 @@ class BaseCodecConfigurer implements CodecConfigurer {
protected
List
<
HttpMessageWriter
<?>>
getWritersInternal
(
boolean
forMultipart
)
{
List
<
HttpMessageWriter
<?>>
result
=
new
ArrayList
<>();
result
.
addAll
(
this
.
defaultCodecs
.
getTypedWriters
(
forMultipart
));
result
.
addAll
(
this
.
customCodecs
.
getTypedWriters
());
result
.
addAll
(
this
.
defaultCodecs
.
getTypedWriters
(
forMultipart
));
result
.
addAll
(
this
.
defaultCodecs
.
getObjectWriters
(
forMultipart
));
result
.
addAll
(
this
.
customCodecs
.
getObjectWriters
());
result
.
addAll
(
this
.
defaultCodecs
.
getObjectWriters
(
forMultipart
));
result
.
addAll
(
this
.
defaultCodecs
.
getCatchAllWriters
());
return
result
;
...
...
spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java
浏览文件 @
49388315
...
...
@@ -125,6 +125,8 @@ public class CodecConfigurerTests {
List
<
HttpMessageReader
<?>>
readers
=
this
.
configurer
.
getReaders
();
assertEquals
(
15
,
readers
.
size
());
assertSame
(
customDecoder1
,
getNextDecoder
(
readers
));
assertSame
(
customReader1
,
readers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
...
...
@@ -132,13 +134,11 @@ public class CodecConfigurerTests {
assertEquals
(
StringDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
assertSame
(
customDecoder
1
,
getNextDecoder
(
readers
));
assertSame
(
customReader
1
,
readers
.
get
(
this
.
index
.
getAndIncrement
()));
assertSame
(
customDecoder
2
,
getNextDecoder
(
readers
));
assertSame
(
customReader
2
,
readers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
Jackson2JsonDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Jackson2SmileDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Jaxb2XmlDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertSame
(
customDecoder2
,
getNextDecoder
(
readers
));
assertSame
(
customReader2
,
readers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
StringDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
}
...
...
@@ -165,19 +165,19 @@ public class CodecConfigurerTests {
List
<
HttpMessageWriter
<?>>
writers
=
this
.
configurer
.
getWriters
();
assertEquals
(
14
,
writers
.
size
());
assertSame
(
customEncoder1
,
getNextEncoder
(
writers
));
assertSame
(
customWriter1
,
writers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
ByteArrayEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
ByteBufferEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
DataBufferEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
ResourceHttpMessageWriter
.
class
,
writers
.
get
(
index
.
getAndIncrement
()).
getClass
());
assertEquals
(
CharSequenceEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
ProtobufHttpMessageWriter
.
class
,
writers
.
get
(
index
.
getAndIncrement
()).
getClass
());
assertSame
(
customEncoder
1
,
getNextEncoder
(
writers
));
assertSame
(
customWriter
1
,
writers
.
get
(
this
.
index
.
getAndIncrement
()));
assertSame
(
customEncoder
2
,
getNextEncoder
(
writers
));
assertSame
(
customWriter
2
,
writers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
Jackson2JsonEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
Jackson2SmileEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertEquals
(
Jaxb2XmlEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
assertSame
(
customEncoder2
,
getNextEncoder
(
writers
));
assertSame
(
customWriter2
,
writers
.
get
(
this
.
index
.
getAndIncrement
()));
assertEquals
(
CharSequenceEncoder
.
class
,
getNextEncoder
(
writers
).
getClass
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录