|
1 | 1 | /*
|
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
26 | 26 | package com.sun.jndi.dns;
|
27 | 27 |
|
28 | 28 | import java.io.IOException;
|
| 29 | +import java.io.UncheckedIOException; |
29 | 30 | import java.net.DatagramSocket;
|
30 | 31 | import java.net.DatagramPacket;
|
31 | 32 | import java.net.InetAddress;
|
32 | 33 | import java.net.InetSocketAddress;
|
| 34 | +import java.net.PortUnreachableException; |
33 | 35 | import java.net.Socket;
|
34 | 36 | import java.net.SocketTimeoutException;
|
35 | 37 | import java.security.SecureRandom;
|
@@ -275,20 +277,23 @@ ResourceRecords query(DnsName fqdn, int qclass, int qtype,
|
275 | 277 | } // servers
|
276 | 278 | }
|
277 | 279 | 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; |
279 | 290 | } catch (IOException e) {
|
280 | 291 | if (debug) {
|
281 | 292 | dprint("Caught IOException:" + e);
|
282 | 293 | }
|
283 | 294 | if (caughtException == null) {
|
284 | 295 | caughtException = e;
|
285 | 296 | }
|
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 |
| - } |
292 | 297 | } catch (NameNotFoundException e) {
|
293 | 298 | // This is authoritative, so return immediately
|
294 | 299 | throw e;
|
|
0 commit comments