Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
284bbf71
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
284bbf71
编写于
4月 12, 2017
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into javadoc
上级
7c16d8dc
1c67022c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
2 deletion
+22
-2
core/src/main/java/jenkins/util/FullDuplexHttpService.java
core/src/main/java/jenkins/util/FullDuplexHttpService.java
+20
-1
test/src/test/java/hudson/cli/CLIActionTest.java
test/src/test/java/hudson/cli/CLIActionTest.java
+2
-1
未找到文件。
core/src/main/java/jenkins/util/FullDuplexHttpService.java
浏览文件 @
284bbf71
...
...
@@ -32,6 +32,8 @@ import java.io.OutputStream;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletResponse
;
import
org.kohsuke.accmod.Restricted
;
...
...
@@ -46,6 +48,8 @@ import org.kohsuke.stapler.StaplerResponse;
*/
public
abstract
class
FullDuplexHttpService
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
FullDuplexHttpService
.
class
.
getName
());
/**
* Set to true if the servlet container doesn't support chunked encoding.
*/
...
...
@@ -92,12 +96,15 @@ public abstract class FullDuplexHttpService {
{
// wait until we have the other channel
long
end
=
System
.
currentTimeMillis
()
+
CONNECTION_TIMEOUT
;
while
(
upload
==
null
&&
System
.
currentTimeMillis
()
<
end
)
{
LOGGER
.
log
(
Level
.
FINE
,
"Waiting for upload stream for {0}: {1}"
,
new
Object
[]
{
uuid
,
this
});
wait
(
1000
);
}
if
(
upload
==
null
)
{
throw
new
IOException
(
"HTTP full-duplex channel timeout: "
+
uuid
);
}
LOGGER
.
log
(
Level
.
FINE
,
"Received upload stream {0} for {1}: {2}"
,
new
Object
[]
{
upload
,
uuid
,
this
});
}
try
{
...
...
@@ -123,6 +130,7 @@ public abstract class FullDuplexHttpService {
// publish the upload channel
upload
=
in
;
LOGGER
.
log
(
Level
.
FINE
,
"Recording upload stream {0} for {1}: {2}"
,
new
Object
[]
{
upload
,
uuid
,
this
});
notify
();
// wait until we are done
...
...
@@ -157,14 +165,25 @@ public abstract class FullDuplexHttpService {
if
(
req
.
getHeader
(
"Side"
).
equals
(
"download"
))
{
FullDuplexHttpService
service
=
createService
(
req
,
uuid
);
LOGGER
.
log
(
Level
.
FINE
,
"Processing download side for {0}: {1}"
,
new
Object
[]
{
uuid
,
service
});
services
.
put
(
uuid
,
service
);
try
{
service
.
download
(
req
,
rsp
);
}
finally
{
LOGGER
.
log
(
Level
.
FINE
,
"Finished download side for {0}: {1}"
,
new
Object
[]
{
uuid
,
service
});
services
.
remove
(
uuid
);
}
}
else
{
services
.
get
(
uuid
).
upload
(
req
,
rsp
);
FullDuplexHttpService
service
=
services
.
get
(
uuid
);
if
(
service
==
null
)
{
throw
new
IOException
(
"No download side found for "
+
uuid
);
}
LOGGER
.
log
(
Level
.
FINE
,
"Processing upload side for {0}: {1}"
,
new
Object
[]
{
uuid
,
service
});
try
{
service
.
upload
(
req
,
rsp
);
}
finally
{
LOGGER
.
log
(
Level
.
FINE
,
"Finished upload side for {0}: {1}"
,
new
Object
[]
{
uuid
,
service
});
}
}
}
catch
(
InterruptedException
e
)
{
throw
new
IOException
(
e
);
...
...
test/src/test/java/hudson/cli/CLIActionTest.java
浏览文件 @
284bbf71
...
...
@@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
import
java.util.logging.Level
;
import
jenkins.model.Jenkins
;
import
jenkins.security.ApiTokenProperty
;
import
jenkins.util.FullDuplexHttpService
;
import
jenkins.util.Timer
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.output.TeeOutputStream
;
...
...
@@ -257,7 +258,7 @@ public class CLIActionTest {
@Issue
(
"JENKINS-41745"
)
@Test
public
void
interleavedStdio
()
throws
Exception
{
logging
.
record
(
PlainCLIProtocol
.
class
,
Level
.
FINE
);
logging
.
record
(
PlainCLIProtocol
.
class
,
Level
.
FINE
)
.
record
(
FullDuplexHttpService
.
class
,
Level
.
FINE
)
;
File
jar
=
tmp
.
newFile
(
"jenkins-cli.jar"
);
FileUtils
.
copyURLToFile
(
j
.
jenkins
.
getJnlpJars
(
"jenkins-cli.jar"
).
getURL
(),
jar
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录