-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java API createCommittableOffsetBatch accepts Committable #1033
Java API createCommittableOffsetBatch accepts Committable #1033
Conversation
@@ -181,7 +181,7 @@ object ConsumerMessage { | |||
* Java API: | |||
* Create an offset batch out of a list of offsets. | |||
*/ | |||
def createCommittableOffsetBatch(offsets: java.util.List[CommittableOffset]): CommittableOffsetBatch = { | |||
def createCommittableOffsetBatch[T <: Committable](offsets: java.util.List[T]): CommittableOffsetBatch = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test I added proves that the type of this list has to be T <: Committable
istead of Committable
, but both types Committable
and T <: Committable
are binary-incompatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This seems fine to me. It's binary-incompatible, but since it's only widening permitted types it shouldn't break anything that was using the previous method.
records.stream().map(ConsumerRecord::value).collect(Collectors.joining(",")); | ||
return ProducerMessage.single(new ProducerRecord<>(topic2, key, value)); | ||
}) | ||
.mapContext(ConsumerMessage::createCommittableOffsetBatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of def createCommittableOffsetBatch(offsets: java.util.List[Committable])
it wouldn't compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I added the MiMa exception.
@@ -181,7 +181,7 @@ object ConsumerMessage { | |||
* Java API: | |||
* Create an offset batch out of a list of offsets. | |||
*/ | |||
def createCommittableOffsetBatch(offsets: java.util.List[CommittableOffset]): CommittableOffsetBatch = { | |||
def createCommittableOffsetBatch[T <: Committable](offsets: java.util.List[T]): CommittableOffsetBatch = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This seems fine to me. It's binary-incompatible, but since it's only widening permitted types it shouldn't break anything that was using the previous method.
records.stream().map(ConsumerRecord::value).collect(Collectors.joining(",")); | ||
return ProducerMessage.single(new ProducerRecord<>(topic2, key, value)); | ||
}) | ||
.mapContext(ConsumerMessage::createCommittableOffsetBatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Purpose
The Java API
createCommittableOffsetBatch
requires a list ofCommittableOffset
where it should allowCommittable
(as the Scala API does in apply).References
#1020