Skip to content

Commit ca6ac93

Browse files
MINOR: Retain public constructors of classes from public API (apache#6455)
TopicDescription and ConsumerGroupDescription in org.apache.kafka.clients.admin. are part of the public API, so we should retain the existing public constructor. Changed the new constructor with authorized operations to be package-private to avoid maintaining more public constructors since we only expect admin client to use this. Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>
1 parent 6279b03 commit ca6ac93

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

clients/src/main/java/org/apache/kafka/clients/admin/ConsumerGroupDescription.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ public class ConsumerGroupDescription {
4141
private final Set<AclOperation> authorizedOperations;
4242

4343
public ConsumerGroupDescription(String groupId,
44+
boolean isSimpleConsumerGroup,
45+
Collection<MemberDescription> members,
46+
String partitionAssignor,
47+
ConsumerGroupState state,
48+
Node coordinator) {
49+
this(groupId, isSimpleConsumerGroup, members, partitionAssignor, state, coordinator, Collections.emptySet());
50+
}
51+
52+
ConsumerGroupDescription(String groupId,
4453
boolean isSimpleConsumerGroup,
4554
Collection<MemberDescription> members,
4655
String partitionAssignor,

clients/src/main/java/org/apache/kafka/clients/admin/TopicDescription.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.kafka.common.acl.AclOperation;
2222
import org.apache.kafka.common.utils.Utils;
2323

24+
import java.util.Collections;
2425
import java.util.List;
2526
import java.util.Objects;
2627
import java.util.Set;
@@ -50,6 +51,18 @@ public int hashCode() {
5051
return Objects.hash(name, internal, partitions, authorizedOperations);
5152
}
5253

54+
/**
55+
* Create an instance with the specified parameters.
56+
*
57+
* @param name The topic name
58+
* @param internal Whether the topic is internal to Kafka
59+
* @param partitions A list of partitions where the index represents the partition id and the element contains
60+
* leadership and replica information for that partition.
61+
*/
62+
public TopicDescription(String name, boolean internal, List<TopicPartitionInfo> partitions) {
63+
this(name, internal, partitions, Collections.emptySet());
64+
}
65+
5366
/**
5467
* Create an instance with the specified parameters.
5568
*
@@ -59,7 +72,7 @@ public int hashCode() {
5972
* leadership and replica information for that partition.
6073
* @param authorizedOperations authorized operations for this topic
6174
*/
62-
public TopicDescription(String name, boolean internal, List<TopicPartitionInfo> partitions,
75+
TopicDescription(String name, boolean internal, List<TopicPartitionInfo> partitions,
6376
Set<AclOperation> authorizedOperations) {
6477
this.name = name;
6578
this.internal = internal;

streams/src/test/java/org/apache/kafka/streams/processor/internals/InternalTopicManagerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ public void shouldCreateRequiredTopics() throws Exception {
113113
{
114114
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
115115
}
116-
}, Collections.emptySet()), mockAdminClient.describeTopics(Collections.singleton(topic)).values().get(topic).get());
116+
}), mockAdminClient.describeTopics(Collections.singleton(topic)).values().get(topic).get());
117117
assertEquals(new TopicDescription(topic2, false, new ArrayList<TopicPartitionInfo>() {
118118
{
119119
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
120120
}
121-
}, Collections.emptySet()), mockAdminClient.describeTopics(Collections.singleton(topic2)).values().get(topic2).get());
121+
}), mockAdminClient.describeTopics(Collections.singleton(topic2)).values().get(topic2).get());
122122
assertEquals(new TopicDescription(topic3, false, new ArrayList<TopicPartitionInfo>() {
123123
{
124124
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
125125
}
126-
}, Collections.emptySet()), mockAdminClient.describeTopics(Collections.singleton(topic3)).values().get(topic3).get());
126+
}), mockAdminClient.describeTopics(Collections.singleton(topic3)).values().get(topic3).get());
127127

128128
final ConfigResource resource = new ConfigResource(ConfigResource.Type.TOPIC, topic);
129129
final ConfigResource resource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2);

tools/src/test/java/org/apache/kafka/trogdor/common/WorkerUtilsTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public void testCreateOneTopic() throws Throwable {
8181
new TopicDescription(
8282
TEST_TOPIC, false,
8383
Collections.singletonList(
84-
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList())),
85-
Collections.emptySet()),
84+
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()))),
8685
adminClient.describeTopics(
8786
Collections.singleton(TEST_TOPIC)).values().get(TEST_TOPIC).get()
8887
);
@@ -99,8 +98,7 @@ public void testCreateRetriesOnTimeout() throws Throwable {
9998
new TopicDescription(
10099
TEST_TOPIC, false,
101100
Collections.singletonList(
102-
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList())),
103-
Collections.emptySet()),
101+
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()))),
104102
adminClient.describeTopics(
105103
Collections.singleton(TEST_TOPIC)).values().get(TEST_TOPIC).get()
106104
);
@@ -180,8 +178,7 @@ public void testCreatesNotExistingTopics() throws Throwable {
180178
new TopicDescription(
181179
TEST_TOPIC, false,
182180
Collections.singletonList(
183-
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList())),
184-
Collections.emptySet()),
181+
new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()))),
185182
adminClient.describeTopics(Collections.singleton(TEST_TOPIC)).values().get(TEST_TOPIC).get()
186183
);
187184
}

0 commit comments

Comments
 (0)