Skip to content

Commit a227594

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 8cc2301 commit a227594

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
@@ -1039,6 +1039,7 @@ public void run() {
10391039
this.last = System.currentTimeMillis();
10401040
initAssignedPartitions();
10411041
publishConsumerStartedEvent();
1042+
Throwable exitThrowable = null;
10421043
while (isRunning()) {
10431044
try {
10441045
pollAndInvoke();
@@ -1074,7 +1075,8 @@ public void run() {
10741075
}
10751076
catch (StopAfterFenceException e) {
10761077
this.logger.error(e, "Stopping container due to fencing");
1077-
stop();
1078+
stop(false);
1079+
exitThrowable = e;
10781080
}
10791081
catch (Error e) { // NOSONAR - rethrown
10801082
Runnable runnable = KafkaMessageListenerContainer.this.emergencyStop;
@@ -1089,7 +1091,7 @@ public void run() {
10891091
handleConsumerException(e);
10901092
}
10911093
}
1092-
wrapUp(null);
1094+
wrapUp(exitThrowable);
10931095
}
10941096

10951097
private void setupSeeks() {

0 commit comments

Comments
 (0)