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> {
...
@@ -45,22 +45,17 @@ public class JacksonJsonDecoder extends AbstractDecoder<Object> {
private
final
ObjectMapper
mapper
;
private
final
ObjectMapper
mapper
;
private
Decoder
<
DataBuffer
>
preProcessor
;
private
final
Decoder
<
DataBuffer
>
preProcessor
=
new
JsonObjectDecoder
()
;
public
JacksonJsonDecoder
()
{
public
JacksonJsonDecoder
()
{
this
(
new
ObjectMapper
()
,
null
);
this
(
new
ObjectMapper
());
}
}
public
JacksonJsonDecoder
(
Decoder
<
DataBuffer
>
preProcessor
)
{
public
JacksonJsonDecoder
(
ObjectMapper
mapper
)
{
this
(
new
ObjectMapper
(),
preProcessor
);
}
public
JacksonJsonDecoder
(
ObjectMapper
mapper
,
Decoder
<
DataBuffer
>
preProcessor
)
{
super
(
new
MimeType
(
"application"
,
"json"
,
StandardCharsets
.
UTF_8
),
super
(
new
MimeType
(
"application"
,
"json"
,
StandardCharsets
.
UTF_8
),
new
MimeType
(
"application"
,
"*+json"
,
StandardCharsets
.
UTF_8
));
new
MimeType
(
"application"
,
"*+json"
,
StandardCharsets
.
UTF_8
));
this
.
mapper
=
mapper
;
this
.
mapper
=
mapper
;
this
.
preProcessor
=
preProcessor
;
}
}
@Override
@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;
...
@@ -28,7 +28,6 @@ import org.springframework.core.codec.support.ByteBufferDecoder;
import
org.springframework.core.codec.support.ByteBufferEncoder
;
import
org.springframework.core.codec.support.ByteBufferEncoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
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.StringDecoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -86,7 +85,7 @@ public final class WebClient {
...
@@ -86,7 +85,7 @@ public final class WebClient {
this
.
messageEncoders
=
Arrays
.
asList
(
new
ByteBufferEncoder
(),
new
StringEncoder
(),
this
.
messageEncoders
=
Arrays
.
asList
(
new
ByteBufferEncoder
(),
new
StringEncoder
(),
new
JacksonJsonEncoder
());
new
JacksonJsonEncoder
());
this
.
messageDecoders
=
Arrays
.
asList
(
new
ByteBufferDecoder
(),
new
StringDecoder
(),
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;
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.support.JacksonJsonDecoder;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
import
org.springframework.core.codec.support.Jaxb2Decoder
;
import
org.springframework.core.codec.support.Jaxb2Decoder
;
import
org.springframework.core.codec.support.Jaxb2Encoder
;
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.StringDecoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.core.codec.support.StringEncoder
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.core.convert.converter.Converter
;
...
@@ -251,7 +250,7 @@ public class WebReactiveConfiguration implements ApplicationContextAware {
...
@@ -251,7 +250,7 @@ public class WebReactiveConfiguration implements ApplicationContextAware {
}
}
if
(
jackson2Present
)
{
if
(
jackson2Present
)
{
JacksonJsonEncoder
jacksonEncoder
=
new
JacksonJsonEncoder
();
JacksonJsonEncoder
jacksonEncoder
=
new
JacksonJsonEncoder
();
JacksonJsonDecoder
jacksonDecoder
=
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
);
JacksonJsonDecoder
jacksonDecoder
=
new
JacksonJsonDecoder
();
converters
.
add
(
converter
(
jacksonEncoder
,
jacksonDecoder
));
converters
.
add
(
converter
(
jacksonEncoder
,
jacksonDecoder
));
sseDataEncoders
.
add
(
jacksonEncoder
);
sseDataEncoders
.
add
(
jacksonEncoder
);
}
else
{
}
else
{
...
...
spring-web-reactive/src/test/java/org/springframework/core/codec/support/JacksonJsonDecoderTests.java
浏览文件 @
1f2fbba8
...
@@ -59,8 +59,8 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
...
@@ -59,8 +59,8 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
}
}
@Test
@Test
@Ignore
// Issue
s 112 (no generic type), otherwise works
@Ignore
// Issue
109
public
void
decodeToList
WithoutObjectDecoder
()
throws
Exception
{
public
void
decodeToList
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
...
@@ -73,8 +73,7 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
...
@@ -73,8 +73,7 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
}
}
@Test
@Test
@Ignore
// Issue 109
public
void
decodeToFlux
()
throws
Exception
{
public
void
decodeToFluxWithoutObjectDecoder
()
throws
Exception
{
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
Flux
<
DataBuffer
>
source
=
Flux
.
just
(
stringBuffer
(
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
"[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"
));
...
@@ -85,32 +84,6 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
...
@@ -85,32 +84,6 @@ public class JacksonJsonDecoderTests extends AbstractDataBufferAllocatingTestCas
assertValues
(
new
Pojo
(
"f1"
,
"b1"
),
new
Pojo
(
"f2"
,
"b2"
));
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"
)
@SuppressWarnings
(
"unused"
)
void
handle
(
List
<
Pojo
>
list
)
{
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;
...
@@ -44,7 +44,6 @@ import org.springframework.core.ParameterNameDiscoverer;
import
org.springframework.core.annotation.SynthesizingMethodParameter
;
import
org.springframework.core.annotation.SynthesizingMethodParameter
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
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.codec.support.StringDecoder
;
import
org.springframework.core.convert.support.GenericConversionService
;
import
org.springframework.core.convert.support.GenericConversionService
;
import
org.springframework.core.convert.support.ReactiveStreamsToCompletableFutureConverter
;
import
org.springframework.core.convert.support.ReactiveStreamsToCompletableFutureConverter
;
...
@@ -93,7 +92,7 @@ public class RequestBodyArgumentResolverTests {
...
@@ -93,7 +92,7 @@ public class RequestBodyArgumentResolverTests {
@Before
@Before
public
void
setUp
()
throws
Exception
{
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"
));
this
.
request
=
new
MockServerHttpRequest
(
HttpMethod
.
GET
,
new
URI
(
"/path"
));
MockServerHttpResponse
response
=
new
MockServerHttpResponse
();
MockServerHttpResponse
response
=
new
MockServerHttpResponse
();
DefaultWebSessionManager
sessionManager
=
new
DefaultWebSessionManager
();
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;
...
@@ -33,7 +33,6 @@ import org.springframework.core.codec.Encoder;
import
org.springframework.core.codec.support.ByteBufferDecoder
;
import
org.springframework.core.codec.support.ByteBufferDecoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonDecoder
;
import
org.springframework.core.codec.support.JacksonJsonEncoder
;
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.StringDecoder
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.client.reactive.ReactorHttpClientRequestFactory
;
import
org.springframework.http.client.reactive.ReactorHttpClientRequestFactory
;
...
@@ -69,7 +68,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
...
@@ -69,7 +68,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
this
.
webClient
.
setMessageDecoders
(
Arrays
.
asList
(
this
.
webClient
.
setMessageDecoders
(
Arrays
.
asList
(
new
ByteBufferDecoder
(),
new
ByteBufferDecoder
(),
new
StringDecoder
(
false
),
new
StringDecoder
(
false
),
new
JacksonJsonDecoder
(
new
JsonObjectDecoder
()
)));
new
JacksonJsonDecoder
()));
}
}
@Override
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录