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

getaddrinfo can fail with EAI_SYSTEM/EAGAIN, causes UnknownHostException to be thrown

    Details

    • Subcomponent:
    • Resolved In Build:
      b113
    • CPU:
      generic
    • OS:
      linux

      Backports

        Description

        SYNOPSIS
        --------
        Improve Java's handling of EAGAIN with respect to DNS lookups

        OPERATING SYSTEM
        ----------------
        Observed on Linux, but probably applicable to all platforms

        FULL JDK VERSION
        ----------------
        All

        DESCRIPTION
        -----------
        Occasionally, the system call getaddrinfo() fails with a return value EAI_SYSTEM and errno set to EAGAIN, meaning that the resource is temporarily unavailable. Under these circumstances Java throws an UnknownHostException, which can cause confusion for application users. We believe that Java's handing of this error needs to be improved.

        We experimented with a standalone C program and found that the failure is highly transient - calling getaddrinfo() again after 50ms almost always succeeds.

        The JRE's handling of this scenario could therefore be improved. Here are two suggestions:

        1. Implement a retry when confronted with an EAGAIN error from the
           system call.

        OR

        2. Redesign the Java API to distinguish between true lookup failures and
           EAGAIN failures, via the introduction of a new Exception class, to
           allow applications to handle the different error scenarios.

        WORKAROUND
        ----------
        The application could catch all UnknownHostExceptions and retry just in case the error was an EAGAIN, but this is obviously far from ideal.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  bpb Brian Burkhalter
                  Reporter:
                  dkorbel David Korbel (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: