Skip to content

Commit 452814c

Browse files
garyrussellartembilan
authored andcommitted
GH-774: Rethrow e in KT.executeInTransaction()
Fixes #774 **cherry-pick to 2.1.x, 2.0.x, 1.3.x** (cherry picked from commit c59a31f)
1 parent 2daa46c commit 452814c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/KafkaTemplate.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,15 @@ public <T> T executeInTransaction(OperationsCallback<K, V, T> callback) {
258258
finally {
259259
this.producers.remove();
260260
closeProducer(producer, false);
261-
producer = null;
262261
}
262+
throw e;
263263
}
264-
if (producer != null) {
265-
try {
266-
producer.commitTransaction();
267-
}
268-
finally {
269-
closeProducer(producer, false);
270-
this.producers.remove();
271-
}
264+
try {
265+
producer.commitTransaction();
266+
}
267+
finally {
268+
this.producers.remove();
269+
closeProducer(producer, false);
272270
}
273271
return result;
274272
}

0 commit comments

Comments
 (0)