Skip to content

Commit 81342e7

Browse files
committed
GH-1633: Fix Race and Event
Resolves #1633 - don't block when self-stopping after producer is fenced - pass the exception into wrapUp to properly set the stopped reason **chery-pick to 2.5.x**
1 parent 786b8b1 commit 81342e7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ public void run() {
10551055
this.last = System.currentTimeMillis();
10561056
initAssignedPartitions();
10571057
publishConsumerStartedEvent();
1058+
Throwable exitThrowable = null;
10581059
while (isRunning()) {
10591060
try {
10601061
pollAndInvoke();
@@ -1090,7 +1091,8 @@ public void run() {
10901091
}
10911092
catch (StopAfterFenceException e) {
10921093
this.logger.error(e, "Stopping container due to fencing");
1093-
stop();
1094+
stop(false);
1095+
exitThrowable = e;
10941096
}
10951097
catch (Error e) { // NOSONAR - rethrown
10961098
Runnable runnable = KafkaMessageListenerContainer.this.emergencyStop;
@@ -1105,7 +1107,7 @@ public void run() {
11051107
handleConsumerException(e);
11061108
}
11071109
}
1108-
wrapUp(null);
1110+
wrapUp(exitThrowable);
11091111
}
11101112

11111113
private void setupSeeks() {

0 commit comments

Comments
 (0)