diff --git a/test/extensions/common/async_files/async_file_handle_thread_pool_test.cc b/test/extensions/common/async_files/async_file_handle_thread_pool_test.cc index cc141ae67aff..8707ce92afb4 100644 --- a/test/extensions/common/async_files/async_file_handle_thread_pool_test.cc +++ b/test/extensions/common/async_files/async_file_handle_thread_pool_test.cc @@ -88,6 +88,12 @@ class AsyncFileHandleWithMockPosixTest : public testing::Test, public AsyncFileH EXPECT_CALL(mock_posix_file_operations_, close(_)) .WillRepeatedly(Return(Api::SysCallIntResult{0, 0})); } + void TearDown() override { + // manager_ must be torn down before mock_posix_file_operations_ to ensure that file + // operations are completed before the mock is destroyed. + manager_ = nullptr; + factory_ = nullptr; + } StrictMock mock_posix_file_operations_; };