Skip to content

Commit

Permalink
Merge pull request #304 from Myllyenko/fixing_race_condition_on_Async…
Browse files Browse the repository at this point in the history
…ReaderImpl_shutdown

Fixing race condition in AsyncReaderImpl::shutdown
  • Loading branch information
pnv1 authored Aug 19, 2024
2 parents 16f2600 + e741432 commit fd38171
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,21 @@ protected void handleClosePartitionSession(tech.ydb.topic.read.PartitionSession
});
}

protected void handleReaderClosed() {
handlerExecutor.execute(() -> {
protected CompletableFuture<Void> handleReaderClosed() {
return CompletableFuture.runAsync(() -> {
try {
eventHandler.onReaderClosed(new ReaderClosedEvent());
} catch (Throwable th) {
logUserThrowableAndStopWorking(th, "onReaderClosed");
throw th;
}
});
}, handlerExecutor);
}

@Override
protected void onShutdown(String reason) {
super.onShutdown(reason);
handleReaderClosed();
handleReaderClosed().join();
if (defaultHandlerExecutorService != null) {
logger.debug("Shutting down default handler executor");
defaultHandlerExecutorService.shutdown();
Expand Down

0 comments on commit fd38171

Please sign in to comment.