Skip to content

Commit c59a31f

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**
1 parent 43a8b2d commit c59a31f

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,15 @@ public <T> T executeInTransaction(OperationsCallback<K, V, T> callback) {
285285
finally {
286286
this.producers.remove();
287287
closeProducer(producer, false);
288-
producer = null;
289288
}
289+
throw e;
290290
}
291-
if (producer != null) {
292-
try {
293-
producer.commitTransaction();
294-
}
295-
finally {
296-
closeProducer(producer, false);
297-
this.producers.remove();
298-
}
291+
try {
292+
producer.commitTransaction();
293+
}
294+
finally {
295+
this.producers.remove();
296+
closeProducer(producer, false);
299297
}
300298
return result;
301299
}

0 commit comments

Comments
 (0)