Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4512

Allow customization of the DNS client

    • Fully Compatible
    • Needed

      Updated Description

      A new interface, com.mongodb.spi.dns.DnsClient will be created that defines a minimal API for a DNS provider. Additionally, a service provider interface, com.mongodb.spi.dns.DnsClientProvider will be created. The latter will be used by the driver to look up implementations of DnsClient via the mechanisms described in java.util.ServiceLoader. If no implementations are found, the driver will fallback to using JNDI for looking up SRV and TXT records (which is the current behavior).

      Original Description

      When resolving mongo+srv:// URLs, the MongoDB client (in Java) uses JNDI. However, with GraalVM, JNDI is not supported when building native executables. 

      At the moment, in Quarkus, we have a "substitution" that replaces the default DNS client when building a native executable. 

      It would be great to avoid substituting and instead allow the user to customize the DNS client they want to use (defaulting to the current one). There is already a DNS client interface.

      There are two possibilities:

      • Allows the user to pass a DNS client interface implementation class when configuring the driver
      • Exposes the DNS client interface as an SPI. When there is a provider on the classpath, use that provider instead of the default one.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            cescoffi@redhat.com Clement Escoffier
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: