Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8339538

Wrong timeout computations in DnsClient

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • None
    • core-libs
    • None

      The following issues related to timeout computation in the 'com.sun.jndi.dns.DnsClient' code have been reported here:
      https://mail.openjdk.org/pipermail/core-libs-dev/2024-September/128797.html

      1. Non-monotonic time source is used to calculate the duration of receive operation:
          " long start = System.currentTimeMillis();
                  gotData = blockingReceive(udpChannel, ipkt, timeoutLeft);
                  long end = System.currentTimeMillis();
          System.currentTimeMillis() is not monotonic and therefore it could happen that end - start < 0"

      2. Left timeout value is not correctly decreased:
          "int timeoutLeft = pktTimeout;
          do {
                ...
                timeoutLeft = pktTimeout - ((int) (end - start));
          } while (timeoutLeft > MIN_TIMEOUT);
          

          Here, timeoutLeft is not iteratively decreased, but is always derived from `pktTimeout`.
          I can see a case where `timeoutLeft` never drops below `MIN_TIMEOUT` (this is the part where I'm not sure if I'm missing some deeper knowledge)."

            aefimov Aleksej Efimov
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: