cadonna commented on PR #15188:
URL: https://github.com/apache/kafka/pull/15188#issuecomment-1953815656
> > > @cadonna @lianetm, since we're supporting for both subscribe method
using java.util.regex.Pattern and SubscriptionPattern, I think we should throw
a illegal heartbeat exeption when user try to use both method at the same time
and inform the user to use once at a time, since the field SubscribedRegex is
used for java.util.regex.Pattern as well as SubscriptionPattern. What do you
guys think?
> >
> >
> > IMO, we must support the deprecated pattern subscriptions with
`java.util.regex.Pattern` to ensure backwards compatibility, but we do not need
to support mixed usage of `java.util.regex.Pattern` and Google regex patterns.
I think this is a blind spot in the KIP. I propose to throw an
`IllegalStateException` if `subscribe(java.util.regex.Pattern)` is called after
`subscribe(SubscriptionPattern)` (and vice versa) without calling
`unsubscribe()` in between. That is similar to the restrictions between
pattern, topic, and partition subscriptions @lianetm linked above. I do not
think it is worth to consider the edge case of mixed usage of the two pattern
types. Does this make sense to you? \cc @dajac What do you as the original
author of the KIP think? Should we update the KIP to make this clear?
>
> @cadonna I would rather follow what we already do with `subscribe` today.
The last one called takes precedence.
@dajac The javadocs of `subscribe()` say:
```
* @throws IllegalStateException If {@code subscribe()} is called
previously with topics, or assign is called
* previously (without a subsequent call
to {@link #unsubscribe()}), or if not
* configured at-least one partition
assignment strategy
```
https://github.com/apache/kafka/blob/f0087ac6a8a7b1005e9588e42b3679146bd3eb13/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L727
One could argue that both subscriptions are pattern subscriptions, but they
are quite different internally. I am wondering how complex it is to allow mixed
usage.
--
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]