You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by da...@apache.org on 2020/10/26 16:33:28 UTC
[kafka] branch 2.7 updated: MINOR;
DescribeUserScramCredentialsRequest API should handle request with
users equals to `null` (#9504)
This is an automated email from the ASF dual-hosted git repository.
dajac pushed a commit to branch 2.7
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.7 by this push:
new e9fec29 MINOR; DescribeUserScramCredentialsRequest API should handle request with users equals to `null` (#9504)
e9fec29 is described below
commit e9fec2984117c3f104274a91f36666f1e29f53d6
Author: David Jacot <dj...@confluent.io>
AuthorDate: Mon Oct 26 17:28:03 2020 +0100
MINOR; DescribeUserScramCredentialsRequest API should handle request with users equals to `null` (#9504)
DescribeUserScramCredentialsRequest states that all users are described when Users is empty or null. null is not handled at the moment and throws an NPE.
Reviewers: Ron Dagostino <rd...@confluent.io>, Colin P. McCabe <cm...@apache.org>
---
core/src/main/scala/kafka/server/KafkaApis.scala | 2 +-
.../server/DescribeUserScramCredentialsRequestTest.scala | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/core/src/main/scala/kafka/server/KafkaApis.scala b/core/src/main/scala/kafka/server/KafkaApis.scala
index 5b5c9c6..dac2590 100644
--- a/core/src/main/scala/kafka/server/KafkaApis.scala
+++ b/core/src/main/scala/kafka/server/KafkaApis.scala
@@ -3066,7 +3066,7 @@ class KafkaApis(val requestChannel: RequestChannel,
if (authorize(request.context, DESCRIBE, CLUSTER, CLUSTER_NAME)) {
val result = adminManager.describeUserScramCredentials(
- Option(describeUserScramCredentialsRequest.data.users.asScala.map(_.name).toList))
+ Option(describeUserScramCredentialsRequest.data.users).map(_.asScala.map(_.name).toList))
sendResponseMaybeThrottle(request, requestThrottleMs =>
new DescribeUserScramCredentialsResponse(result.setThrottleTimeMs(requestThrottleMs)))
} else {
diff --git a/core/src/test/scala/unit/kafka/server/DescribeUserScramCredentialsRequestTest.scala b/core/src/test/scala/unit/kafka/server/DescribeUserScramCredentialsRequestTest.scala
index 86990ec..299fa6f 100644
--- a/core/src/test/scala/unit/kafka/server/DescribeUserScramCredentialsRequestTest.scala
+++ b/core/src/test/scala/unit/kafka/server/DescribeUserScramCredentialsRequestTest.scala
@@ -67,6 +67,19 @@ class DescribeUserScramCredentialsRequestTest extends BaseRequestTest {
}
@Test
+ def testDescribeWithNull(): Unit = {
+ val request = new DescribeUserScramCredentialsRequest.Builder(
+ new DescribeUserScramCredentialsRequestData().setUsers(null)).build()
+ val response = sendDescribeUserScramCredentialsRequest(request)
+
+ val error = response.data.errorCode
+ assertEquals("Expected no error when describing everything and there are no credentials",
+ Errors.NONE.code, error)
+ assertEquals("Expected no credentials when describing everything and there are no credentials",
+ 0, response.data.results.size)
+ }
+
+ @Test
def testDescribeNotController(): Unit = {
val request = new DescribeUserScramCredentialsRequest.Builder(
new DescribeUserScramCredentialsRequestData()).build()