Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
090aaac3
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
090aaac3
编写于
11月 13, 2013
作者:
J
jbachorik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004126: TEST_BUG: com/sun/jdi/BadHandshakeTest.java fails intermittently
Reviewed-by: dholmes, ykantser
上级
257253a0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
75 deletion
+34
-75
test/com/sun/jdi/BadHandshakeTest.java
test/com/sun/jdi/BadHandshakeTest.java
+34
-75
未找到文件。
test/com/sun/jdi/BadHandshakeTest.java
浏览文件 @
090aaac3
...
@@ -24,16 +24,12 @@
...
@@ -24,16 +24,12 @@
/* @test
/* @test
* @bug 6306165 6432567
* @bug 6306165 6432567
* @summary Check that a bad handshake doesn't cause a debuggee to abort
* @summary Check that a bad handshake doesn't cause a debuggee to abort
* @library /lib/testlibrary
*
*
* @build VMConnection BadHandshakeTest Exit0
* @build VMConnection BadHandshakeTest Exit0
* @run main BadHandshakeTest
* @run main BadHandshakeTest
*
*
*/
*/
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.File
;
import
java.io.BufferedInputStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
com.sun.jdi.Bootstrap
;
import
com.sun.jdi.Bootstrap
;
...
@@ -44,50 +40,13 @@ import com.sun.jdi.connect.AttachingConnector;
...
@@ -44,50 +40,13 @@ import com.sun.jdi.connect.AttachingConnector;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
public
class
BadHandshakeTest
{
import
jdk.testlibrary.Utils
;
import
jdk.testlibrary.ProcessTools
;
static
volatile
boolean
ready
=
false
;
/*
* Helper class to redirect process output/error
*/
static
class
IOHandler
implements
Runnable
{
InputStream
in
;
IOHandler
(
InputStream
in
)
{
this
.
in
=
in
;
}
static
void
handle
(
InputStream
in
)
{
IOHandler
handler
=
new
IOHandler
(
in
);
Thread
thr
=
new
Thread
(
handler
);
thr
.
setDaemon
(
true
);
thr
.
start
();
}
public
void
run
()
{
try
{
byte
b
[]
=
new
byte
[
100
];
for
(;;)
{
int
n
=
in
.
read
(
b
,
0
,
100
);
// The first thing that will get read is
// Listening for transport dt_socket at address: xxxxx
// which shows the debuggee is ready to accept connections.
ready
=
true
;
if
(
n
<
0
)
{
break
;
}
String
s
=
new
String
(
b
,
0
,
n
,
"UTF-8"
);
System
.
out
.
print
(
s
);
}
}
catch
(
IOException
ioe
)
{
ioe
.
printStackTrace
();
}
}
}
public
class
BadHandshakeTest
{
/*
/*
* Find a connector by name
* Find a connector by name
*/
*/
...
@@ -106,22 +65,31 @@ public class BadHandshakeTest {
...
@@ -106,22 +65,31 @@ public class BadHandshakeTest {
/*
/*
* Launch a server debuggee with the given address
* Launch a server debuggee with the given address
*/
*/
private
static
Process
launch
(
String
address
,
String
class_name
)
throws
IOException
{
private
static
Process
launch
(
String
address
,
String
class_name
)
throws
Exception
{
String
exe
=
System
.
getProperty
(
"java.home"
)
String
[]
args
=
VMConnection
.
insertDebuggeeVMOptions
(
new
String
[]
{
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java"
;
"-agentlib:jdwp=transport=dt_socket"
+
String
cmd
=
exe
+
" "
+
VMConnection
.
getDebuggeeVMOptions
()
+
",server=y"
+
",suspend=y"
+
",address="
+
address
,
" -agentlib:jdwp=transport=dt_socket"
+
class_name
",server=y"
+
",suspend=y"
+
",address="
+
address
+
});
" "
+
class_name
;
ProcessBuilder
pb
=
ProcessTools
.
createJavaProcessBuilder
(
args
);
System
.
out
.
println
(
"Starting: "
+
cmd
);
final
AtomicBoolean
success
=
new
AtomicBoolean
();
Process
p
=
Runtime
.
getRuntime
().
exec
(
cmd
);
Process
p
=
ProcessTools
.
startProcess
(
class_name
,
IOHandler
.
handle
(
p
.
getInputStream
());
pb
,
IOHandler
.
handle
(
p
.
getErrorStream
());
(
line
)
->
{
// The first thing that will get read is
return
p
;
// Listening for transport dt_socket at address: xxxxx
// which shows the debuggee is ready to accept connections.
success
.
set
(
line
.
contains
(
"Listening for transport dt_socket at address:"
));
return
true
;
},
1500
,
TimeUnit
.
MILLISECONDS
);
return
success
.
get
()
?
p
:
null
;
}
}
/*
/*
...
@@ -131,23 +99,14 @@ public class BadHandshakeTest {
...
@@ -131,23 +99,14 @@ public class BadHandshakeTest {
* - verify we saw no error
* - verify we saw no error
*/
*/
public
static
void
main
(
String
args
[])
throws
Exception
{
public
static
void
main
(
String
args
[])
throws
Exception
{
// find a free port
int
port
=
Utils
.
getFreePort
();
ServerSocket
ss
=
new
ServerSocket
(
0
);
int
port
=
ss
.
getLocalPort
();
ss
.
close
();
String
address
=
String
.
valueOf
(
port
);
String
address
=
String
.
valueOf
(
port
);
// launch the server debuggee
// launch the server debuggee
Process
process
=
launch
(
address
,
"Exit0"
);
Process
process
=
launch
(
address
,
"Exit0"
);
if
(
process
==
null
)
{
// wait for the debugge to be ready
throw
new
RuntimeException
(
"Unable to start debugee"
);
while
(!
ready
)
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
Exception
ee
)
{
throw
ee
;
}
}
}
// Connect to the debuggee and handshake with garbage
// Connect to the debuggee and handshake with garbage
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录