Skip to content

Commit fc57ee6

Browse files
macarteAlekseiEfimov
authored andcommitted
8272996: JNDI DNS provider fails to resolve SRV entries when IPV6 stack is enabled
Backport-of: 4c169495a2c4bfdcbc82e94e9ca1ee0cc050daf9
1 parent df5a29c commit fc57ee6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,10 +26,12 @@
2626
package com.sun.jndi.dns;
2727

2828
import java.io.IOException;
29+
import java.io.UncheckedIOException;
2930
import java.net.DatagramSocket;
3031
import java.net.DatagramPacket;
3132
import java.net.InetAddress;
3233
import java.net.InetSocketAddress;
34+
import java.net.PortUnreachableException;
3335
import java.net.Socket;
3436
import java.net.SocketTimeoutException;
3537
import java.security.SecureRandom;
@@ -275,20 +277,23 @@ ResourceRecords query(DnsName fqdn, int qclass, int qtype,
275277
} // servers
276278
}
277279
return new ResourceRecords(msg, msg.length, hdr, false);
278-
280+
} catch (UncheckedIOException | PortUnreachableException ex) {
281+
// DatagramSocket.connect in doUdpQuery can throw UncheckedIOException
282+
// DatagramSocket.send in doUdpQuery can throw PortUnreachableException
283+
if (debug) {
284+
dprint("Caught Exception:" + ex);
285+
}
286+
if (caughtException == null) {
287+
caughtException = ex;
288+
}
289+
doNotRetry[i] = true;
279290
} catch (IOException e) {
280291
if (debug) {
281292
dprint("Caught IOException:" + e);
282293
}
283294
if (caughtException == null) {
284295
caughtException = e;
285296
}
286-
// Use reflection to allow pre-1.4 compilation.
287-
// This won't be needed much longer.
288-
if (e.getClass().getName().equals(
289-
"java.net.PortUnreachableException")) {
290-
doNotRetry[i] = true;
291-
}
292297
} catch (NameNotFoundException e) {
293298
// This is authoritative, so return immediately
294299
throw e;

0 commit comments

Comments
 (0)