Skip to content

Commit

Permalink
KAFKA-18079 consumer-config does not work with console-share-consumer (
Browse files Browse the repository at this point in the history
…apache#17925)

Reviewers: Andrew Schofield <[email protected]>, Chia-Ping Tsai <[email protected]>
  • Loading branch information
FrankYang0529 authored Nov 24, 2024
1 parent ccbb731 commit 70babd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ private Set<String> checkShareGroup(Properties consumerPropsFromFile, Properties
}

private Properties buildConsumerProps(Properties consumerPropsFromFile, Properties extraConsumerProps, Set<String> groupIdsProvided) {
Properties consumerProps = new Properties(consumerPropsFromFile);
Properties consumerProps = new Properties();
consumerProps.putAll(consumerPropsFromFile);
consumerProps.putAll(extraConsumerProps);
consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer());
if (consumerProps.getProperty(ConsumerConfig.CLIENT_ID_CONFIG) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.kafka.clients.consumer.AcknowledgeType;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.utils.Exit;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.tools.ToolsTestUtils;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -101,8 +102,11 @@ public void shouldParseConfigsFromFile() throws IOException {

ConsoleShareConsumerOptions config = new ConsoleShareConsumerOptions(args);

assertEquals("1000", config.consumerProps().getProperty("request.timeout.ms"));
assertEquals("group1", config.consumerProps().getProperty("group.id"));
// KafkaShareConsumer uses Utils.propsToMap to convert the properties to a map,
// so using the same method to check the map has the expected values
Map<String, Object> configMap = Utils.propsToMap(config.consumerProps());
assertEquals("1000", configMap.get("request.timeout.ms"));
assertEquals("group1", configMap.get("group.id"));
}

@Test
Expand Down

0 comments on commit 70babd5

Please sign in to comment.