Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
1f2fbba8
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,发现更多精彩内容 >>
提交
1f2fbba8
编写于
6月 29, 2016
作者:
S
Sebastien Deleuze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make JsonObjectDecoder mandatory in JacksonJsonDecoder
上级
92821d93
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
10 addition
and
46 deletion
+10
-46
spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java
...pringframework/core/codec/support/JacksonJsonDecoder.java
+3
-8
spring-web-reactive/src/main/java/org/springframework/web/client/reactive/WebClient.java
...va/org/springframework/web/client/reactive/WebClient.java
+1
-2
spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java
...amework/web/reactive/config/WebReactiveConfiguration.java
+1
-2
spring-web-reactive/src/test/java/org/springframework/core/codec/support/JacksonJsonDecoderTests.java
...framework/core/codec/support/JacksonJsonDecoderTests.java
+3
-30
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java
...t/method/annotation/RequestBodyArgumentResolverTests.java
+1
-2
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
...eactive/result/method/annotation/SseIntegrationTests.java
+1
-2
未找到文件。
spring-web-reactive/src/main/java/org/springframework/core/codec/support/JacksonJsonDecoder.java
浏览文件 @
1f2fbba8
...
...
@@ -45,22 +45,17 @@ public class JacksonJsonDecoder extends AbstractDecoder<Object> {
private
final
ObjectMapper
mapper
;
private
Decoder
<
DataBuffer
>
preProcessor
;
private
final
Decoder
<
DataBuffer
>
preProcessor
=
new
JsonObjectDecoder
()
;
public
JacksonJsonDecoder
()
{
this
(
new
ObjectMapper
()
,
null
);
this
(
new
ObjectMapper
());
}
public
JacksonJsonDecoder
(
Decoder
<
DataBuffer
>
preProcessor
)
{
this
(
new
ObjectMapper
(),
preProcessor
);
}
public
JacksonJsonDecoder
(
ObjectMapper
mapper
,
Decoder
<
DataBuffer
>
preProcessor
)
{
public
JacksonJsonDecoder
(
ObjectMapper
mapper
)
{
super
(
new
MimeType
(
"application"
,
"json"
,
StandardCharsets
.
UTF_8
),
new
MimeType
(
"application"
,
"*+json"
,
StandardCharsets
.
UTF_8
));
this
.
mapper
=
mapper
;
this
.
preProcessor
=
preProcessor
;
}
@Override
...
...
spring-web-reactive/src/main/java/org/springframework/web/client/reactive/WebClient.java
浏览文件 @
1f2fbba8
...
...
@@ -28,7 +28,6 @@ import org.springframework.core.codec.support.ByteBufferDecoder;
import
org.springframework.core.codec.support.ByteBufferEncoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
import
org.springframework.core.codec.support.JsonObjectDecoder
;
import
org.springframework.core.codec.support.StringDecoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -86,7 +85,7 @@ public final class WebClient {
this
.
messageEncoders
=
Arrays
.
asList
(
new
ByteBufferEncoder
(),
new
StringEncoder
(),
new
JacksonJsonEncoder
());
this
.
messageDecoders
=
Arrays
.
asList
(
new
ByteBufferDecoder
(),
new
StringDecoder
(),
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
));
new
JacksonJsonDecoder
());
}
/**
...
...
spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java
浏览文件 @
1f2fbba8
...
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.support.JacksonJsonDecoder;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
import
org.springframework.core.codec.support.Jaxb2Decoder
;
import
org.springframework.core.codec.support.Jaxb2Encoder
;
import
org.springframework.core.codec.support.JsonObjectDecoder
;
import
org.springframework.core.codec.support.StringDecoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.core.convert.converter.Converter
;
...
...
@@ -251,7 +250,7 @@ public class WebReactiveConfiguration implements ApplicationContextAware {
}
if
(
jackson2Present
)
{
JacksonJsonEncoder
jacksonEncoder
=
new
JacksonJsonEncoder
();
JacksonJsonDecoder
jacksonDecoder
=
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
);
JacksonJsonDecoder
jacksonDecoder
=
new
JacksonJsonDecoder
();
converters
.
add
(
converter
(
jacksonEncoder
,
jacksonDecoder
));
sseDataEncoders
.
add
(
jacksonEncoder
);
}
else
{
...
...
spring-web-reactive/src/test/java/org/springframework/core/codec/support/JacksonJsonDecoderTests.java
浏览文件 @
1f2fbba8
...
...
@@ -59,8 +59,8 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
}
@Test
@Ignore
// Issue
s 112 (no generic type), otherwise works
public
void
decodeToList
WithoutObjectDecoder
()
throws
Exception
{
@Ignore
// Issue
109
public
void
decodeToList
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
...
...
@@ -73,8 +73,7 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
}
@Test
@Ignore
// Issue 109
public
void
decodeToFluxWithoutObjectDecoder
()
throws
Exception
{
public
void
decodeToFlux
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
...
...
@@ -85,32 +84,6 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
assertValues
(
new
Pojo
(
"f1"
,
"b1"
),
new
Pojo
(
"f2"
,
"b2"
));
}
@Test
@Ignore
// Issue 109
public
void
decodeToListWithObjectDecoder
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
Method
method
=
getClass
().
getDeclaredMethod
(
"handle"
,
List
.
class
);
ResolvableType
elementType
=
ResolvableType
.
forMethodParameter
(
method
,
0
);
Flux
<
Object
>
flux
=
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()).
decode
(
source
,
elementType
,
null
);
TestSubscriber
.
subscribe
(
flux
).
assertNoError
().
assertComplete
().
assertValues
(
Arrays
.
asList
(
new
Pojo
(
"f1"
,
"b1"
),
new
Pojo
(
"f2"
,
"b2"
)));
}
@Test
public
void
decodeToFluxWithObjectDecoder
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
ResolvableType
elementType
=
ResolvableType
.
forClass
(
Pojo
.
class
);
Flux
<
Object
>
flux
=
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()).
decode
(
source
,
elementType
,
null
);
TestSubscriber
.
subscribe
(
flux
).
assertNoError
().
assertComplete
().
assertValues
(
new
Pojo
(
"f1"
,
"b1"
),
new
Pojo
(
"f2"
,
"b2"
));
}
@SuppressWarnings
(
"unused"
)
void
handle
(
List
<
Pojo
>
list
)
{
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java
浏览文件 @
1f2fbba8
...
...
@@ -44,7 +44,6 @@ import org.springframework.core.ParameterNameDiscoverer;
import
org.springframework.core.annotation.SynthesizingMethodParameter
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JsonObjectDecoder
;
import
org.springframework.core.codec.support.StringDecoder
;
import
org.springframework.core.convert.support.GenericConversionService
;
import
org.springframework.core.convert.support.ReactiveStreamsToCompletableFutureConverter
;
...
...
@@ -93,7 +92,7 @@ public class RequestBodyArgumentResolverTests {
@Before
public
void
setUp
()
throws
Exception
{
this
.
resolver
=
resolver
(
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
));
this
.
resolver
=
resolver
(
new
JacksonJsonDecoder
());
this
.
request
=
new
MockServerHttpRequest
(
HttpMethod
.
GET
,
new
URI
(
"/path"
));
MockServerHttpResponse
response
=
new
MockServerHttpResponse
();
DefaultWebSessionManager
sessionManager
=
new
DefaultWebSessionManager
();
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
浏览文件 @
1f2fbba8
...
...
@@ -33,7 +33,6 @@ import org.springframework.core.codec.Encoder;
import
org.springframework.core.codec.support.ByteBufferDecoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
import
org.springframework.core.codec.support.JsonObjectDecoder
;
import
org.springframework.core.codec.support.StringDecoder
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.client.reactive.ReactorHttpClientRequestFactory
;
...
...
@@ -69,7 +68,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
this
.
webClient
.
setMessageDecoders
(
Arrays
.
asList
(
new
ByteBufferDecoder
(),
new
StringDecoder
(
false
),
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
)));
new
JacksonJsonDecoder
()));
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录