@Override
    public String resolveAdditionalQueryParametersFromTxtRecords(final String host) {
    """
	/*
	A TXT record is just a string
	We require each to be one or more query parameters for a MongoDB connection string.
	Here we concatenate TXT records together with a '&' separator as required by connection strings
    """
        String additionalQueryParameters = "";
        InitialDirContext dirContext = createDnsDirContext();
        try {
            Attributes attributes = dirContext.getAttributes(host, new String[]{"TXT"});
            Attribute attribute = attributes.get("TXT");
            if (attribute != null) {
                NamingEnumeration<?> txtRecordEnumeration = attribute.getAll();
                if (txtRecordEnumeration.hasMore()) {
                    // Remove all space characters, as the DNS resolver for TXT records inserts a space character
                    // between each character-string in a single TXT record.  That whitespace is spurious in
                    // this context and must be removed
                    additionalQueryParameters = ((String) txtRecordEnumeration.next()).replaceAll("\\s", "");

                    if (txtRecordEnumeration.hasMore()) {
                        throw new MongoConfigurationException(format("Multiple TXT records found for host '%s'.  Only one is permitted",
                                host));
                    }
                }
            }
        } catch (NamingException e) {
            throw new MongoConfigurationException("Unable to look up TXT record for host " + host, e);
        } finally {
            try {
                dirContext.close();
            } catch (NamingException e) {
                // ignore
            }
        }
        return additionalQueryParameters;
    }
@Override
    public String resolveAdditionalQueryParametersFromTxtRecords(final String host) {
        String additionalQueryParameters = "";
        InitialDirContext dirContext = createDnsDirContext();
        try {
            Attributes attributes = dirContext.getAttributes(host, new String[]{"TXT"});
            Attribute attribute = attributes.get("TXT");
            if (attribute != null) {
                NamingEnumeration<?> txtRecordEnumeration = attribute.getAll();
                if (txtRecordEnumeration.hasMore()) {
                    // Remove all space characters, as the DNS resolver for TXT records inserts a space character
                    // between each character-string in a single TXT record.  That whitespace is spurious in
                    // this context and must be removed
                    additionalQueryParameters = ((String) txtRecordEnumeration.next()).replaceAll("\\s", "");

                    if (txtRecordEnumeration.hasMore()) {
                        throw new MongoConfigurationException(format("Multiple TXT records found for host '%s'.  Only one is permitted",
                                host));
                    }
                }
            }
        } catch (NamingException e) {
            throw new MongoConfigurationException("Unable to look up TXT record for host " + host, e);
        } finally {
            try {
                dirContext.close();
            } catch (NamingException e) {
                // ignore
            }
        }
        return additionalQueryParameters;
    }
@ Override public String resolveAdditionalQueryParametersFromTxtRecords ( final String host ) { String additionalQueryParameters = "" ; InitialDirContext dirContext = createDnsDirContext ( ) ; try { Attributes attributes = dirContext . getAttributes ( host , new String [ ] { "TXT" } ) ; Attribute attribute = attributes . get ( "TXT" ) ; if ( attribute != null ) { NamingEnumeration < ? > txtRecordEnumeration = attribute . getAll ( ) ; if ( txtRecordEnumeration . hasMore ( ) ) { // Remove all space characters, as the DNS resolver for TXT records inserts a space character // between each character-string in a single TXT record.  That whitespace is spurious in // this context and must be removed additionalQueryParameters = ( ( String ) txtRecordEnumeration . next ( ) ) . replaceAll ( "\\s" , "" ) ; if ( txtRecordEnumeration . hasMore ( ) ) { throw new MongoConfigurationException ( format ( "Multiple TXT records found for host '%s'.  Only one is permitted" , host ) ) ; } } } } catch ( NamingException e ) { throw new MongoConfigurationException ( "Unable to look up TXT record for host " + host , e ) ; } finally { try { dirContext . close ( ) ; } catch ( NamingException e ) { // ignore } } return additionalQueryParameters ; }
/*
A TXT record is just a string
We require each to be one or more query parameters for a MongoDB connection string.
Here we concatenate TXT records together with a '&' separator as required by connection strings
/ * A TXT record is just a string We require each to be one or more query parameters for a MongoDB connection string . Here we concatenate TXT records together with a & separator as required by connection strings