Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ae27291b
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看板
提交
ae27291b
编写于
9月 18, 2012
作者:
D
dxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
Reviewed-by: alanb
上级
37d3ba0c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
101 addition
and
50 deletion
+101
-50
test/ProblemList.txt
test/ProblemList.txt
+0
-3
test/java/nio/channels/AsyncCloseAndInterrupt.java
test/java/nio/channels/AsyncCloseAndInterrupt.java
+101
-47
未找到文件。
test/ProblemList.txt
浏览文件 @
ae27291b
...
@@ -249,9 +249,6 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
...
@@ -249,9 +249,6 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
# 7132677
# 7132677
java/nio/channels/Selector/OutOfBand.java macosx-all
java/nio/channels/Selector/OutOfBand.java macosx-all
# 7142919
java/nio/channels/AsyncCloseAndInterrupt.java solaris-all
############################################################################
############################################################################
# jdk_rmi
# jdk_rmi
...
...
test/java/nio/channels/AsyncCloseAndInterrupt.java
浏览文件 @
ae27291b
/*
/*
* Copyright (c) 2002, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
2
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -22,17 +22,24 @@
...
@@ -22,17 +22,24 @@
*/
*/
/* @test
/* @test
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919
* @run main/othervm AsyncCloseAndInterrupt
* @summary Comprehensive test of asynchronous closing and interruption
* @summary Comprehensive test of asynchronous closing and interruption
* @author Mark Reinhold
* @author Mark Reinhold
*/
*/
import
java.io.*
;
import
java.io.*
;
import
java.net.*
;
import
java.net.*
;
import
java.nio.*
;
import
java.nio.channels.*
;
import
java.nio.channels.*
;
import
java.util.*
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
public
class
AsyncCloseAndInterrupt
{
public
class
AsyncCloseAndInterrupt
{
...
@@ -79,45 +86,12 @@ public class AsyncCloseAndInterrupt {
...
@@ -79,45 +86,12 @@ public class AsyncCloseAndInterrupt {
// Server socket that refuses all connections
// Server socket that refuses all connections
static
ServerSocketChannel
refuser
;
static
ServerSocketChannel
refuser
;
static
List
refuserClients
=
new
ArrayList
();
private
static
void
initRefuser
()
throws
IOException
{
private
static
void
initRefuser
()
throws
IOException
{
refuser
=
ServerSocketChannel
.
open
();
refuser
=
ServerSocketChannel
.
open
();
refuser
.
socket
().
bind
(
wildcardAddress
);
refuser
.
socket
().
bind
(
wildcardAddress
);
pumpRefuser
(
"Initializing refuser..."
);
}
}
private
static
void
pumpRefuser
(
String
msg
)
throws
IOException
{
// Can't reliably saturate connection backlog on Windows Server editions
assert
!
TestUtil
.
onWindows
();
log
.
print
(
msg
);
int
n
=
refuserClients
.
size
();
// Saturate the refuser's connection backlog so that further connection
// attempts will block
//
outer:
for
(;;)
{
SocketChannel
sc
=
SocketChannel
.
open
();
sc
.
configureBlocking
(
false
);
if
(!
sc
.
connect
(
refuser
.
socket
().
getLocalSocketAddress
()))
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
Thread
.
yield
();
if
(
sc
.
finishConnect
())
break
;
if
(
i
>=
19
)
break
outer
;
}
}
// Retain so that finalizer doesn't close
refuserClients
.
add
(
sc
);
}
log
.
println
(
" "
+
(
refuserClients
.
size
()
-
n
)
+
" connections"
);
}
// Dead pipe source and sink
// Dead pipe source and sink
static
Pipe
.
SourceChannel
deadSource
;
static
Pipe
.
SourceChannel
deadSource
;
...
@@ -374,8 +348,8 @@ public class AsyncCloseAndInterrupt {
...
@@ -374,8 +348,8 @@ public class AsyncCloseAndInterrupt {
};
};
static
final
Op
CONNECT
=
new
Op
(
"connect"
)
{
static
final
Op
CONNECT
=
new
Op
(
"connect"
)
{
void
setup
()
throws
IOException
{
void
setup
()
{
pumpRefuser
(
"P
umping refuser ..."
);
waitPump
(
"connect wait for p
umping refuser ..."
);
}
}
void
doIO
(
InterruptibleChannel
ich
)
throws
IOException
{
void
doIO
(
InterruptibleChannel
ich
)
throws
IOException
{
SocketChannel
sc
=
(
SocketChannel
)
ich
;
SocketChannel
sc
=
(
SocketChannel
)
ich
;
...
@@ -386,8 +360,8 @@ public class AsyncCloseAndInterrupt {
...
@@ -386,8 +360,8 @@ public class AsyncCloseAndInterrupt {
};
};
static
final
Op
FINISH_CONNECT
=
new
Op
(
"finishConnect"
)
{
static
final
Op
FINISH_CONNECT
=
new
Op
(
"finishConnect"
)
{
void
setup
()
throws
IOException
{
void
setup
()
{
pumpRefuser
(
"P
umping refuser ..."
);
waitPump
(
"finishConnect wait for p
umping refuser ..."
);
}
}
void
doIO
(
InterruptibleChannel
ich
)
throws
IOException
{
void
doIO
(
InterruptibleChannel
ich
)
throws
IOException
{
SocketChannel
sc
=
(
SocketChannel
)
ich
;
SocketChannel
sc
=
(
SocketChannel
)
ich
;
...
@@ -462,6 +436,7 @@ public class AsyncCloseAndInterrupt {
...
@@ -462,6 +436,7 @@ public class AsyncCloseAndInterrupt {
this
.
test
=
test
;
this
.
test
=
test
;
}
}
@SuppressWarnings
(
"fallthrough"
)
private
void
caught
(
Channel
ch
,
IOException
x
)
{
private
void
caught
(
Channel
ch
,
IOException
x
)
{
String
xn
=
x
.
getClass
().
getName
();
String
xn
=
x
.
getClass
().
getName
();
switch
(
test
)
{
switch
(
test
)
{
...
@@ -519,9 +494,63 @@ public class AsyncCloseAndInterrupt {
...
@@ -519,9 +494,63 @@ public class AsyncCloseAndInterrupt {
}
}
private
static
volatile
boolean
pumpDone
=
false
;
private
static
volatile
boolean
pumpReady
=
false
;
private
static
void
waitPump
(
String
msg
){
pumpReady
=
false
;
log
.
println
(
msg
);
while
(!
pumpReady
){
sleep
(
200
);
}
}
// Create a pump thread dedicated to saturate refuser's connection backlog
private
static
Future
<
Integer
>
pumpRefuser
(
ExecutorService
pumperExecutor
)
{
Callable
<
Integer
>
pumpTask
=
new
Callable
<
Integer
>()
{
@Override
public
Integer
call
()
throws
IOException
{
// Can't reliably saturate connection backlog on Windows Server editions
assert
!
TestUtil
.
onWindows
();
log
.
println
(
"Start pumping refuser ..."
);
List
<
SocketChannel
>
refuserClients
=
new
ArrayList
<>();
// Saturate the refuser's connection backlog so that further connection
// attempts will be blocked
while
(!
pumpDone
)
{
SocketChannel
sc
=
SocketChannel
.
open
();
sc
.
configureBlocking
(
false
);
boolean
connected
=
sc
.
connect
(
refuser
.
socket
().
getLocalSocketAddress
());
// Assume that the connection backlog is saturated if a
// client cannot connect to the refuser within 50 miliseconds
long
start
=
System
.
currentTimeMillis
();
while
(!
connected
&&
(
System
.
currentTimeMillis
()
-
start
<
50
))
{
connected
=
sc
.
finishConnect
();
}
// Tests
if
(
connected
)
{
// Retain so that finalizer doesn't close
refuserClients
.
add
(
sc
);
pumpReady
=
false
;
}
else
{
sc
.
close
();
pumpReady
=
true
;
}
}
log
.
println
(
"Stop pumping refuser ..."
);
return
refuserClients
.
size
();
}
};
return
pumperExecutor
.
submit
(
pumpTask
);
}
// Test
static
void
test
(
ChannelFactory
cf
,
Op
op
,
int
test
)
static
void
test
(
ChannelFactory
cf
,
Op
op
,
int
test
)
throws
Exception
throws
Exception
{
{
...
@@ -667,15 +696,40 @@ public class AsyncCloseAndInterrupt {
...
@@ -667,15 +696,40 @@ public class AsyncCloseAndInterrupt {
log
.
println
(
"WARNING Cannot reliably test connect/finishConnect"
log
.
println
(
"WARNING Cannot reliably test connect/finishConnect"
+
" operations on Windows"
);
+
" operations on Windows"
);
}
else
{
}
else
{
test
(
socketChannelFactory
,
CONNECT
);
// Only the following tests need refuser's connection backlog
test
(
socketChannelFactory
,
FINISH_CONNECT
);
// to be saturated
ExecutorService
pumperExecutor
=
Executors
.
newSingleThreadExecutor
(
new
ThreadFactory
()
{
@Override
public
Thread
newThread
(
Runnable
r
)
{
Thread
t
=
new
Thread
(
r
);
t
.
setDaemon
(
true
);
t
.
setName
(
"Pumper"
);
return
t
;
}
});
pumpDone
=
false
;
try
{
Future
<
Integer
>
pumpFuture
=
pumpRefuser
(
pumperExecutor
);
waitPump
(
"\nWait for initial Pump"
);
test
(
socketChannelFactory
,
CONNECT
);
test
(
socketChannelFactory
,
FINISH_CONNECT
);
pumpDone
=
true
;
Integer
newConn
=
pumpFuture
.
get
(
30
,
TimeUnit
.
SECONDS
);
log
.
println
(
"Pump "
+
newConn
+
" connections."
);
}
finally
{
pumperExecutor
.
shutdown
();
}
}
}
test
(
serverSocketChannelFactory
,
ACCEPT
);
test
(
serverSocketChannelFactory
,
ACCEPT
);
test
(
datagramChannelFactory
);
test
(
datagramChannelFactory
);
test
(
pipeSourceChannelFactory
);
test
(
pipeSourceChannelFactory
);
test
(
pipeSinkChannelFactory
);
test
(
pipeSinkChannelFactory
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录