Skip to content

Commit

Permalink
MINOR: disable zookeeper.sasl.client to avoid false error (apache#11469)
Browse files Browse the repository at this point in the history
Reviewers: Mickael Maison <[email protected]>
  • Loading branch information
chia7712 authored Feb 5, 2022
1 parent ba0fe61 commit f49524e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/src/main/scala/kafka/server/KafkaServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ object KafkaServer {
KafkaConfig.setZooKeeperClientProperty(clientConfig, KafkaConfig.ZkSslCrlEnableProp, config.ZkSslCrlEnable.toString)
KafkaConfig.setZooKeeperClientProperty(clientConfig, KafkaConfig.ZkSslOcspEnableProp, config.ZkSslOcspEnable.toString)
}
// The zk sasl is enabled by default so it can produce false error when broker does not intend to use SASL.
if (!JaasUtils.isZkSaslEnabled) clientConfig.setProperty(JaasUtils.ZK_SASL_CLIENT, "false")
clientConfig
}

Expand Down
10 changes: 9 additions & 1 deletion core/src/test/scala/unit/kafka/server/KafkaServerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package kafka.server

import kafka.api.ApiVersion
import kafka.utils.TestUtils
import kafka.server.QuorumTestHarness
import org.apache.kafka.common.security.JaasUtils
import org.junit.jupiter.api.Assertions.{assertEquals, assertNull, assertThrows, fail}
import org.junit.jupiter.api.Test

Expand All @@ -41,6 +41,14 @@ class KafkaServerTest extends QuorumTestHarness {
TestUtils.shutdownServers(Seq(server1, server2))
}

@Test
def testCreatesProperZkConfigWhenSaslDisabled(): Unit = {
val props = new Properties
props.put(KafkaConfig.ZkConnectProp, zkConnect) // required, otherwise we would leave it out
val zkClientConfig = KafkaServer.zkClientConfigFromKafkaConfig(KafkaConfig.fromProps(props))
assertEquals("false", zkClientConfig.getProperty(JaasUtils.ZK_SASL_CLIENT))
}

@Test
def testCreatesProperZkTlsConfigWhenDisabled(): Unit = {
val props = new Properties
Expand Down

0 comments on commit f49524e

Please sign in to comment.