From d22cac93bdcd43ef6040cb0780034f58e4fa40a0 Mon Sep 17 00:00:00 2001 From: Anchit Jain <112778471+anchitj@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:32:09 +0530 Subject: [PATCH] Fix Backward Compatibility Issue in TopicPartitionOffset Constructor (#2066) * Fix backwards compatability of TopicPartitionOffset constructor #2060 * Fix bug and add changelog --------- Co-authored-by: drinehim --- CHANGELOG.md | 7 +++++ src/Confluent.Kafka/TopicPartitionOffset.cs | 34 +++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72d1f4be0..ff1169897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 2.2.0 + +## Fixes + +- Fix backwards compatability of TopicPartitionOffset constructor. ([drinehimer](https://github.com/drinehimer), #2066) + + # 2.1.1 ## Enhancements diff --git a/src/Confluent.Kafka/TopicPartitionOffset.cs b/src/Confluent.Kafka/TopicPartitionOffset.cs index eeb05dc42..425b0cb65 100644 --- a/src/Confluent.Kafka/TopicPartitionOffset.cs +++ b/src/Confluent.Kafka/TopicPartitionOffset.cs @@ -23,6 +23,18 @@ namespace Confluent.Kafka /// public class TopicPartitionOffset { + /// + /// Initializes a new TopicPartitionOffset instance. + /// + /// + /// Kafka topic name and partition. + /// + /// + /// A Kafka offset value. + /// + public TopicPartitionOffset(TopicPartition tp, Offset offset) + : this(tp.Topic, tp.Partition, offset, null) { } + /// /// Initializes a new TopicPartitionOffset instance. /// @@ -36,8 +48,24 @@ public class TopicPartitionOffset /// The offset leader epoch (optional). /// public TopicPartitionOffset(TopicPartition tp, Offset offset, - int? leaderEpoch = null) - : this(tp.Topic, tp.Partition, offset, leaderEpoch) {} + int? leaderEpoch) + : this(tp.Topic, tp.Partition, offset, leaderEpoch) { } + + /// + /// Initializes a new TopicPartitionOffset instance. + /// + /// + /// A Kafka topic name. + /// + /// + /// A Kafka partition. + /// + /// + /// A Kafka offset value. + /// + public TopicPartitionOffset(string topic, Partition partition, + Offset offset) + : this(topic, partition, offset, null) { } /// /// Initializes a new TopicPartitionOffset instance. @@ -55,7 +83,7 @@ public TopicPartitionOffset(TopicPartition tp, Offset offset, /// The optional offset leader epoch. /// public TopicPartitionOffset(string topic, Partition partition, - Offset offset, int? leaderEpoch = null) + Offset offset, int? leaderEpoch) { Topic = topic; Partition = partition;