C0urante opened a new pull request, #13379: URL: https://github.com/apache/kafka/pull/13379
[Jira](https://issues.apache.org/jira/browse/KAFKA-14799) Since invoking `KafkaProducer::abortTransaction` when no transaction is currently open (via `KafkaProducer::beginTransaction`) causes an `IllegalStateException`, requests by source tasks to abort the current transaction when they have not returned any records from `SourceTask::poll` will currently cause the task to fail. This patch gracefully handles that scenario by skipping the call to `KafkaProducer::abortTransaction` but emitting a `WARN`-level log message. A basic unit test is added to ensure that we do not attempt to abort empty transactions. As a follow-up item, we may want to consider using the `MockProducer` class in these and other unit tests since it may involve less work than manually mocking the `Producer` interface and should more-closely resemble the behavior of the `KafkaProducer` class (for example, it will automatically check for transaction state during calls to `beginTransaction`, `abortTransaction`, and `commitTransaction`). ### Committer Checklist (excluded from commit message) - [ ] Verify design and implementation - [ ] Verify test coverage and CI build status - [ ] Verify documentation (including upgrade notes) -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org