diff --git a/src/mongo/util/future_util_test.cpp b/src/mongo/util/future_util_test.cpp
|
index e9878d21e8..d35a45ef72 100644
|
--- a/src/mongo/util/future_util_test.cpp
|
+++ b/src/mongo/util/future_util_test.cpp
|
@@ -64,7 +64,7 @@ public:
|
return _network;
|
}
|
|
-private:
|
+protected:
|
std::shared_ptr<executor::ThreadPoolTaskExecutor> _executor;
|
executor::NetworkInterfaceMock* _network;
|
};
|
@@ -85,6 +85,26 @@ private:
|
|
using AsyncTryUntilTest = FutureUtilTest;
|
|
+// This test case doesn't actually use AsyncTry but AsyncTryUntilTest is a test fixture that I knew
|
+// had a ThreadPoolTaskExecutor.
|
+TEST_F(AsyncTryUntilTest, CheckIfGetWaitsForDestructorToRun) {
|
+ auto currentUseCount = _executor.use_count();
|
+ auto i = 0;
|
+ {
|
+ ExecutorFuture(_executor)
|
+ .then([&i, executor = _executor] {
|
+ (void)executor;
|
+ ++i;
|
+ })
|
+ // Uncommenting the following line causes the test to pass.
|
+ // .then([] {})
|
+ .get();
|
+ }
|
+
|
+ ASSERT_EQ(i, 1);
|
+ ASSERT_EQ(_executor.use_count(), currentUseCount);
|
+}
|
+
|
TEST_F(AsyncTryUntilTest, LoopExecutesOnceWithAlwaysTrueCondition) {
|
auto i = 0;
|
auto resultFut = AsyncTry([&] { ++i; })
|