Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
04638098
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 搜索 >>
提交
04638098
编写于
10月 30, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Nullability refinements
上级
773b2f06
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
23 deletion
+30
-23
spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java
...org/springframework/mock/web/MockHttpServletResponse.java
+4
-2
spring-web/src/main/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReader.java
...ttp/codec/multipart/SynchronossPartHttpMessageReader.java
+22
-19
spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java
...pringframework/mock/web/test/MockHttpServletResponse.java
+4
-2
未找到文件。
spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java
浏览文件 @
04638098
...
...
@@ -27,6 +27,7 @@ import java.nio.charset.Charset;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -375,8 +376,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
if
(
maxAge
>=
0
)
{
buf
.
append
(
"; Max-Age="
).
append
(
maxAge
);
buf
.
append
(
"; Expires="
);
if
(
cookie
instanceof
MockCookie
&&
((
MockCookie
)
cookie
).
getExpires
()
!=
null
)
{
buf
.
append
(((
MockCookie
)
cookie
).
getExpires
().
format
(
DateTimeFormatter
.
RFC_1123_DATE_TIME
));
ZonedDateTime
expires
=
(
cookie
instanceof
MockCookie
?
((
MockCookie
)
cookie
).
getExpires
()
:
null
);
if
(
expires
!=
null
)
{
buf
.
append
(
expires
.
format
(
DateTimeFormatter
.
RFC_1123_DATE_TIME
));
}
else
{
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
spring-web/src/main/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReader.java
浏览文件 @
04638098
...
...
@@ -162,7 +162,6 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
(
mediaType
==
null
||
MediaType
.
MULTIPART_FORM_DATA
.
isCompatibleWith
(
mediaType
));
}
@Override
public
Flux
<
Part
>
read
(
ResolvableType
elementType
,
ReactiveHttpInputMessage
message
,
Map
<
String
,
Object
>
hints
)
{
return
Flux
.
create
(
new
SynchronossPartGenerator
(
message
))
...
...
@@ -176,13 +175,9 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
});
}
@Override
public
Mono
<
Part
>
readMono
(
ResolvableType
elementType
,
ReactiveHttpInputMessage
message
,
Map
<
String
,
Object
>
hints
)
{
return
Mono
.
error
(
new
UnsupportedOperationException
(
"Cannot read multipart request body into single Part"
));
public
Mono
<
Part
>
readMono
(
ResolvableType
elementType
,
ReactiveHttpInputMessage
message
,
Map
<
String
,
Object
>
hints
)
{
return
Mono
.
error
(
new
UnsupportedOperationException
(
"Cannot read multipart request body into single Part"
));
}
...
...
@@ -196,16 +191,16 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
private
final
LimitedPartBodyStreamStorageFactory
storageFactory
=
new
LimitedPartBodyStreamStorageFactory
();
@Nullable
private
NioMultipartParserListener
listener
;
@Nullable
private
NioMultipartParser
parser
;
public
SynchronossPartGenerator
(
ReactiveHttpInputMessage
inputMessage
)
{
this
.
inputMessage
=
inputMessage
;
}
@Override
public
void
accept
(
FluxSink
<
Part
>
sink
)
{
HttpHeaders
headers
=
this
.
inputMessage
.
getHeaders
();
...
...
@@ -228,10 +223,13 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
@Override
protected
void
hookOnNext
(
DataBuffer
buffer
)
{
Assert
.
state
(
this
.
parser
!=
null
&&
this
.
listener
!=
null
,
"Not initialized yet"
);
int
size
=
buffer
.
readableByteCount
();
this
.
storageFactory
.
increaseByteCount
(
size
);
byte
[]
resultBytes
=
new
byte
[
size
];
buffer
.
read
(
resultBytes
);
try
{
this
.
parser
.
write
(
resultBytes
);
}
...
...
@@ -248,24 +246,32 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
@Override
protected
void
hookOnError
(
Throwable
ex
)
{
try
{
this
.
parser
.
close
();
if
(
this
.
parser
!=
null
)
{
this
.
parser
.
close
();
}
}
catch
(
IOException
ex2
)
{
// ignore
}
finally
{
int
index
=
this
.
storageFactory
.
getCurrentPartIndex
();
this
.
listener
.
onError
(
"Failure while parsing part["
+
index
+
"]"
,
ex
);
if
(
this
.
listener
!=
null
)
{
int
index
=
this
.
storageFactory
.
getCurrentPartIndex
();
this
.
listener
.
onError
(
"Failure while parsing part["
+
index
+
"]"
,
ex
);
}
}
}
@Override
protected
void
hookFinally
(
SignalType
type
)
{
try
{
this
.
parser
.
close
();
if
(
this
.
parser
!=
null
)
{
this
.
parser
.
close
();
}
}
catch
(
IOException
ex
)
{
this
.
listener
.
onError
(
"Error while closing parser"
,
ex
);
if
(
this
.
listener
!=
null
)
{
this
.
listener
.
onError
(
"Error while closing parser"
,
ex
);
}
}
}
...
...
@@ -279,9 +285,9 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
private
class
LimitedPartBodyStreamStorageFactory
implements
PartBodyStreamStorageFactory
{
private
final
PartBodyStreamStorageFactory
storageFactory
=
maxInMemorySize
>
0
?
private
final
PartBodyStreamStorageFactory
storageFactory
=
(
maxInMemorySize
>
0
?
new
DefaultPartBodyStreamStorageFactory
(
maxInMemorySize
)
:
new
DefaultPartBodyStreamStorageFactory
();
new
DefaultPartBodyStreamStorageFactory
()
)
;
private
int
index
=
1
;
...
...
@@ -289,7 +295,6 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
private
long
partSize
;
public
int
getCurrentPartIndex
()
{
return
this
.
index
;
}
...
...
@@ -338,7 +343,6 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
private
final
AtomicInteger
terminated
=
new
AtomicInteger
(
0
);
FluxSinkAdapterListener
(
FluxSink
<
Part
>
sink
,
MultipartContext
context
,
LimitedPartBodyStreamStorageFactory
factory
)
{
...
...
@@ -347,7 +351,6 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
this
.
storageFactory
=
factory
;
}
@Override
public
void
onPartFinished
(
StreamStorage
storage
,
Map
<
String
,
List
<
String
>>
headers
)
{
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
...
...
spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java
浏览文件 @
04638098
...
...
@@ -27,6 +27,7 @@ import java.nio.charset.Charset;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -375,8 +376,9 @@ public class MockHttpServletResponse implements HttpServletResponse {
if
(
maxAge
>=
0
)
{
buf
.
append
(
"; Max-Age="
).
append
(
maxAge
);
buf
.
append
(
"; Expires="
);
if
(
cookie
instanceof
MockCookie
&&
((
MockCookie
)
cookie
).
getExpires
()
!=
null
)
{
buf
.
append
(((
MockCookie
)
cookie
).
getExpires
().
format
(
DateTimeFormatter
.
RFC_1123_DATE_TIME
));
ZonedDateTime
expires
=
(
cookie
instanceof
MockCookie
?
((
MockCookie
)
cookie
).
getExpires
()
:
null
);
if
(
expires
!=
null
)
{
buf
.
append
(
expires
.
format
(
DateTimeFormatter
.
RFC_1123_DATE_TIME
));
}
else
{
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录