@@ -33,8 +33,6 @@ public final class DnsResolver {
3333 private static final String CNAME_RECORD_TYPE = "CNAME" ;
3434 private static final String TXT_RECORD_TYPE = "TXT" ;
3535
36- static final DirContext dirContext = getDirContext ();
37-
3836 private DnsResolver () {
3937 }
4038
@@ -66,7 +64,7 @@ public static String resolve(String originalHost) {
6664 try {
6765 String targetHost = null ;
6866 do {
69- Attributes attrs = dirContext .getAttributes (currentHost , new String []{A_RECORD_TYPE , CNAME_RECORD_TYPE });
67+ Attributes attrs = getDirContext () .getAttributes (currentHost , new String []{A_RECORD_TYPE , CNAME_RECORD_TYPE });
7068 Attribute attr = attrs .get (A_RECORD_TYPE );
7169 if (attr != null ) {
7270 targetHost = attr .get ().toString ();
@@ -97,7 +95,7 @@ public static List<String> resolveARecord(String rootDomainName) {
9795 return null ;
9896 }
9997 try {
100- Attributes attrs = dirContext .getAttributes (rootDomainName , new String []{A_RECORD_TYPE , CNAME_RECORD_TYPE });
98+ Attributes attrs = getDirContext () .getAttributes (rootDomainName , new String []{A_RECORD_TYPE , CNAME_RECORD_TYPE });
10199 Attribute aRecord = attrs .get (A_RECORD_TYPE );
102100 Attribute cRecord = attrs .get (CNAME_RECORD_TYPE );
103101 if (aRecord != null && cRecord == null ) {
@@ -129,7 +127,7 @@ private static boolean isLocalOrIp(String currentHost) {
129127 * Looks up the DNS name provided in the JNDI context.
130128 */
131129 public static Set <String > getCNamesFromTxtRecord (String discoveryDnsName ) throws NamingException {
132- Attributes attrs = dirContext .getAttributes (discoveryDnsName , new String []{TXT_RECORD_TYPE });
130+ Attributes attrs = getDirContext () .getAttributes (discoveryDnsName , new String []{TXT_RECORD_TYPE });
133131 Attribute attr = attrs .get (TXT_RECORD_TYPE );
134132 String txtRecord = null ;
135133 if (attr != null ) {
0 commit comments