Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6f6e1cd6
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看板
提交
6f6e1cd6
编写于
4月 20, 2009
作者:
M
martin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6716076: test UTIL_REGRESSION/test/java/util/logging/LoggingDeadlock2.java failed with exit code 1
Reviewed-by: swamyv, mchung
上级
abda44bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
181 addition
and
30 deletion
+181
-30
test/java/util/logging/LoggingDeadlock2.java
test/java/util/logging/LoggingDeadlock2.java
+181
-30
未找到文件。
test/java/util/logging/LoggingDeadlock2.java
浏览文件 @
6f6e1cd6
...
...
@@ -23,10 +23,9 @@
/*
* @test
* @bug 6467152
* @ignore until 6716076 is fixed
* @bug 6467152 6716076 6829503
* @summary deadlock occurs in LogManager initialization and JVM termination
* @author Serguei Spitsyn / Hit
tachi
* @author Serguei Spitsyn / Hit
achi / Martin Buchholz
*
* @build LoggingDeadlock2
* @run main/timeout=15 LoggingDeadlock2
...
...
@@ -47,43 +46,195 @@
* This is a regression test for this bug.
*/
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.concurrent.CyclicBarrier
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.logging.LogManager
;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
public
class
LoggingDeadlock2
implements
Runnable
{
static
final
java
.
io
.
PrintStream
out
=
System
.
out
;
static
Object
lock
=
new
Object
();
static
int
c
=
0
;
public
static
void
main
(
String
arg
[])
{
out
.
println
(
"\nThis test checks that there is no deadlock."
);
out
.
println
(
"If not crashed or timed-out then it is passed."
);
public
class
LoggingDeadlock2
{
public
static
void
realMain
(
String
arg
[])
throws
Throwable
{
try
{
new
Thread
(
new
LoggingDeadlock2
()).
start
();
synchronized
(
lock
)
{
c
++;
if
(
c
==
2
)
lock
.
notify
();
else
lock
.
wait
();
}
System
.
out
.
println
(
javaChildArgs
);
ProcessBuilder
pb
=
new
ProcessBuilder
(
javaChildArgs
);
ProcessResults
r
=
run
(
pb
.
start
());
equal
(
r
.
exitValue
(),
99
);
equal
(
r
.
out
(),
""
);
equal
(
r
.
err
(),
""
);
}
catch
(
Throwable
t
)
{
unexpected
(
t
);
}
}
public
static
class
JavaChild
{
public
static
void
main
(
String
args
[])
throws
Throwable
{
final
CyclicBarrier
startingGate
=
new
CyclicBarrier
(
2
);
final
Throwable
[]
thrown
=
new
Throwable
[
1
];
// Some random variation, to help tickle races.
final
Random
rnd
=
new
Random
();
final
boolean
dojoin
=
rnd
.
nextBoolean
();
final
int
JITTER
=
1024
;
final
int
iters1
=
rnd
.
nextInt
(
JITTER
);
final
int
iters2
=
JITTER
-
iters1
;
final
AtomicInteger
counter
=
new
AtomicInteger
(
0
);
Thread
exiter
=
new
Thread
()
{
public
void
run
()
{
try
{
startingGate
.
await
();
for
(
int
i
=
0
;
i
<
iters1
;
i
++)
counter
.
getAndIncrement
();
System
.
exit
(
99
);
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
System
.
exit
(
86
);
}
}};
exiter
.
start
();
startingGate
.
await
();
for
(
int
i
=
0
;
i
<
iters2
;
i
++)
counter
.
getAndIncrement
();
// This may or may not result in a first call to
// Runtime.addShutdownHook after shutdown has already
// commenced.
LogManager
log
=
LogManager
.
getLogManager
();
out
.
println
(
"Test passed"
);
if
(
dojoin
)
{
exiter
.
join
();
if
(
thrown
[
0
]
!=
null
)
throw
new
Error
(
thrown
[
0
]);
check
(
counter
.
get
()
==
JITTER
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
out
.
println
(
"Test FAILED"
);
// Not expected
}
//----------------------------------------------------------------
// The rest of this test is copied from ProcessBuilder/Basic.java
//----------------------------------------------------------------
private
static
final
String
javaExe
=
System
.
getProperty
(
"java.home"
)
+
File
.
separator
+
"bin"
+
File
.
separator
+
"java"
;
private
static
final
String
classpath
=
System
.
getProperty
(
"java.class.path"
);
private
static
final
List
<
String
>
javaChildArgs
=
Arrays
.
asList
(
new
String
[]
{
javaExe
,
"-classpath"
,
classpath
,
"LoggingDeadlock2$JavaChild"
});
private
static
class
ProcessResults
{
private
final
String
out
;
private
final
String
err
;
private
final
int
exitValue
;
private
final
Throwable
throwable
;
public
ProcessResults
(
String
out
,
String
err
,
int
exitValue
,
Throwable
throwable
)
{
this
.
out
=
out
;
this
.
err
=
err
;
this
.
exitValue
=
exitValue
;
this
.
throwable
=
throwable
;
}
public
String
out
()
{
return
out
;
}
public
String
err
()
{
return
err
;
}
public
int
exitValue
()
{
return
exitValue
;
}
public
Throwable
throwable
()
{
return
throwable
;
}
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"<STDOUT>\n"
+
out
()
+
"</STDOUT>\n"
)
.
append
(
"<STDERR>\n"
+
err
()
+
"</STDERR>\n"
)
.
append
(
"exitValue = "
+
exitValue
+
"\n"
);
if
(
throwable
!=
null
)
sb
.
append
(
throwable
.
getStackTrace
());
return
sb
.
toString
();
}
}
public
void
run
()
{
try
{
synchronized
(
lock
)
{
c
++;
if
(
c
==
2
)
lock
.
notify
();
else
lock
.
wait
();
private
static
class
StreamAccumulator
extends
Thread
{
private
final
InputStream
is
;
private
final
StringBuilder
sb
=
new
StringBuilder
();
private
Throwable
throwable
=
null
;
public
String
result
()
throws
Throwable
{
if
(
throwable
!=
null
)
throw
throwable
;
return
sb
.
toString
();
}
StreamAccumulator
(
InputStream
is
)
{
this
.
is
=
is
;
}
public
void
run
()
{
try
{
Reader
r
=
new
InputStreamReader
(
is
);
char
[]
buf
=
new
char
[
4096
];
int
n
;
while
((
n
=
r
.
read
(
buf
))
>
0
)
{
sb
.
append
(
buf
,
0
,
n
);
}
}
catch
(
Throwable
t
)
{
throwable
=
t
;
}
finally
{
try
{
is
.
close
();
}
catch
(
Throwable
t
)
{
throwable
=
t
;
}
}
System
.
exit
(
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
out
.
println
(
"Test FAILED"
);
// Not expected
}
private
static
ProcessResults
run
(
Process
p
)
{
Throwable
throwable
=
null
;
int
exitValue
=
-
1
;
String
out
=
""
;
String
err
=
""
;
StreamAccumulator
outAccumulator
=
new
StreamAccumulator
(
p
.
getInputStream
());
StreamAccumulator
errAccumulator
=
new
StreamAccumulator
(
p
.
getErrorStream
());
try
{
outAccumulator
.
start
();
errAccumulator
.
start
();
exitValue
=
p
.
waitFor
();
outAccumulator
.
join
();
errAccumulator
.
join
();
out
=
outAccumulator
.
result
();
err
=
errAccumulator
.
result
();
}
catch
(
Throwable
t
)
{
throwable
=
t
;
}
return
new
ProcessResults
(
out
,
err
,
exitValue
,
throwable
);
}
//--------------------- Infrastructure ---------------------------
static
volatile
int
passed
=
0
,
failed
=
0
;
static
void
pass
()
{
passed
++;}
static
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
static
void
fail
(
String
msg
)
{
System
.
out
.
println
(
msg
);
fail
();}
static
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();}
static
void
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();}
static
void
check
(
boolean
cond
,
String
m
)
{
if
(
cond
)
pass
();
else
fail
(
m
);}
static
void
equal
(
Object
x
,
Object
y
)
{
if
(
x
==
null
?
y
==
null
:
x
.
equals
(
y
))
pass
();
else
fail
(
x
+
" not equal to "
+
y
);}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
try
{
realMain
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
System
.
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录