Skip to content

Conversation

@garyrussell
Copy link
Contributor

Resolves #1026

Also improve DefaultKafkaHeaderMapper with a NeverMatchHeaderMatcher.

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

Some review so far.

* @return true to provide the header.
* @since 2.3
*/
String exposeGroupId() default "false";
Copy link
Member

Choose a reason for hiding this comment

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

I wonder why would one doesn't want to map this property to header?..
Why don't we do that unconditionally like for many other Kafka records properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh - good point 😄

protected final List<SimplePatternBasedHeaderMatcher> matchers = new ArrayList<>(NEVER_MAPPED); // NOSONAR
protected final Log LOGGER = LogFactory.getLog(getClass()); // NOSONAR

private static final List<HeaderMatcher> NEVER_MAPPED = Collections.singletonList(
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't look like this constant is used any where.
Can't we just make it inline in the matchers bellow?

protected final Log LOGGER = LogFactory.getLog(getClass()); // NOSONAR

private static final List<HeaderMatcher> NEVER_MAPPED = Collections.singletonList(
new NeverMatchHeaderMatcher(Arrays.stream(new String[] {
Copy link
Member

Choose a reason for hiding this comment

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

I would move toSet() into the NeverMatchHeaderMatcher ctor having its argument as a varargs variant to even avoid an explicit array here.

* A matcher for headers.
* @since 2.3
*/
protected interface HeaderMatcher {
Copy link
Member

Choose a reason for hiding this comment

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

So, the idea to let have any custom matcher only if we extend the whole class.
No way to reuse default one, but insert custom matchers.

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simply realized that having a pattern matcher for header names without a wildcard is much less efficient than looking up the header in a set.

The interface is so I can have 2 different types of matcher.

Copy link
Member

Choose a reason for hiding this comment

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

But my point that it is protected and therefore not available if we don't extend.
The implementation is fine though, only concern is about convenience of end-users.

* @param value the value.
* @param consumer the consumer.
* @return this.
* @since 5.2
Copy link
Member

Choose a reason for hiding this comment

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

I think all these @since on methods are just wrong for this new class in this project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh - copy/paste.

@artembilan artembilan merged commit c53c68e into spring-projects:master Mar 27, 2019
@garyrussell garyrussell deleted the GH-1026 branch March 27, 2019 16:44
garyrussell added a commit to garyrussell/spring-kafka that referenced this pull request Oct 9, 2023
spring-projects#1030 (comment)

We removed the property from the annotation during PR review, but failed to correct the docs.
artembilan pushed a commit that referenced this pull request Oct 9, 2023
#1030 (comment)

We removed the property from the annotation during PR review, but failed to correct the docs.
garyrussell added a commit to garyrussell/spring-kafka that referenced this pull request Oct 9, 2023
spring-projects#1030 (comment)

We removed the property from the annotation during PR review, but failed to correct the docs.
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.

2 participants