jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1807037 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java xdocs/changes.xml
Date Sat, 02 Sep 2017 11:04:06 GMT
Author: fschumacher
Date: Sat Sep  2 11:04:06 2017
New Revision: 1807037

URL: http://svn.apache.org/viewvc?rev=1807037&view=rev
Log:
Use system DNS resolver as last resort, when resolving entries in the static host table.

Bugzilla Id: 61375

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
    jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java?rev=1807037&r1=1807036&r2=1807037&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/DNSCacheManager.java
Sat Sep  2 11:04:06 2017
@@ -217,8 +217,14 @@ public class DNSCacheManager extends Con
                 List<InetAddress> addresses = new ArrayList<>();
                 for (String address : Arrays.asList(entry.getAddress().split("\\s*,\\s*")))
{
                     try {
-                        addresses.addAll(Arrays.asList(requestLookup(address)));
+                        final InetAddress[] requestLookup = requestLookup(address);
+                        if (requestLookup == null) {
+                            addAsLiteralAddress(addresses, address);
+                        } else {
+                            addresses.addAll(Arrays.asList(requestLookup));
+                        }
                     } catch (UnknownHostException e) {
+                        addAsLiteralAddress(addresses, address);
                         log.warn("Couldn't resolve static address {} for host {}", address,
host, e);
                     }
                 }
@@ -228,6 +234,15 @@ public class DNSCacheManager extends Con
         return new InetAddress[0];
     }
 
+    private void addAsLiteralAddress(List<InetAddress> addresses,
+            String address) {
+        try {
+            addresses.add(InetAddress.getByName(address));
+        } catch (UnknownHostException e) {
+            log.info("Couldn't convert {} as literal address to InetAddress", address, e);
+        }
+    }
+
     /**
      * Sends DNS request via system or custom DNS resolver
      * @param host Host

Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java?rev=1807037&r1=1807036&r2=1807037&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestDNSCacheManager.java
Sat Sep  2 11:04:06 2017
@@ -47,6 +47,16 @@ public class TestDNSCacheManager extends
     }
 
     @Test
+    public void testWithOneAsStaticHostAndInvalidCustomResolver() throws Exception {
+        DNSCacheManager manager = new DNSCacheManager();
+        manager.setCustomResolver(true);
+        manager.addServer(INVALID_DNS_SERVER);
+        manager.addHost("localhost", "127.0.0.1");
+        assertThat(manager.resolve("localhost"),
+                CoreMatchers.is(CoreMatchers.equalTo(new InetAddress[] { InetAddress.getByName("127.0.0.1")
})));
+    }
+
+    @Test
     public void testWithMultipleStaticHost() throws Exception {
         DNSCacheManager manager = new DNSCacheManager();
         manager.setCustomResolver(true);

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1807037&r1=1807036&r2=1807037&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Sat Sep  2 11:04:06 2017
@@ -185,6 +185,7 @@ Incorporated feed back about unclear doc
 
 <h3>Controllers</h3>
 <ul>
+    <li><bug>61375</bug>Use system DNS resolver as last resort, when resolving
entries in the static host table.</li>
 </ul>
 
 <h3>Listeners</h3>



Mime
View raw message