Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
Dragonwell11
提交
dfae2fdf
D
Dragonwell11
项目概览
LinuxSuRen
/
Dragonwell11
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dfae2fdf
编写于
9月 21, 2017
作者:
X
xiaofeya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8085875: java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
Reviewed-by: msheppar, clanger
上级
6d5a3767
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
3 deletion
+27
-3
test/jdk/java/net/DatagramSocket/PortUnreachable.java
test/jdk/java/net/DatagramSocket/PortUnreachable.java
+27
-3
未找到文件。
test/jdk/java/net/DatagramSocket/PortUnreachable.java
浏览文件 @
dfae2fdf
/*
* Copyright (c) 2000, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
7
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -24,11 +24,11 @@
/**
* @test
* @bug 4361783
* @key intermittent
* @summary Test to see if ICMP Port Unreachable on non-connected
* DatagramSocket causes a SocketException "socket closed"
* exception on Windows 2000.
*/
import
java.net.BindException
;
import
java.net.InetAddress
;
import
java.net.DatagramSocket
;
import
java.net.DatagramPacket
;
...
...
@@ -50,7 +50,7 @@ public class PortUnreachable {
serverPort
);
clientSock
.
send
(
packet
);
DatagramSocket
sock
=
new
Datagram
Socket
(
serverPort
);
DatagramSocket
sock
=
recreateServer
Socket
(
serverPort
);
b
=
"Greetings from the server"
.
getBytes
();
packet
=
new
DatagramPacket
(
b
,
b
.
length
,
addr
,
clientPort
);
sock
.
send
(
packet
);
...
...
@@ -60,6 +60,29 @@ public class PortUnreachable {
}
}
DatagramSocket
recreateServerSocket
(
int
serverPort
)
throws
Exception
{
DatagramSocket
serverSocket
=
null
;
int
retryCount
=
0
;
System
.
out
.
println
(
"Attempting to recreate server socket with port: "
+
serverPort
);
while
(
serverSocket
==
null
)
{
try
{
serverSocket
=
new
DatagramSocket
(
serverPort
);
}
catch
(
BindException
bEx
)
{
if
(
retryCount
++
<
5
)
{
Thread
.
sleep
(
500
);
}
else
{
System
.
out
.
println
(
"Give up after 5 retries"
);
throw
bEx
;
}
}
}
System
.
out
.
println
(
"PortUnreachableTest.recreateServerSocket: returning socket == "
+
serverSocket
.
getLocalAddress
()
+
":"
+
serverSocket
.
getLocalPort
());
return
serverSocket
;
}
PortUnreachable
()
throws
Exception
{
clientSock
=
new
DatagramSocket
();
...
...
@@ -103,3 +126,4 @@ public class PortUnreachable {
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录