Bug 57447 - DNS Cache Manager always reads in resolv.config when using custom DNS resolver
Summary: DNS Cache Manager always reads in resolv.config when using custom DNS resolver
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 2.12
Hardware: Macintosh All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2015-01-15 22:00 UTC by Yifan Cai
Modified: 2017-01-19 16:58 UTC (History)
2 users (show)

Use only the configured DNS servers (4.21 KB, patch)
2015-01-16 21:19 UTC, Felix Schumacher
Details | Diff
Update patch v2 (4.30 KB, patch)
2015-01-24 16:32 UTC, Milamber
Details | Diff
test plan (49.74 KB, application/xml)
2017-01-19 07:49 UTC, Sean Chang
jmeter.log (4.40 KB, text/plain)
2017-01-19 07:51 UTC, Sean Chang

Note You need to log in before you can comment on or make changes to this bug.
Description Yifan Cai 2015-01-15 22:00:32 UTC
The "use custom DNS resolver" option means ONLY use the DNS severs add to the list in the DNS Manager component. 
In the Unix environment, the behavior is not as described (not tried in other OSs, but from the view of the code, I think, the other OSs have the same issue). It will read in the DNS servers specified in the /etc/resolv.config file first, then add the DNS servers from the DNS Manager list. 

The reason, I believe, is because that ExtendedResolver, which is used by DNS Manager, reads in the system DNS settings first, when instantiating. 

  public ExtendedResolver()
    throws UnknownHostException
    String[] servers = ResolverConfig.getCurrentConfig().servers();
    if (servers != null) {
      for (int i = 0; i < servers.length; i++)
        Resolver r = new SimpleResolver(servers[i]);
    } else {
      this.resolvers.add(new SimpleResolver());

Please correct me, if I have a misunderstanding on how "custom DNS resolvers" should work.
Comment 1 Sebb 2015-01-15 23:19:19 UTC
This does not appear to have anything to do with JMeter.

It does not have an ExtendedResolver class.
Comment 2 Yifan Cai 2015-01-15 23:26:43 UTC
The resolver that DNSCacheManager uses is ExtendedResolver. 
In its clone() method, clone.resolver = new ExtendedResolver();
I do not find any instantiation anywhere else. So I guess this is where the resolver got assigned.
The ExtendedResolver is from dnsjava lib. It is mentioned that "Custom DNS resolver(from dnsjava library) will be used."

Please consider it again.

(In reply to Sebb from comment #1)
> This does not appear to have anything to do with JMeter.
> It does not have an ExtendedResolver class.
Comment 3 Sebb 2015-01-16 00:39:16 UTC
Ah, I see now.
Comment 4 Felix Schumacher 2015-01-16 21:19:20 UTC
Created attachment 32372 [details]
Use only the configured DNS servers

By using the constructor ExtendedResolver(String[]) we should be ignoring the contents of /etc/resolv.conf or similar things.

Two thing the attached patch solves: 
 * NPE when no host ist found (Lookup#run returns null, when no host is found)
 * custom dns will not be used, if only one dns server was given ( expression >1 means at least two)
Comment 5 Milamber 2015-01-24 16:31:23 UTC
Patch looks good, except the AL header on TestDNSCacheManager file.

I have uploaded the same patch with some formatting and the AL.

@felix, you can committing on the SVN (don't forget to add the bug record in changes.xml)
Comment 6 Milamber 2015-01-24 16:32:06 UTC
Created attachment 32395 [details]
Update patch v2
Comment 7 Felix Schumacher 2015-01-24 19:54:47 UTC
Date: Sat Jan 24 19:51:20 2015
New Revision: 1654575

URL: http://svn.apache.org/r1654575
Bug 57447 - Use only the user listed DNS Servers, when "use custom DNS resolver"
option is enabled.
Bugzilla Id: 57447

Comment 8 Sean Chang 2017-01-19 01:42:27 UTC
Is this fix merged to 3.0 or 3.1? I found I could not use custom DNS on 3.0 and 3.1.
Comment 9 Philippe Mouawad 2017-01-19 06:36:40 UTC
It is merged since 3.0
Can you attach your test plan , put jmeter in debug. and attacj jmeter.log ?
Are you using http client implementation ? without any 3rd part plugin ?
Comment 10 Sean Chang 2017-01-19 07:49:46 UTC
Created attachment 34646 [details]
test plan

I'm not sure if I'm using any third party plugin because I got this test plan from other guy.
In DNS Cache Manager, is not the right DNS server. I tried to use a wrong one, but found Jmeter will still use system DNS - the right one.
Comment 11 Sean Chang 2017-01-19 07:51:33 UTC
Created attachment 34647 [details]

I only open log_level.jmeter.protocol.http.proxy.HttpRequestHdr=DEBUG and log_level.jmeter.report=DEBUG in user.properties, not sure if the log fit your debug requirement.
Comment 12 Sean Chang 2017-01-19 07:53:33 UTC
I'm using httpclient4 implementation, this test plan do work for custom DNS on JMeter 2.13
Comment 13 Philippe Mouawad 2017-01-19 16:28:37 UTC
Thanks for provided information.
I see you're using 3rd party plugins (Ultimate Thread Group).
Can you tell what jars you have in jmeter/lib folder and jmeter/lib/ext ?

Also , could you provide a simple test plan with only regular Thread Group and the minimal elements to reproduce your issue ?
Thank you
Comment 14 Philippe Mouawad 2017-01-19 16:58:03 UTC
It's ok, I reproduced.
I'll create a dedicated bug as it is a regression introduced in 3.0

Thanks for report