Skip to content

Commit

Permalink
fix(MongoDB): PooledConnection shall have a pointer to a ConnectionPo…
Browse files Browse the repository at this point in the history
…ol instead of a reference (fixes clang warning) #4276
  • Loading branch information
matejk committed Nov 30, 2023
1 parent 4cfa96c commit 1e4c08b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions MongoDB/include/Poco/MongoDB/PoolableConnectionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Connection, Connection::Ptr>& pool) : _pool(pool)
PooledConnection(Poco::ObjectPool<Connection, Connection::Ptr>& pool) : _pool(&pool)
{
_connection = _pool.borrowObject();
_connection = _pool->borrowObject();
}

virtual ~PooledConnection()
Expand All @@ -102,7 +104,7 @@ class PooledConnection
{
if (_connection)
{
_pool.returnObject(_connection);
_pool->returnObject(_connection);
}
}
catch (...)
Expand All @@ -125,7 +127,7 @@ class PooledConnection
PooledConnection& operator=(PooledConnection&&) = default;

private:
Poco::ObjectPool<Connection, Connection::Ptr>& _pool;
Poco::ObjectPool<Connection, Connection::Ptr>* _pool;
Connection::Ptr _connection;
};

Expand Down

0 comments on commit 1e4c08b

Please sign in to comment.