mirror of https://github.com/apache/kafka.git
KAFKA-18079 consumer-config does not work with console-share-consumer (#17925)
Reviewers: Andrew Schofield <aschofield@confluent.io>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
ccbb73111c
commit
70babd5716
|
@ -182,7 +182,8 @@ public final class ConsoleShareConsumerOptions extends CommandDefaultOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Properties buildConsumerProps(Properties consumerPropsFromFile, Properties extraConsumerProps, Set<String> groupIdsProvided) {
|
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.putAll(extraConsumerProps);
|
||||||
consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer());
|
consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer());
|
||||||
if (consumerProps.getProperty(ConsumerConfig.CLIENT_ID_CONFIG) == null) {
|
if (consumerProps.getProperty(ConsumerConfig.CLIENT_ID_CONFIG) == null) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.kafka.tools.consumer;
|
||||||
import org.apache.kafka.clients.consumer.AcknowledgeType;
|
import org.apache.kafka.clients.consumer.AcknowledgeType;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||||
import org.apache.kafka.common.utils.Exit;
|
import org.apache.kafka.common.utils.Exit;
|
||||||
|
import org.apache.kafka.common.utils.Utils;
|
||||||
import org.apache.kafka.tools.ToolsTestUtils;
|
import org.apache.kafka.tools.ToolsTestUtils;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -101,8 +102,11 @@ public class ConsoleShareConsumerOptionsTest {
|
||||||
|
|
||||||
ConsoleShareConsumerOptions config = new ConsoleShareConsumerOptions(args);
|
ConsoleShareConsumerOptions config = new ConsoleShareConsumerOptions(args);
|
||||||
|
|
||||||
assertEquals("1000", config.consumerProps().getProperty("request.timeout.ms"));
|
// KafkaShareConsumer uses Utils.propsToMap to convert the properties to a map,
|
||||||
assertEquals("group1", config.consumerProps().getProperty("group.id"));
|
// 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
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue