Skip to content
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

Conversation

jewertow
Copy link
Contributor

Purpose

The Java API createCommittableOffsetBatch requires a list of CommittableOffset where it should allow Committable (as the Scala API does in apply).

References

#1020

@jewertow jewertow changed the title Java API accepts Java API accepts Committable Jan 31, 2020
@jewertow jewertow changed the title Java API accepts Committable Java API createCommittableOffsetBatch accepts Committable Jan 31, 2020
@@ -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 = {
Copy link
Contributor Author

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.

Copy link
Contributor

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)
Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@seglo seglo left a 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 = {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants