-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
8
-
generic
-
generic
FULL PRODUCT VERSION :
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hostname 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When I disable the JVM's DNS cache (line 8 of MakeTwoDnsRequests.java), and then make two DNS requests, then using Wireshark I can see two DNS requests are made.
However, upon enabling JMX, when I re-do the same test, I can only see one DNS request.
It's as if the disabling of the DNS cache silently failed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(You might need to run tshark and kill as root)
```
$ javac MakeTwoDnsRequests.java
$ tshark -i any -f "src port 53" -Y "dns.qry.type eq 1" -n -T fields -e dns.qry.name -e dns.a > without-jmx.txt 2>/dev/null &
[1] 17460
$ java MakeTwoDnsRequests
$ kill 17460
$ cat without-jmx.txt
www.example.com 93.184.216.34
www.example.com 93.184.216.34
$
$ tshark -i any -f "src port 53" -Y "dns.qry.type eq 1" -n -T fields -e dns.qry.name -e dns.a > with-jmx.txt 2>/dev/null &
[1] 17495
$ java -Dcom.sun.management.jmxremote MakeTwoDnsRequests
$ kill 17495
$ cat with-jmx.txt
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect DNS requests are sent:
```
$ cat with-jmx.txt
www.example.com 93.184.216.34
www.example.com 93.184.216.34
```
ACTUAL -
But only one DNS request is sent:
```
$ cat with-jmx.txt
www.example.com 93.184.216.34
```
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.security.Security;
import java.net.InetAddress;
public class MakeTwoDnsRequests {
public static void main(String[] args) throws Exception {
// Disable JVM DNS caching
Security.setProperty("networkaddress.cache.ttl", "0");
System.out.println(InetAddress.getByName("www.example.com").getHostAddress());
System.out.println(InetAddress.getByName("www.example.com").getHostAddress());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
For Hotspot, specify sun.net.inetaddr.ttl=0 when starting the JVM:
```
$ java -Dsun.net.inetaddr.ttl=0 -Dcom.sun.management.jmxremote MakeTwoDnsRequests
```
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hostname 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When I disable the JVM's DNS cache (line 8 of MakeTwoDnsRequests.java), and then make two DNS requests, then using Wireshark I can see two DNS requests are made.
However, upon enabling JMX, when I re-do the same test, I can only see one DNS request.
It's as if the disabling of the DNS cache silently failed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(You might need to run tshark and kill as root)
```
$ javac MakeTwoDnsRequests.java
$ tshark -i any -f "src port 53" -Y "dns.qry.type eq 1" -n -T fields -e dns.qry.name -e dns.a > without-jmx.txt 2>/dev/null &
[1] 17460
$ java MakeTwoDnsRequests
$ kill 17460
$ cat without-jmx.txt
www.example.com 93.184.216.34
www.example.com 93.184.216.34
$
$ tshark -i any -f "src port 53" -Y "dns.qry.type eq 1" -n -T fields -e dns.qry.name -e dns.a > with-jmx.txt 2>/dev/null &
[1] 17495
$ java -Dcom.sun.management.jmxremote MakeTwoDnsRequests
$ kill 17495
$ cat with-jmx.txt
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expect DNS requests are sent:
```
$ cat with-jmx.txt
www.example.com 93.184.216.34
www.example.com 93.184.216.34
```
ACTUAL -
But only one DNS request is sent:
```
$ cat with-jmx.txt
www.example.com 93.184.216.34
```
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.security.Security;
import java.net.InetAddress;
public class MakeTwoDnsRequests {
public static void main(String[] args) throws Exception {
// Disable JVM DNS caching
Security.setProperty("networkaddress.cache.ttl", "0");
System.out.println(InetAddress.getByName("www.example.com").getHostAddress());
System.out.println(InetAddress.getByName("www.example.com").getHostAddress());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
For Hotspot, specify sun.net.inetaddr.ttl=0 when starting the JVM:
```
$ java -Dsun.net.inetaddr.ttl=0 -Dcom.sun.management.jmxremote MakeTwoDnsRequests
```