Skip to content

Commit

Permalink
Merge pull request #1157 from krutsko/Issue_DNS_Server_Change
Browse files Browse the repository at this point in the history
Eureka Client doesn't respect DNS server change at runtime
elandau authored Dec 18, 2018
2 parents aaa00c1 + d6ba8c1 commit 1b60b49
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -33,8 +33,6 @@ public final class DnsResolver {
private static final String CNAME_RECORD_TYPE = "CNAME";
private static final String TXT_RECORD_TYPE = "TXT";

static final DirContext dirContext = getDirContext();

private DnsResolver() {
}

@@ -66,7 +64,7 @@ public static String resolve(String originalHost) {
try {
String targetHost = null;
do {
Attributes attrs = dirContext.getAttributes(currentHost, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE});
Attributes attrs = getDirContext().getAttributes(currentHost, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE});
Attribute attr = attrs.get(A_RECORD_TYPE);
if (attr != null) {
targetHost = attr.get().toString();
@@ -97,7 +95,7 @@ public static List<String> resolveARecord(String rootDomainName) {
return null;
}
try {
Attributes attrs = dirContext.getAttributes(rootDomainName, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE});
Attributes attrs = getDirContext().getAttributes(rootDomainName, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE});
Attribute aRecord = attrs.get(A_RECORD_TYPE);
Attribute cRecord = attrs.get(CNAME_RECORD_TYPE);
if (aRecord != null && cRecord == null) {
@@ -129,7 +127,7 @@ private static boolean isLocalOrIp(String currentHost) {
* Looks up the DNS name provided in the JNDI context.
*/
public static Set<String> getCNamesFromTxtRecord(String discoveryDnsName) throws NamingException {
Attributes attrs = dirContext.getAttributes(discoveryDnsName, new String[]{TXT_RECORD_TYPE});
Attributes attrs = getDirContext().getAttributes(discoveryDnsName, new String[]{TXT_RECORD_TYPE});
Attribute attr = attrs.get(TXT_RECORD_TYPE);
String txtRecord = null;
if (attr != null) {

1 comment on commit 1b60b49

@468165108
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use the dns not any Problem now

Please sign in to comment.