Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4d058cee
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,发现更多精彩内容 >>
提交
4d058cee
编写于
4月 21, 2017
作者:
V
Violeta Georgieva
提交者:
Arjen Poutsma
4月 24, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resume Undertow writes only when data is available
上级
55833dc3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
8 deletion
+40
-8
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
.../http/server/reactive/AbstractListenerWriteProcessor.java
+16
-0
spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java
...ework/http/server/reactive/ServletServerHttpResponse.java
+5
-0
spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java
...work/http/server/reactive/UndertowServerHttpResponse.java
+19
-8
未找到文件。
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
浏览文件 @
4d058cee
...
...
@@ -150,6 +150,18 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
*/
protected
abstract
boolean
write
(
T
data
)
throws
IOException
;
/**
* Suspend writing. Defaults to no-op.
*/
protected
void
suspendWriting
()
{
}
/**
* Invoked when writing is complete. Defaults to no-op.
*/
protected
void
writingComplete
()
{
}
private
boolean
changeState
(
State
oldState
,
State
newState
)
{
return
this
.
state
.
compareAndSet
(
oldState
,
newState
);
...
...
@@ -223,6 +235,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
@Override
public
<
T
>
void
onComplete
(
AbstractListenerWriteProcessor
<
T
>
processor
)
{
if
(
processor
.
changeState
(
this
,
COMPLETED
))
{
processor
.
writingComplete
();
processor
.
resultPublisher
.
publishComplete
();
}
}
...
...
@@ -248,10 +261,12 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
processor
.
releaseData
();
if
(!
processor
.
subscriberCompleted
)
{
processor
.
changeState
(
WRITING
,
REQUESTED
);
processor
.
suspendWriting
();
processor
.
subscription
.
request
(
1
);
}
else
{
processor
.
changeState
(
WRITING
,
COMPLETED
);
processor
.
writingComplete
();
processor
.
resultPublisher
.
publishComplete
();
}
}
...
...
@@ -311,6 +326,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
public
<
T
>
void
onError
(
AbstractListenerWriteProcessor
<
T
>
processor
,
Throwable
ex
)
{
if
(
processor
.
changeState
(
this
,
COMPLETED
))
{
processor
.
writingComplete
();
processor
.
resultPublisher
.
publishError
(
ex
);
}
}
...
...
spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java
浏览文件 @
4d058cee
...
...
@@ -306,6 +306,11 @@ public class ServletServerHttpResponse extends AbstractListenerServerHttpRespons
return
false
;
}
}
@Override
protected
void
writingComplete
()
{
bodyProcessor
=
null
;
}
}
}
spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java
浏览文件 @
4d058cee
...
...
@@ -138,9 +138,7 @@ public class UndertowServerHttpResponse extends AbstractListenerServerHttpRespon
if
(
this
.
responseChannel
==
null
)
{
this
.
responseChannel
=
this
.
exchange
.
getResponseChannel
();
}
ResponseBodyProcessor
bodyProcessor
=
new
ResponseBodyProcessor
(
this
.
responseChannel
);
bodyProcessor
.
registerListener
();
return
bodyProcessor
;
return
new
ResponseBodyProcessor
(
this
.
responseChannel
);
}
...
...
@@ -153,16 +151,18 @@ public class UndertowServerHttpResponse extends AbstractListenerServerHttpRespon
public
ResponseBodyProcessor
(
StreamSinkChannel
channel
)
{
Assert
.
notNull
(
channel
,
"StreamSinkChannel must not be null"
);
this
.
channel
=
channel
;
}
public
void
registerListener
()
{
this
.
channel
.
getWriteSetter
().
set
(
c
->
onWritePossible
());
this
.
channel
.
resume
Writes
();
this
.
channel
.
suspend
Writes
();
}
@Override
protected
boolean
isWritePossible
()
{
return
false
;
if
(
this
.
channel
.
isWriteResumed
())
{
return
true
;
}
else
{
this
.
channel
.
resumeWrites
();
return
false
;
}
}
@Override
...
...
@@ -214,6 +214,17 @@ public class UndertowServerHttpResponse extends AbstractListenerServerHttpRespon
protected
boolean
isDataEmpty
(
DataBuffer
dataBuffer
)
{
return
(
dataBuffer
.
readableByteCount
()
==
0
);
}
@Override
protected
void
suspendWriting
()
{
this
.
channel
.
suspendWrites
();
}
@Override
protected
void
writingComplete
()
{
this
.
channel
.
getWriteSetter
().
set
(
null
);
this
.
channel
.
resumeWrites
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录