Skip to content

Commit f9f7d9c

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 17278b5 commit f9f7d9c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,15 @@ public <T> T executeInTransaction(OperationsCallback<K, V, T> callback) {
280280
finally {
281281
this.producers.remove();
282282
closeProducer(producer, false);
283-
producer = null;
284283
}
284+
throw e;
285285
}
286-
if (producer != null) {
287-
try {
288-
producer.commitTransaction();
289-
}
290-
finally {
291-
closeProducer(producer, false);
292-
this.producers.remove();
293-
}
286+
try {
287+
producer.commitTransaction();
288+
}
289+
finally {
290+
this.producers.remove();
291+
closeProducer(producer, false);
294292
}
295293
return result;
296294
}

0 commit comments

Comments
 (0)