Skip to content

MINOR: align the constructor of KafkaConsumer to KafkaProducer#8605

Merged
ijuma merged 1 commit into
apache:trunkfrom
chia7712:remove_kafka_producer_propsToMap
May 31, 2020
Merged

MINOR: align the constructor of KafkaConsumer to KafkaProducer#8605
ijuma merged 1 commit into
apache:trunkfrom
chia7712:remove_kafka_producer_propsToMap

Conversation

@chia7712

@chia7712 chia7712 commented May 3, 2020

Copy link
Copy Markdown
Member

This PR includes following changes.

1. remove KafkaProducer#propsToMap
2. align the constructor of KafkaProducer and KafkaConsumer

  1. move KafkaProducer#propsToMap to Utils#propsToMap
  2. apply Utils#propsToMap to constructor of KafkaConsumer

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

This comment was marked as off-topic.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this constructor is used by KafkaProducerTest only. I keep this method to minimize this PR

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Even though it removes some duplication, it adds some duplication that the previous approach avoided. To me, it's the approach proposed in this PR is more error prone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous approach was intended to avoid having this logic in many places.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviews!

Do you mean that previous approach tried to avoid ‘’’addSerializerToConfig’’’? If so, should we do it for KafkaConsumer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit error prone to have that logic in every constructor. We could move the propsToMap method to a utility class and use it on the consumer too.

@chia7712 chia7712 changed the title Minor: remove KafkaProducer#propsToMap as it is duplicate to Abstract… Minor: align the constructor of KafkaConsumer to KafkaProducer May 4, 2020
@chia7712 chia7712 changed the title Minor: align the constructor of KafkaConsumer to KafkaProducer MINOR: align the constructor of KafkaConsumer to KafkaProducer May 4, 2020
@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch from c45abb9 to af489fd Compare May 4, 2020 17:16

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the access modifier is changed from private to public as

  1. KafkaProducer has a same but public constructor
  2. the previous constructor (ConsumerConfig, ...) is useless

@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch from af489fd to a43dfcf Compare May 6, 2020 06:58
@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch from a43dfcf to e5b0086 Compare May 19, 2020 15:59
@nresare

nresare commented May 21, 2020

Copy link
Copy Markdown
Contributor

@ijuma please note that this diff has changed fundamentally since you reviewed it, and it now modifies KafkaConsumer and not KafkaProducer.

I would like to endorse this PR. Funnily enough I came to very similar conclusions when I worked on the same code yesterday and raised #8707 without any knowledge that this one existed.

@nresare

nresare commented May 21, 2020

Copy link
Copy Markdown
Contributor

Please note that addDeserializerToConfig(Properties, Deserializer<?>, Deserializer<?>) is now only used in test cases and can be removed along with the two tests of that method.

@chia7712

Copy link
Copy Markdown
Member Author

@nresare This "coincidence" is more favorite than "approved" :)

@nresare

nresare commented May 26, 2020

Copy link
Copy Markdown
Contributor

@chia7712 did you get around to update the PR with a variant that removes the no-longer-used addDeserializerToConfig() method?

@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch from e5b0086 to 2cac7c3 Compare May 26, 2020 13:41
Comment thread clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerConfig.java Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is similar to ConsumerConfigTest

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. A few comments below.

Comment thread clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/utils/Utils.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerConfig.java Outdated
@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch 2 times, most recently from 147d89c to 797f864 Compare May 29, 2020 15:19

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, just one comment below.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert a string valued parameter too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@chia7712
chia7712 force-pushed the remove_kafka_producer_propsToMap branch from 797f864 to e51e19a Compare May 30, 2020 18:01

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@ijuma
ijuma merged commit d4c1ef4 into apache:trunk May 31, 2020
@chia7712
chia7712 deleted the remove_kafka_producer_propsToMap branch March 25, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants