mjsax commented on code in PR #20540:
URL: https://github.com/apache/kafka/pull/20540#discussion_r2386338950
##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java:
##########
@@ -141,20 +141,18 @@ public void setup(final TestInfo testInfo) {
private void produceTestRecords(final String inputTopic, final
EmbeddedKafkaCluster cluster) {
final Properties props = new Properties();
- props.put("acks", "all");
- props.put("retries", 1);
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
cluster.bootstrapServers());
props.put(ProducerConfig.CLIENT_ID_CONFIG, "test-client");
props.put("key.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
- final KafkaProducer<String, String> dummyProducer = new
KafkaProducer<>(props);
- for (int i = 0; i < 5000; i++) {
- final String key = "key-" + (i % 50);
- final String value = "value-" + i;
- dummyProducer.send(new ProducerRecord<String, String>(inputTopic,
key, value));
- }
- dummyProducer.flush();
- dummyProducer.close();
+ try (KafkaProducer<String, String> dummyProducer = new
KafkaProducer<>(props)) {
+ for (int i = 0; i < 5000; i++) {
+ final String key = "key-" + (i % 50);
+ final String value = "value-" + i;
+ dummyProducer.send(new ProducerRecord<>(inputTopic, key,
value));
+ }
+ dummyProducer.close();
Review Comment:
try-with-resouce does close the producer automatically . That's why we want
to use it :) this line can be removed
##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java:
##########
@@ -141,20 +141,18 @@ public void setup(final TestInfo testInfo) {
private void produceTestRecords(final String inputTopic, final
EmbeddedKafkaCluster cluster) {
final Properties props = new Properties();
- props.put("acks", "all");
- props.put("retries", 1);
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
cluster.bootstrapServers());
props.put(ProducerConfig.CLIENT_ID_CONFIG, "test-client");
props.put("key.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer",
"org.apache.kafka.common.serialization.StringSerializer");
- final KafkaProducer<String, String> dummyProducer = new
KafkaProducer<>(props);
- for (int i = 0; i < 5000; i++) {
- final String key = "key-" + (i % 50);
- final String value = "value-" + i;
- dummyProducer.send(new ProducerRecord<String, String>(inputTopic,
key, value));
- }
- dummyProducer.flush();
- dummyProducer.close();
+ try (KafkaProducer<String, String> dummyProducer = new
KafkaProducer<>(props)) {
Review Comment:
nit: not sure why "dummyProdoucer"? What's dummy about it. Seems to be just
a `producer` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]