Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
0ac57f25
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看板
提交
0ac57f25
编写于
12月 05, 2012
作者:
J
jgish
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8004317: TestLibrary.getUnusedRandomPort() fails intermittently, but exception not reported
Reviewed-by: alanb, dmocek, smarks
上级
80d662b2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
38 addition
and
37 deletion
+38
-37
test/java/rmi/testlibrary/TestLibrary.java
test/java/rmi/testlibrary/TestLibrary.java
+38
-37
未找到文件。
test/java/rmi/testlibrary/TestLibrary.java
浏览文件 @
0ac57f25
...
@@ -54,6 +54,7 @@ import java.rmi.server.RemoteRef;
...
@@ -54,6 +54,7 @@ import java.rmi.server.RemoteRef;
import
java.rmi.server.UnicastRemoteObject
;
import
java.rmi.server.UnicastRemoteObject
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Properties
;
import
java.util.Properties
;
import
sun.rmi.registry.RegistryImpl
;
import
sun.rmi.registry.RegistryImpl
;
import
sun.rmi.server.UnicastServerRef
;
import
sun.rmi.server.UnicastServerRef
;
import
sun.rmi.transport.Endpoint
;
import
sun.rmi.transport.Endpoint
;
...
@@ -92,6 +93,7 @@ public class TestLibrary {
...
@@ -92,6 +93,7 @@ public class TestLibrary {
public
final
static
int
INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT
=
64003
;
public
final
static
int
INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT
=
64003
;
public
final
static
int
INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT
=
64004
;
public
final
static
int
INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT
=
64004
;
public
final
static
int
READTEST_REGISTRY_PORT
=
64005
;
public
final
static
int
READTEST_REGISTRY_PORT
=
64005
;
private
final
static
int
MAX_SERVER_SOCKET_TRIES
=
10
;
static
void
mesg
(
Object
mesg
)
{
static
void
mesg
(
Object
mesg
)
{
System
.
err
.
println
(
"TEST_LIBRARY: "
+
mesg
.
toString
());
System
.
err
.
println
(
"TEST_LIBRARY: "
+
mesg
.
toString
());
...
@@ -125,36 +127,15 @@ public class TestLibrary {
...
@@ -125,36 +127,15 @@ public class TestLibrary {
bomb
(
null
,
e
);
bomb
(
null
,
e
);
}
}
/**
* Property accessors
*/
private
static
boolean
getBoolean
(
String
name
)
{
return
(
new
Boolean
(
getProperty
(
name
,
"false"
)).
booleanValue
());
}
private
static
Integer
getInteger
(
String
name
)
{
int
val
=
0
;
Integer
value
=
null
;
String
propVal
=
getProperty
(
name
,
null
);
if
(
propVal
==
null
)
{
return
null
;
}
try
{
value
=
new
Integer
(
Integer
.
parseInt
(
propVal
));
}
catch
(
NumberFormatException
nfe
)
{
}
return
value
;
}
public
static
String
getProperty
(
String
property
,
String
defaultVal
)
{
public
static
String
getProperty
(
String
property
,
String
defaultVal
)
{
final
String
prop
=
property
;
final
String
prop
=
property
;
final
String
def
=
defaultVal
;
final
String
def
=
defaultVal
;
return
((
String
)
java
.
security
.
AccessController
.
doPrivileged
return
java
.
security
.
AccessController
.
doPrivileged
(
(
new
java
.
security
.
PrivilegedAction
()
{
new
java
.
security
.
PrivilegedAction
<
String
>
()
{
public
Object
run
()
{
public
String
run
()
{
return
System
.
getProperty
(
prop
,
def
);
return
System
.
getProperty
(
prop
,
def
);
}
}
})
)
;
});
}
}
/**
/**
...
@@ -169,9 +150,9 @@ public class TestLibrary {
...
@@ -169,9 +150,9 @@ public class TestLibrary {
public
static
void
setProperty
(
String
property
,
String
value
)
{
public
static
void
setProperty
(
String
property
,
String
value
)
{
final
String
prop
=
property
;
final
String
prop
=
property
;
final
String
val
=
value
;
final
String
val
=
value
;
java
.
security
.
AccessController
.
doPrivileged
java
.
security
.
AccessController
.
doPrivileged
(
(
new
java
.
security
.
PrivilegedAction
()
{
new
java
.
security
.
PrivilegedAction
<
Void
>
()
{
public
Object
run
()
{
public
Void
run
()
{
System
.
setProperty
(
prop
,
val
);
System
.
setProperty
(
prop
,
val
);
return
null
;
return
null
;
}
}
...
@@ -188,7 +169,7 @@ public class TestLibrary {
...
@@ -188,7 +169,7 @@ public class TestLibrary {
out
.
println
(
"-------------------Test environment----------"
+
out
.
println
(
"-------------------Test environment----------"
+
"---------"
);
"---------"
);
for
(
Enumeration
keys
=
System
.
getProperties
().
keys
();
for
(
Enumeration
<?>
keys
=
System
.
getProperties
().
keys
();
keys
.
hasMoreElements
();)
{
keys
.
hasMoreElements
();)
{
String
property
=
(
String
)
keys
.
nextElement
();
String
property
=
(
String
)
keys
.
nextElement
();
...
@@ -252,7 +233,7 @@ public class TestLibrary {
...
@@ -252,7 +233,7 @@ public class TestLibrary {
/*
/*
* Obtain the URL for the codebase.
* Obtain the URL for the codebase.
*/
*/
URL
codebaseURL
=
dstDir
.
toURL
();
URL
codebaseURL
=
dstDir
.
toUR
I
().
toUR
L
();
/*
/*
* Specify where we will copy the class definition from, if
* Specify where we will copy the class definition from, if
...
@@ -407,27 +388,47 @@ public class TestLibrary {
...
@@ -407,27 +388,47 @@ public class TestLibrary {
*/
*/
public
static
int
getUnusedRandomPort
()
{
public
static
int
getUnusedRandomPort
()
{
int
numTries
=
0
;
int
numTries
=
0
;
int
unusedRandomPort
=
FIXED_PORT_MIN
;
IOException
ex
=
null
;
Exception
ex
=
null
;
while
(
numTries
++
<
10
)
{
while
(
numTries
++
<
MAX_SERVER_SOCKET_TRIES
)
{
int
unusedRandomPort
=
-
1
;
ex
=
null
;
//reset
ex
=
null
;
//reset
try
(
ServerSocket
ss
=
new
ServerSocket
(
0
))
{
try
(
ServerSocket
ss
=
new
ServerSocket
(
0
))
{
unusedRandomPort
=
ss
.
getLocalPort
();
unusedRandomPort
=
ss
.
getLocalPort
();
}
catch
(
Exception
e
)
{
}
catch
(
IO
Exception
e
)
{
ex
=
e
;
ex
=
e
;
}
// temporarily print stack trace here until we find out why
// tests are failing.
if
(!
isReservedPort
(
unusedRandomPort
))
{
System
.
err
.
println
(
"TestLibrary.getUnusedRandomPort() caught "
+
"exception on iteration "
+
numTries
+
(
numTries
==
MAX_SERVER_SOCKET_TRIES
?
" (the final try)."
:
"."
));
ex
.
printStackTrace
();
}
if
(
unusedRandomPort
>=
0
)
{
if
(
isReservedPort
(
unusedRandomPort
))
{
System
.
out
.
println
(
"INFO: On try # "
+
numTries
+
(
numTries
==
MAX_SERVER_SOCKET_TRIES
?
", the final try, "
:
","
)
+
" ServerSocket(0) returned the reserved port "
+
unusedRandomPort
+
" in TestLibrary.getUnusedRandomPort() "
);
}
else
{
return
unusedRandomPort
;
return
unusedRandomPort
;
}
}
}
}
}
// If we're here, then either an exception was thrown or the port is
// If we're here, then either an exception was thrown or the port is
// a reserved port.
// a reserved port.
if
(
ex
==
null
)
{
throw
new
RuntimeException
(
"Error getting unused random port. The"
+
" last port returned by ServerSocket(0) was a reserved port"
);
}
else
{
throw
new
RuntimeException
(
"Error getting unused random port."
,
ex
);
throw
new
RuntimeException
(
"Error getting unused random port."
,
ex
);
}
}
}
/**
/**
* Determines if a port is one of the reserved port numbers.
* Determines if a port is one of the reserved port numbers.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录