Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7e0ee085
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,发现更多精彩内容 >>
提交
7e0ee085
编写于
4月 22, 2015
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8075378: JNDI DnsClient Exception Handling
Reviewed-by: vinnie
上级
372f90d0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
107 addition
and
102 deletion
+107
-102
src/share/classes/com/sun/jndi/dns/DnsClient.java
src/share/classes/com/sun/jndi/dns/DnsClient.java
+107
-102
未找到文件。
src/share/classes/com/sun/jndi/dns/DnsClient.java
浏览文件 @
7e0ee085
/*
* Copyright (c) 2000, 201
4
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
5
, 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
...
...
@@ -184,119 +184,124 @@ public class DnsClient {
Exception
caughtException
=
null
;
boolean
[]
doNotRetry
=
new
boolean
[
servers
.
length
];
//
// The UDP retry strategy is to try the 1st server, and then
// each server in order. If no answer, double the timeout
// and try each server again.
//
for
(
int
retry
=
0
;
retry
<
retries
;
retry
++)
{
// Try each name server.
for
(
int
i
=
0
;
i
<
servers
.
length
;
i
++)
{
if
(
doNotRetry
[
i
])
{
continue
;
}
// send the request packet and wait for a response.
try
{
if
(
debug
)
{
dprint
(
"SEND ID ("
+
(
retry
+
1
)
+
"): "
+
xid
);
try
{
//
// The UDP retry strategy is to try the 1st server, and then
// each server in order. If no answer, double the timeout
// and try each server again.
//
for
(
int
retry
=
0
;
retry
<
retries
;
retry
++)
{
// Try each name server.
for
(
int
i
=
0
;
i
<
servers
.
length
;
i
++)
{
if
(
doNotRetry
[
i
])
{
continue
;
}
byte
[]
msg
=
null
;
msg
=
doUdpQuery
(
pkt
,
servers
[
i
],
serverPorts
[
i
],
retry
,
xid
);
//
// If the matching response is not got within the
// given timeout, check if the response was enqueued
// by some other thread, if not proceed with the next
// server or retry.
//
if
(
msg
==
null
)
{
if
(
resps
.
size
()
>
0
)
{
msg
=
lookupResponse
(
xid
);
}
if
(
msg
==
null
)
{
// try next server or retry
continue
;
// send the request packet and wait for a response.
try
{
if
(
debug
)
{
dprint
(
"SEND ID ("
+
(
retry
+
1
)
+
"): "
+
xid
);
}
}
Header
hdr
=
new
Header
(
msg
,
msg
.
length
);
if
(
auth
&&
!
hdr
.
authoritative
)
{
caughtException
=
new
NameNotFoundException
(
"DNS response not authoritative"
);
doNotRetry
[
i
]
=
true
;
continue
;
}
if
(
hdr
.
truncated
)
{
// message is truncated -- try TCP
// Try each server, starting with the one that just
// provided the truncated message.
for
(
int
j
=
0
;
j
<
servers
.
length
;
j
++)
{
int
ij
=
(
i
+
j
)
%
servers
.
length
;
if
(
doNotRetry
[
ij
])
{
byte
[]
msg
=
null
;
msg
=
doUdpQuery
(
pkt
,
servers
[
i
],
serverPorts
[
i
],
retry
,
xid
);
//
// If the matching response is not got within the
// given timeout, check if the response was enqueued
// by some other thread, if not proceed with the next
// server or retry.
//
if
(
msg
==
null
)
{
if
(
resps
.
size
()
>
0
)
{
msg
=
lookupResponse
(
xid
);
}
if
(
msg
==
null
)
{
// try next server or retry
continue
;
}
try
{
Tcp
tcp
=
new
Tcp
(
servers
[
ij
],
serverPorts
[
ij
]);
byte
[]
msg2
;
try
{
msg2
=
doTcpQuery
(
tcp
,
pkt
);
}
finally
{
tcp
.
close
();
}
Header
hdr2
=
new
Header
(
msg2
,
msg2
.
length
);
if
(
hdr2
.
query
)
{
throw
new
CommunicationException
(
"DNS error: expecting response"
);
}
Header
hdr
=
new
Header
(
msg
,
msg
.
length
);
if
(
auth
&&
!
hdr
.
authoritative
)
{
caughtException
=
new
NameNotFoundException
(
"DNS response not authoritative"
);
doNotRetry
[
i
]
=
true
;
continue
;
}
if
(
hdr
.
truncated
)
{
// message is truncated -- try TCP
// Try each server, starting with the one that just
// provided the truncated message.
for
(
int
j
=
0
;
j
<
servers
.
length
;
j
++)
{
int
ij
=
(
i
+
j
)
%
servers
.
length
;
if
(
doNotRetry
[
ij
])
{
continue
;
}
checkResponseCode
(
hdr2
);
if
(!
auth
||
hdr2
.
authoritative
)
{
// Got a valid response
hdr
=
hdr2
;
msg
=
msg2
;
break
;
}
else
{
doNotRetry
[
ij
]
=
true
;
try
{
Tcp
tcp
=
new
Tcp
(
servers
[
ij
],
serverPorts
[
ij
]);
byte
[]
msg2
;
try
{
msg2
=
doTcpQuery
(
tcp
,
pkt
);
}
finally
{
tcp
.
close
();
}
Header
hdr2
=
new
Header
(
msg2
,
msg2
.
length
);
if
(
hdr2
.
query
)
{
throw
new
CommunicationException
(
"DNS error: expecting response"
);
}
checkResponseCode
(
hdr2
);
if
(!
auth
||
hdr2
.
authoritative
)
{
// Got a valid response
hdr
=
hdr2
;
msg
=
msg2
;
break
;
}
else
{
doNotRetry
[
ij
]
=
true
;
}
}
catch
(
Exception
e
)
{
// Try next server, or use UDP response
}
}
catch
(
Exception
e
)
{
// Try next server, or use UDP response
}
}
// servers
}
return
new
ResourceRecords
(
msg
,
msg
.
length
,
hdr
,
false
);
}
// servers
}
return
new
ResourceRecords
(
msg
,
msg
.
length
,
hdr
,
false
);
}
catch
(
IOException
e
)
{
if
(
debug
)
{
dprint
(
"Caught IOException:"
+
e
);
}
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
// Use reflection to allow pre-1.4 compilation.
// This won't be needed much longer.
if
(
e
.
getClass
().
getName
().
equals
(
"java.net.PortUnreachableException"
))
{
}
catch
(
IOException
e
)
{
if
(
debug
)
{
dprint
(
"Caught IOException:"
+
e
);
}
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
// Use reflection to allow pre-1.4 compilation.
// This won't be needed much longer.
if
(
e
.
getClass
().
getName
().
equals
(
"java.net.PortUnreachableException"
))
{
doNotRetry
[
i
]
=
true
;
}
}
catch
(
NameNotFoundException
e
)
{
// This is authoritative, so return immediately
throw
e
;
}
catch
(
CommunicationException
e
)
{
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
}
catch
(
NamingException
e
)
{
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
doNotRetry
[
i
]
=
true
;
}
}
catch
(
NameNotFoundException
e
)
{
throw
e
;
}
catch
(
CommunicationException
e
)
{
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
}
catch
(
NamingException
e
)
{
if
(
caughtException
==
null
)
{
caughtException
=
e
;
}
doNotRetry
[
i
]
=
true
;
}
}
// servers
}
// retries
}
// servers
}
// retries
}
finally
{
reqs
.
remove
(
xid
);
// cleanup
}
reqs
.
remove
(
xid
);
if
(
caughtException
instanceof
NamingException
)
{
throw
(
NamingException
)
caughtException
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录