From 3750898e20c0680d0c58220fd3ecb6ecf1b5fef0 Mon Sep 17 00:00:00 2001 From: Kamal Chandraprakash Date: Wed, 3 Jul 2019 23:46:44 +0530 Subject: [PATCH] MINOR: Improve group metadata unknown key version exception message (#7006) The patch clarifies the exception message for unknown key versions when loading from the group metadata topic. The patch also makes a trivial change in `KafkaAdminClient` to use `Map.computeIfAbsent`. Reviewers: Viktor Somogyi , Jason Gustafson --- .../org/apache/kafka/clients/admin/KafkaAdminClient.java | 7 +------ .../kafka/coordinator/group/GroupMetadataManager.scala | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java index ebc23c77cd1..f7c022ec5b1 100644 --- a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java +++ b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java @@ -273,12 +273,7 @@ public class KafkaAdminClient extends AdminClient { * @return The list value. */ static List getOrCreateListValue(Map> map, K key) { - List list = map.get(key); - if (list != null) - return list; - list = new LinkedList<>(); - map.put(key, list); - return list; + return map.computeIfAbsent(key, k -> new LinkedList<>()); } /** diff --git a/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala b/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala index 1efbfa081ce..6ef8ff39870 100644 --- a/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala +++ b/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala @@ -1078,7 +1078,7 @@ object GroupMetadataManager { val schemaOpt = MESSAGE_TYPE_SCHEMAS.get(version) schemaOpt match { case Some(schema) => schema - case _ => throw new KafkaException("Unknown offset schema version " + version) + case _ => throw new KafkaException("Unknown message key schema version " + version) } }