Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,15 @@ public Map<String, Object> getMainConsumerConfigs(final String groupId, final St
// add group id, client id with stream client id prefix, and group instance id
consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
consumerProps.put(CommonClientConfigs.CLIENT_ID_CONFIG, clientId);
final String groupInstanceId = (String) consumerProps.get(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG);
final String groupInstanceId = (String) parseType(
ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,
consumerProps.get(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG),
Type.STRING
);
new ConfigDef.NonEmptyString().ensureValid(
ConsumerConfig.GROUP_INSTANCE_ID_CONFIG,
groupInstanceId
);
// Suffix each thread consumer with thread.id to enforce uniqueness of group.instance.id.
if (groupInstanceId != null) {
consumerProps.put(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG, groupInstanceId + "-" + threadIdx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ public void testGetGroupInstanceIdConfigs() {
assertNull(returnedProps.get(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG));
}

@ParameterizedTest
@ValueSource(strings = {"", StreamsConfig.CONSUMER_PREFIX, StreamsConfig.MAIN_CONSUMER_PREFIX})
public void shouldRejectEmptyGroupInstanceId(final String prefix) {
props.put(prefix + ConsumerConfig.GROUP_INSTANCE_ID_CONFIG, "");
final StreamsConfig streamsConfig = new StreamsConfig(props);

final ConfigException exception = assertThrows(
ConfigException.class,
() -> streamsConfig.getMainConsumerConfigs(groupId, clientId, threadIdx)
);
assertTrue(exception.getMessage().contains(ConsumerConfig.GROUP_INSTANCE_ID_CONFIG));
}

@ParameterizedTest
@ValueSource(strings = {"", StreamsConfig.CONSUMER_PREFIX, StreamsConfig.MAIN_CONSUMER_PREFIX})
public void shouldAllowStaticMembershipWhenStreamsProtocolUsed(final String prefix) {
Expand Down