Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
41702346
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看板
提交
41702346
编写于
7月 19, 2010
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6969683: Generify ResolverConfiguration codes
Reviewed-by: alanb, chegar
上级
e80093ab
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
73 addition
and
75 deletion
+73
-75
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
+4
-5
src/share/classes/sun/net/dns/ResolverConfiguration.java
src/share/classes/sun/net/dns/ResolverConfiguration.java
+3
-4
src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java
...e/classes/sun/net/spi/nameservice/dns/DNSNameService.java
+38
-40
src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java
...olaris/classes/sun/net/dns/ResolverConfigurationImpl.java
+23
-20
src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java
...indows/classes/sun/net/dns/ResolverConfigurationImpl.java
+5
-6
未找到文件。
src/share/classes/com/sun/jndi/dns/DnsContextFactory.java
浏览文件 @
41702346
/*
/*
* Copyright (c) 2000, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
10
, 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
...
@@ -132,7 +132,7 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -132,7 +132,7 @@ public class DnsContextFactory implements InitialContextFactory {
throw
new
ConfigurationException
(
"DNS pseudo-URL required"
);
throw
new
ConfigurationException
(
"DNS pseudo-URL required"
);
}
}
List
servers
=
new
ArrayList
();
List
<
String
>
servers
=
new
ArrayList
<>
();
for
(
int
i
=
0
;
i
<
urls
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
urls
.
length
;
i
++)
{
String
server
=
urls
[
i
].
getHost
();
String
server
=
urls
[
i
].
getHost
();
...
@@ -142,7 +142,7 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -142,7 +142,7 @@ public class DnsContextFactory implements InitialContextFactory {
// No server or port given, so look to underlying platform.
// No server or port given, so look to underlying platform.
// ResolverConfiguration does some limited caching, so the
// ResolverConfiguration does some limited caching, so the
// following is reasonably efficient even if called rapid-fire.
// following is reasonably efficient even if called rapid-fire.
List
platformServers
=
List
<
String
>
platformServers
=
ResolverConfiguration
.
open
().
nameservers
();
ResolverConfiguration
.
open
().
nameservers
();
if
(!
platformServers
.
isEmpty
())
{
if
(!
platformServers
.
isEmpty
())
{
servers
.
addAll
(
platformServers
);
servers
.
addAll
(
platformServers
);
...
@@ -157,8 +157,7 @@ public class DnsContextFactory implements InitialContextFactory {
...
@@ -157,8 +157,7 @@ public class DnsContextFactory implements InitialContextFactory {
?
server
?
server
:
server
+
":"
+
port
);
:
server
+
":"
+
port
);
}
}
return
(
String
[])
servers
.
toArray
(
return
servers
.
toArray
(
new
String
[
servers
.
size
()]);
new
String
[
servers
.
size
()]);
}
}
/*
/*
...
...
src/share/classes/sun/net/dns/ResolverConfiguration.java
浏览文件 @
41702346
/*
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2010,
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
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
package
sun.net.dns
;
package
sun.net.dns
;
import
java.util.List
;
import
java.util.List
;
import
java.io.IOException
;
/**
/**
* The configuration of the client resolver.
* The configuration of the client resolver.
...
@@ -68,7 +67,7 @@ public abstract class ResolverConfiguration {
...
@@ -68,7 +67,7 @@ public abstract class ResolverConfiguration {
*
*
* @return list of domain names
* @return list of domain names
*/
*/
public
abstract
List
searchlist
();
public
abstract
List
<
String
>
searchlist
();
/**
/**
* Returns a list of name servers used for host name lookup.
* Returns a list of name servers used for host name lookup.
...
@@ -78,7 +77,7 @@ public abstract class ResolverConfiguration {
...
@@ -78,7 +77,7 @@ public abstract class ResolverConfiguration {
*
*
* @return list of the name servers
* @return list of the name servers
*/
*/
public
abstract
List
nameservers
();
public
abstract
List
<
String
>
nameservers
();
/**
/**
...
...
src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java
浏览文件 @
41702346
/*
/*
* Copyright (c) 2000, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
10
, 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
...
@@ -45,20 +45,21 @@ import sun.security.action.*;
...
@@ -45,20 +45,21 @@ import sun.security.action.*;
public
final
class
DNSNameService
implements
NameService
{
public
final
class
DNSNameService
implements
NameService
{
// List of domains specified by property
// List of domains specified by property
private
LinkedList
domainList
=
null
;
private
LinkedList
<
String
>
domainList
=
null
;
// JNDI-DNS URL for name servers specified via property
// JNDI-DNS URL for name servers specified via property
private
String
nameProviderUrl
=
null
;
private
String
nameProviderUrl
=
null
;
// Per-thread soft cache of the last temporary context
// Per-thread soft cache of the last temporary context
private
static
ThreadLocal
contextRef
=
new
ThreadLocal
();
private
static
ThreadLocal
<
SoftReference
<
ThreadContext
>>
contextRef
=
new
ThreadLocal
<>();
// Simple class to encapsulate the temporary context
// Simple class to encapsulate the temporary context
private
static
class
ThreadContext
{
private
static
class
ThreadContext
{
private
DirContext
dirCtxt
;
private
DirContext
dirCtxt
;
private
List
nsList
;
private
List
<
String
>
nsList
;
public
ThreadContext
(
DirContext
dirCtxt
,
List
nsList
)
{
public
ThreadContext
(
DirContext
dirCtxt
,
List
<
String
>
nsList
)
{
this
.
dirCtxt
=
dirCtxt
;
this
.
dirCtxt
=
dirCtxt
;
this
.
nsList
=
nsList
;
this
.
nsList
=
nsList
;
}
}
...
@@ -67,16 +68,16 @@ public final class DNSNameService implements NameService {
...
@@ -67,16 +68,16 @@ public final class DNSNameService implements NameService {
return
dirCtxt
;
return
dirCtxt
;
}
}
public
List
nameservers
()
{
public
List
<
String
>
nameservers
()
{
return
nsList
;
return
nsList
;
}
}
}
}
// Returns a per-thread DirContext
// Returns a per-thread DirContext
private
DirContext
getTemporaryContext
()
throws
NamingException
{
private
DirContext
getTemporaryContext
()
throws
NamingException
{
SoftReference
ref
=
(
SoftReference
)
contextRef
.
get
();
SoftReference
<
ThreadContext
>
ref
=
contextRef
.
get
();
ThreadContext
thrCtxt
=
null
;
ThreadContext
thrCtxt
=
null
;
List
nsList
=
null
;
List
<
String
>
nsList
=
null
;
// if no property specified we need to obtain the list of servers
// if no property specified we need to obtain the list of servers
//
//
...
@@ -87,7 +88,7 @@ public final class DNSNameService implements NameService {
...
@@ -87,7 +88,7 @@ public final class DNSNameService implements NameService {
// specified then we need to check if the DNS configuration
// specified then we need to check if the DNS configuration
// has changed.
// has changed.
//
//
if
((
ref
!=
null
)
&&
((
thrCtxt
=
(
ThreadContext
)
ref
.
get
())
!=
null
))
{
if
((
ref
!=
null
)
&&
((
thrCtxt
=
ref
.
get
())
!=
null
))
{
if
(
nameProviderUrl
==
null
)
{
if
(
nameProviderUrl
==
null
)
{
if
(!
thrCtxt
.
nameservers
().
equals
(
nsList
))
{
if
(!
thrCtxt
.
nameservers
().
equals
(
nsList
))
{
// DNS configuration has changed
// DNS configuration has changed
...
@@ -98,7 +99,7 @@ public final class DNSNameService implements NameService {
...
@@ -98,7 +99,7 @@ public final class DNSNameService implements NameService {
// new thread context needs to be created
// new thread context needs to be created
if
(
thrCtxt
==
null
)
{
if
(
thrCtxt
==
null
)
{
final
Hashtable
<
String
,
Object
>
env
=
new
Hashtable
<
String
,
Object
>();
final
Hashtable
<
String
,
Object
>
env
=
new
Hashtable
<>();
env
.
put
(
"java.naming.factory.initial"
,
env
.
put
(
"java.naming.factory.initial"
,
"com.sun.jndi.dns.DnsContextFactory"
);
"com.sun.jndi.dns.DnsContextFactory"
);
...
@@ -119,10 +120,9 @@ public final class DNSNameService implements NameService {
...
@@ -119,10 +120,9 @@ public final class DNSNameService implements NameService {
//
//
DirContext
dirCtxt
;
DirContext
dirCtxt
;
try
{
try
{
dirCtxt
=
(
DirContext
)
dirCtxt
=
java
.
security
.
AccessController
.
doPrivileged
(
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedExceptionAction
<
DirContext
>()
{
new
java
.
security
.
PrivilegedExceptionAction
()
{
public
DirContext
run
()
throws
NamingException
{
public
Object
run
()
throws
NamingException
{
// Create the DNS context using NamingManager rather than using
// Create the DNS context using NamingManager rather than using
// the initial context constructor. This avoids having the initial
// the initial context constructor. This avoids having the initial
// context constructor call itself.
// context constructor call itself.
...
@@ -130,7 +130,7 @@ public final class DNSNameService implements NameService {
...
@@ -130,7 +130,7 @@ public final class DNSNameService implements NameService {
if
(!(
ctx
instanceof
DirContext
))
{
if
(!(
ctx
instanceof
DirContext
))
{
return
null
;
// cannot create a DNS context
return
null
;
// cannot create a DNS context
}
}
return
ctx
;
return
(
DirContext
)
ctx
;
}
}
});
});
}
catch
(
java
.
security
.
PrivilegedActionException
pae
)
{
}
catch
(
java
.
security
.
PrivilegedActionException
pae
)
{
...
@@ -161,18 +161,18 @@ public final class DNSNameService implements NameService {
...
@@ -161,18 +161,18 @@ public final class DNSNameService implements NameService {
*
*
* @throws UnknownHostException if lookup fails or other error.
* @throws UnknownHostException if lookup fails or other error.
*/
*/
private
ArrayList
resolve
(
final
DirContext
ctx
,
final
String
name
,
final
String
[]
ids
,
private
ArrayList
<
String
>
resolve
(
final
DirContext
ctx
,
final
String
name
,
int
depth
)
throws
UnknownHostException
final
String
[]
ids
,
int
depth
)
throws
UnknownHostException
{
{
ArrayList
results
=
new
ArrayList
();
ArrayList
<
String
>
results
=
new
ArrayList
<>
();
Attributes
attrs
;
Attributes
attrs
;
// do the query
// do the query
try
{
try
{
attrs
=
(
Attributes
)
attrs
=
java
.
security
.
AccessController
.
doPrivileged
(
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedExceptionAction
<
Attributes
>()
{
new
java
.
security
.
PrivilegedExceptionAction
()
{
public
Attributes
run
()
throws
NamingException
{
public
Object
run
()
throws
NamingException
{
return
ctx
.
getAttributes
(
name
,
ids
);
return
ctx
.
getAttributes
(
name
,
ids
);
}
}
});
});
...
@@ -181,7 +181,7 @@ public final class DNSNameService implements NameService {
...
@@ -181,7 +181,7 @@ public final class DNSNameService implements NameService {
}
}
// non-requested type returned so enumeration is empty
// non-requested type returned so enumeration is empty
NamingEnumeration
ne
=
attrs
.
getAll
();
NamingEnumeration
<?
extends
Attribute
>
ne
=
attrs
.
getAll
();
if
(!
ne
.
hasMoreElements
())
{
if
(!
ne
.
hasMoreElements
())
{
throw
new
UnknownHostException
(
"DNS record not found"
);
throw
new
UnknownHostException
(
"DNS record not found"
);
}
}
...
@@ -190,7 +190,7 @@ public final class DNSNameService implements NameService {
...
@@ -190,7 +190,7 @@ public final class DNSNameService implements NameService {
UnknownHostException
uhe
=
null
;
UnknownHostException
uhe
=
null
;
try
{
try
{
while
(
ne
.
hasMoreElements
())
{
while
(
ne
.
hasMoreElements
())
{
Attribute
attr
=
(
Attribute
)
ne
.
next
();
Attribute
attr
=
ne
.
next
();
String
attrID
=
attr
.
getID
();
String
attrID
=
attr
.
getID
();
for
(
NamingEnumeration
e
=
attr
.
getAll
();
e
.
hasMoreElements
();)
{
for
(
NamingEnumeration
e
=
attr
.
getAll
();
e
.
hasMoreElements
();)
{
...
@@ -251,13 +251,12 @@ public final class DNSNameService implements NameService {
...
@@ -251,13 +251,12 @@ public final class DNSNameService implements NameService {
// no property specified so check host DNS resolver configured
// no property specified so check host DNS resolver configured
// with at least one nameserver in dotted notation.
// with at least one nameserver in dotted notation.
//
//
List
nsList
=
ResolverConfiguration
.
open
().
nameservers
();
List
<
String
>
nsList
=
ResolverConfiguration
.
open
().
nameservers
();
if
(
nsList
.
size
()
==
0
)
if
(
nsList
.
isEmpty
())
{
throw
new
RuntimeException
(
"no nameservers provided"
);
throw
new
RuntimeException
(
"no nameservers provided"
);
}
boolean
found
=
false
;
boolean
found
=
false
;
Iterator
i
=
nsList
.
iterator
();
for
(
String
addr:
nsList
)
{
while
(
i
.
hasNext
())
{
String
addr
=
(
String
)
i
.
next
();
if
(
IPAddressUtil
.
isIPv4LiteralAddress
(
addr
)
||
if
(
IPAddressUtil
.
isIPv4LiteralAddress
(
addr
)
||
IPAddressUtil
.
isIPv6LiteralAddress
(
addr
))
{
IPAddressUtil
.
isIPv6LiteralAddress
(
addr
))
{
found
=
true
;
found
=
true
;
...
@@ -308,8 +307,8 @@ public final class DNSNameService implements NameService {
...
@@ -308,8 +307,8 @@ public final class DNSNameService implements NameService {
// suffix if the list has one entry.
// suffix if the list has one entry.
if
(
results
==
null
)
{
if
(
results
==
null
)
{
List
searchList
=
null
;
List
<
String
>
searchList
=
null
;
Iterator
i
;
Iterator
<
String
>
i
;
boolean
usingSearchList
=
false
;
boolean
usingSearchList
=
false
;
if
(
domainList
!=
null
)
{
if
(
domainList
!=
null
)
{
...
@@ -324,7 +323,7 @@ public final class DNSNameService implements NameService {
...
@@ -324,7 +323,7 @@ public final class DNSNameService implements NameService {
// iterator through each domain suffix
// iterator through each domain suffix
while
(
i
.
hasNext
())
{
while
(
i
.
hasNext
())
{
String
parentDomain
=
(
String
)
i
.
next
();
String
parentDomain
=
i
.
next
();
int
start
=
0
;
int
start
=
0
;
while
((
start
=
parentDomain
.
indexOf
(
"."
))
!=
-
1
while
((
start
=
parentDomain
.
indexOf
(
"."
))
!=
-
1
&&
start
<
parentDomain
.
length
()
-
1
)
{
&&
start
<
parentDomain
.
length
()
-
1
)
{
...
@@ -407,7 +406,7 @@ public final class DNSNameService implements NameService {
...
@@ -407,7 +406,7 @@ public final class DNSNameService implements NameService {
String
literalip
=
""
;
String
literalip
=
""
;
String
[]
ids
=
{
"PTR"
};
String
[]
ids
=
{
"PTR"
};
DirContext
ctx
;
DirContext
ctx
;
ArrayList
results
=
null
;
ArrayList
<
String
>
results
=
null
;
try
{
try
{
ctx
=
getTemporaryContext
();
ctx
=
getTemporaryContext
();
}
catch
(
NamingException
nx
)
{
}
catch
(
NamingException
nx
)
{
...
@@ -420,7 +419,7 @@ public final class DNSNameService implements NameService {
...
@@ -420,7 +419,7 @@ public final class DNSNameService implements NameService {
literalip
+=
"IN-ADDR.ARPA."
;
literalip
+=
"IN-ADDR.ARPA."
;
results
=
resolve
(
ctx
,
literalip
,
ids
,
0
);
results
=
resolve
(
ctx
,
literalip
,
ids
,
0
);
host
=
(
String
)
results
.
get
(
0
);
host
=
results
.
get
(
0
);
}
else
if
(
addr
.
length
==
16
)
{
// IPv6 Address
}
else
if
(
addr
.
length
==
16
)
{
// IPv6 Address
/**
/**
* Because RFC 3152 changed the root domain name for reverse
* Because RFC 3152 changed the root domain name for reverse
...
@@ -437,7 +436,7 @@ public final class DNSNameService implements NameService {
...
@@ -437,7 +436,7 @@ public final class DNSNameService implements NameService {
try
{
try
{
results
=
resolve
(
ctx
,
ip6lit
,
ids
,
0
);
results
=
resolve
(
ctx
,
ip6lit
,
ids
,
0
);
host
=
(
String
)
results
.
get
(
0
);
host
=
results
.
get
(
0
);
}
catch
(
UnknownHostException
e
)
{
}
catch
(
UnknownHostException
e
)
{
host
=
null
;
host
=
null
;
}
}
...
@@ -445,7 +444,7 @@ public final class DNSNameService implements NameService {
...
@@ -445,7 +444,7 @@ public final class DNSNameService implements NameService {
// IP6.ARPA lookup failed, let's try the older IP6.INT
// IP6.ARPA lookup failed, let's try the older IP6.INT
ip6lit
=
literalip
+
"IP6.INT."
;
ip6lit
=
literalip
+
"IP6.INT."
;
results
=
resolve
(
ctx
,
ip6lit
,
ids
,
0
);
results
=
resolve
(
ctx
,
ip6lit
,
ids
,
0
);
host
=
(
String
)
results
.
get
(
0
);
host
=
results
.
get
(
0
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -478,11 +477,10 @@ public final class DNSNameService implements NameService {
...
@@ -478,11 +477,10 @@ public final class DNSNameService implements NameService {
* @return String containing the JNDI-DNS provider URL
* @return String containing the JNDI-DNS provider URL
* corresponding to the supplied List of nameservers.
* corresponding to the supplied List of nameservers.
*/
*/
private
static
String
createProviderURL
(
List
nsList
)
{
private
static
String
createProviderURL
(
List
<
String
>
nsList
)
{
Iterator
i
=
nsList
.
iterator
();
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
while
(
i
.
hasNext
()
)
{
for
(
String
s:
nsList
)
{
appendIfLiteralAddress
(
(
String
)
i
.
next
()
,
sb
);
appendIfLiteralAddress
(
s
,
sb
);
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
...
...
src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java
浏览文件 @
41702346
/*
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2010,
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
...
@@ -56,8 +56,11 @@ public class ResolverConfigurationImpl
...
@@ -56,8 +56,11 @@ public class ResolverConfigurationImpl
// Parse /etc/resolv.conf to get the values for a particular
// Parse /etc/resolv.conf to get the values for a particular
// keyword.
// keyword.
//
//
private
LinkedList
resolvconf
(
String
keyword
,
int
maxperkeyword
,
int
maxkeywords
)
{
private
LinkedList
<
String
>
resolvconf
(
String
keyword
,
LinkedList
ll
=
new
LinkedList
();
int
maxperkeyword
,
int
maxkeywords
)
{
LinkedList
<
String
>
ll
=
new
LinkedList
<>();
try
{
try
{
BufferedReader
in
=
BufferedReader
in
=
...
@@ -99,8 +102,8 @@ public class ResolverConfigurationImpl
...
@@ -99,8 +102,8 @@ public class ResolverConfigurationImpl
return
ll
;
return
ll
;
}
}
private
LinkedList
searchlist
;
private
LinkedList
<
String
>
searchlist
;
private
LinkedList
nameservers
;
private
LinkedList
<
String
>
nameservers
;
// Load DNS configuration from OS
// Load DNS configuration from OS
...
@@ -118,9 +121,9 @@ public class ResolverConfigurationImpl
...
@@ -118,9 +121,9 @@ public class ResolverConfigurationImpl
// get the name servers from /etc/resolv.conf
// get the name servers from /etc/resolv.conf
nameservers
=
nameservers
=
(
LinkedList
)
java
.
security
.
AccessController
.
doPrivileged
(
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
new
java
.
security
.
PrivilegedAction
<
LinkedList
<
String
>>
()
{
public
Object
run
()
{
public
LinkedList
<
String
>
run
()
{
// typically MAXNS is 3 but we've picked 5 here
// typically MAXNS is 3 but we've picked 5 here
// to allow for additional servers if required.
// to allow for additional servers if required.
return
resolvconf
(
"nameserver"
,
1
,
5
);
return
resolvconf
(
"nameserver"
,
1
,
5
);
...
@@ -137,15 +140,15 @@ public class ResolverConfigurationImpl
...
@@ -137,15 +140,15 @@ public class ResolverConfigurationImpl
// obtain search list or local domain
// obtain search list or local domain
private
LinkedList
getSearchList
()
{
private
LinkedList
<
String
>
getSearchList
()
{
LinkedList
sl
;
LinkedList
<
String
>
sl
;
// first try the search keyword in /etc/resolv.conf
// first try the search keyword in /etc/resolv.conf
sl
=
(
LinkedList
)
java
.
security
.
AccessController
.
doPrivileged
(
sl
=
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
new
java
.
security
.
PrivilegedAction
<
LinkedList
<
String
>>
()
{
public
Object
run
()
{
public
LinkedList
<
String
>
run
()
{
LinkedList
ll
;
LinkedList
ll
;
// first try search keyword (max 6 domains)
// first try search keyword (max 6 domains)
...
@@ -177,10 +180,10 @@ public class ResolverConfigurationImpl
...
@@ -177,10 +180,10 @@ public class ResolverConfigurationImpl
// try domain keyword in /etc/resolv.conf
// try domain keyword in /etc/resolv.conf
sl
=
(
LinkedList
)
java
.
security
.
AccessController
.
doPrivileged
(
sl
=
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
new
java
.
security
.
PrivilegedAction
<
LinkedList
<
String
>>
()
{
public
Object
run
()
{
public
LinkedList
<
String
>
run
()
{
LinkedList
ll
;
LinkedList
<
String
>
ll
;
ll
=
resolvconf
(
"domain"
,
1
,
1
);
ll
=
resolvconf
(
"domain"
,
1
,
1
);
if
(
ll
.
size
()
>
0
)
{
if
(
ll
.
size
()
>
0
)
{
...
@@ -197,7 +200,7 @@ public class ResolverConfigurationImpl
...
@@ -197,7 +200,7 @@ public class ResolverConfigurationImpl
// no local domain so try fallback (RPC) domain or
// no local domain so try fallback (RPC) domain or
// hostname
// hostname
sl
=
new
LinkedList
();
sl
=
new
LinkedList
<>
();
String
domain
=
fallbackDomain0
();
String
domain
=
fallbackDomain0
();
if
(
domain
!=
null
&&
domain
.
length
()
>
0
)
{
if
(
domain
!=
null
&&
domain
.
length
()
>
0
)
{
sl
.
add
(
domain
);
sl
.
add
(
domain
);
...
@@ -213,7 +216,7 @@ public class ResolverConfigurationImpl
...
@@ -213,7 +216,7 @@ public class ResolverConfigurationImpl
opts
=
new
OptionsImpl
();
opts
=
new
OptionsImpl
();
}
}
public
List
searchlist
()
{
public
List
<
String
>
searchlist
()
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
loadConfig
();
loadConfig
();
...
@@ -222,7 +225,7 @@ public class ResolverConfigurationImpl
...
@@ -222,7 +225,7 @@ public class ResolverConfigurationImpl
}
}
}
}
public
List
nameservers
()
{
public
List
<
String
>
nameservers
()
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
loadConfig
();
loadConfig
();
...
...
src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java
浏览文件 @
41702346
/*
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002,
2010,
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
...
@@ -28,7 +28,6 @@ package sun.net.dns;
...
@@ -28,7 +28,6 @@ package sun.net.dns;
import
java.util.List
;
import
java.util.List
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.StringTokenizer
;
import
java.util.StringTokenizer
;
import
java.io.IOException
;
/*
/*
* An implementation of sun.net.ResolverConfiguration for Windows.
* An implementation of sun.net.ResolverConfiguration for Windows.
...
@@ -63,8 +62,8 @@ public class ResolverConfigurationImpl
...
@@ -63,8 +62,8 @@ public class ResolverConfigurationImpl
// Parse string that consists of token delimited by space or commas
// Parse string that consists of token delimited by space or commas
// and return LinkedHashMap
// and return LinkedHashMap
private
LinkedList
stringToList
(
String
str
)
{
private
LinkedList
<
String
>
stringToList
(
String
str
)
{
LinkedList
ll
=
new
LinkedList
();
LinkedList
<
String
>
ll
=
new
LinkedList
<>
();
// comma and space are valid delimites
// comma and space are valid delimites
StringTokenizer
st
=
new
StringTokenizer
(
str
,
", "
);
StringTokenizer
st
=
new
StringTokenizer
(
str
,
", "
);
...
@@ -112,7 +111,7 @@ public class ResolverConfigurationImpl
...
@@ -112,7 +111,7 @@ public class ResolverConfigurationImpl
opts
=
new
OptionsImpl
();
opts
=
new
OptionsImpl
();
}
}
public
List
searchlist
()
{
public
List
<
String
>
searchlist
()
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
loadConfig
();
loadConfig
();
...
@@ -121,7 +120,7 @@ public class ResolverConfigurationImpl
...
@@ -121,7 +120,7 @@ public class ResolverConfigurationImpl
}
}
}
}
public
List
nameservers
()
{
public
List
<
String
>
nameservers
()
{
synchronized
(
lock
)
{
synchronized
(
lock
)
{
loadConfig
();
loadConfig
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录