sunm2n commented on code in PR #24240:
URL: https://github.com/apache/kafka/pull/24240#discussion_r4594231060
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java:
##########
@@ -365,28 +370,36 @@ public void run() {
);
this.streamsUncaughtExceptionHandler.accept(e);
} catch (final Exception e) {
+ interrupted = Thread.interrupted();
log.error("Error happened while maintaining global state store.
The streams application or client will now close to ERROR.", e);
this.streamsUncaughtExceptionHandler.accept(e);
} finally {
- // set the state to pending shutdown first as it may be called due
to error;
- // its state may already be PENDING_SHUTDOWN so it will return
false but we
- // intentionally do not check the returned flag
- setState(State.PENDING_SHUTDOWN);
+ interrupted |= Thread.interrupted();
+ try {
+ // set the state to pending shutdown first as it may be called
due to error;
+ // its state may already be PENDING_SHUTDOWN so it will return
false but we
+ // intentionally do not check the returned flag
+ setState(State.PENDING_SHUTDOWN);
- log.info("Shutting down");
+ log.info("Shutting down");
- try {
- stateConsumer.close(wipeStateStore);
- } catch (final IOException e) {
- log.error("Failed to close state maintainer due to the
following error:", e);
- }
+ try {
+ stateConsumer.close(wipeStateStore);
+ } catch (final IOException e) {
+ log.error("Failed to close state maintainer due to the
following error:", e);
+ }
- streamsMetrics.removeAllThreadLevelSensors(getName());
- streamsMetrics.removeAllThreadLevelMetrics(getName());
+ streamsMetrics.removeAllThreadLevelSensors(getName());
+ streamsMetrics.removeAllThreadLevelMetrics(getName());
- setState(DEAD);
+ setState(DEAD);
- log.info("Shutdown complete");
+ log.info("Shutdown complete");
+ } finally {
+ if (interrupted) {
Review Comment:
I followed the pattern from #23549 here, but you're right that there's no
need to restore the flag at the end of `run()`, so I removed the restore, and
the shutdown block is no longer re-indented.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]