From 1e4c08b4eb8965a427d317c3429b5acd579bef22 Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Thu, 30 Nov 2023 12:46:24 +0100 Subject: [PATCH] fix(MongoDB): PooledConnection shall have a pointer to a ConnectionPool instead of a reference (fixes clang warning) #4276 --- .../include/Poco/MongoDB/PoolableConnectionFactory.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h b/MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h index 10d089517..26c485eab 100644 --- a/MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h +++ b/MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h @@ -89,11 +89,13 @@ namespace MongoDB { class PooledConnection /// Helper class for borrowing and returning a connection automatically from a pool. + /// Note that the connection pool is not expected to be deleted during the lifetime + /// of an instance of PooledConnection. { public: - PooledConnection(Poco::ObjectPool& pool) : _pool(pool) + PooledConnection(Poco::ObjectPool& pool) : _pool(&pool) { - _connection = _pool.borrowObject(); + _connection = _pool->borrowObject(); } virtual ~PooledConnection() @@ -102,7 +104,7 @@ public: { if (_connection) { - _pool.returnObject(_connection); + _pool->returnObject(_connection); } } catch (...) @@ -125,7 +127,7 @@ public: PooledConnection& operator=(PooledConnection&&) = default; private: - Poco::ObjectPool& _pool; + Poco::ObjectPool* _pool; Connection::Ptr _connection; };