[ 
https://issues.apache.org/jira/browse/KAFKA-9874?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17086436#comment-17086436
 ] 

para commented on KAFKA-9874:
-----------------------------

thanks [~sliebau] 
As you can see, getHostByAddr was blcoked when the DNS server is down. 
the follow is the default  implement of createSaslServer,and serverName was 
never used.
My question is why use hostname(serverName)int the method createSaslServer,and 
how can i avoid this problem in this case.  Thank you.

{code:java}
public static class ScramSaslServerFactory implements SaslServerFactory {

        @Override
        public SaslServer createSaslServer(String mechanism, String protocol, 
String serverName, Map<String, ?> props, CallbackHandler cbh)
            throws SaslException {

            if (!ScramMechanism.isScram(mechanism)) {
                throw new SaslException(String.format("Requested mechanism '%s' 
is not supported. Supported mechanisms are '%s'.",
                        mechanism, ScramMechanism.mechanismNames()));
            }
            try {
                return new 
ScramSaslServer(ScramMechanism.forMechanismName(mechanism), props, cbh);
            } catch (NoSuchAlgorithmException e) {
                throw new SaslException("Hash algorithm not supported for 
mechanism " + mechanism, e);
            }
        }

        @Override
        public String[] getMechanismNames(Map<String, ?> props) {
            Collection<String> mechanisms = ScramMechanism.mechanismNames();
            return mechanisms.toArray(new String[mechanisms.size()]);
        }
    }
{code}


{code:java}
public static class PlainSaslServerFactory implements SaslServerFactory {

        @Override
        public SaslServer createSaslServer(String mechanism, String protocol, 
String serverName, Map<String, ?> props, CallbackHandler cbh)
            throws SaslException {

            if (!PLAIN_MECHANISM.equals(mechanism))
                throw new SaslException(String.format("Mechanism \'%s\' is not 
supported. Only PLAIN is supported.", mechanism));

            return new PlainSaslServer(cbh);
        }

        @Override
        public String[] getMechanismNames(Map<String, ?> props) {
            if (props == null) return new String[]{PLAIN_MECHANISM};
            String noPlainText = (String) props.get(Sasl.POLICY_NOPLAINTEXT);
            if ("true".equals(noPlainText))
                return new String[]{};
            else
                return new String[]{PLAIN_MECHANISM};
        }
    }
{code}

> broker can not work when use dns fault
> --------------------------------------
>
>                 Key: KAFKA-9874
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9874
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 2.3.1, 2.4.1
>            Reporter: para
>            Priority: Critical
>              Labels: acl, dns
>         Attachments: kast.log
>
>
> in 2.3.1 we authenticate using sasl blocked when the dns service is 
> fault,caused by java native func getHostByAddr.
> but the hostname was never used, can use the default name instead of it
>  
> h3.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to