View | Details | Raw Unified | Return to bug 61375
Collapse All | Expand All

(-)src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java (-1 / +16 lines)
Lines 217-224 Link Here
217
                List<InetAddress> addresses = new ArrayList<>();
217
                List<InetAddress> addresses = new ArrayList<>();
218
                for (String address : Arrays.asList(entry.getAddress().split("\\s*,\\s*"))) {
218
                for (String address : Arrays.asList(entry.getAddress().split("\\s*,\\s*"))) {
219
                    try {
219
                    try {
220
                        addresses.addAll(Arrays.asList(requestLookup(address)));
220
                        final InetAddress[] requestLookup = requestLookup(address);
221
                        if (requestLookup == null) {
222
                            addAsLiteralAddress(addresses, address);
223
                        } else {
224
                            addresses.addAll(Arrays.asList(requestLookup));
225
                        }
221
                    } catch (UnknownHostException e) {
226
                    } catch (UnknownHostException e) {
227
                        addAsLiteralAddress(addresses, address);
222
                        log.warn("Couldn't resolve static address {} for host {}", address, host, e);
228
                        log.warn("Couldn't resolve static address {} for host {}", address, host, e);
223
                    }
229
                    }
224
                }
230
                }
Lines 228-233 Link Here
228
        return new InetAddress[0];
234
        return new InetAddress[0];
229
    }
235
    }
230
236
237
    private void addAsLiteralAddress(List<InetAddress> addresses,
238
            String address) {
239
        try {
240
            addresses.add(InetAddress.getByName(address));
241
        } catch (UnknownHostException e) {
242
            log.info("Couldn't convert {} as literal address to InetAddress", address, e);
243
        }
244
    }
245
231
    /**
246
    /**
232
     * Sends DNS request via system or custom DNS resolver
247
     * Sends DNS request via system or custom DNS resolver
233
     * @param host Host
248
     * @param host Host
(-)test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java (+10 lines)
Lines 47-52 Link Here
47
    }
47
    }
48
48
49
    @Test
49
    @Test
50
    public void testWithOneAsStaticHostAndInvalidCustomResolver() throws Exception {
51
        DNSCacheManager manager = new DNSCacheManager();
52
        manager.setCustomResolver(true);
53
        manager.addServer(INVALID_DNS_SERVER);
54
        manager.addHost("localhost", "127.0.0.1");
55
        assertThat(manager.resolve("localhost"),
56
                CoreMatchers.is(CoreMatchers.equalTo(new InetAddress[] { InetAddress.getByName("127.0.0.1") })));
57
    }
58
59
    @Test
50
    public void testWithMultipleStaticHost() throws Exception {
60
    public void testWithMultipleStaticHost() throws Exception {
51
        DNSCacheManager manager = new DNSCacheManager();
61
        DNSCacheManager manager = new DNSCacheManager();
52
        manager.setCustomResolver(true);
62
        manager.setCustomResolver(true);

Return to bug 61375