diff --git a/CHANGELOG.md b/CHANGELOG.md index ceec3ff..6a23eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 3.5.3 - New typed exceptions: `UniqueViolationException`, `ForeignKeyViolationException`. [#416](https://github.com/isoos/postgresql-dart/pull/416) by [hurrba](https://github.com/hurrba) +- Fix: don't reuse pool connections that are closed/closing. [#417](https://github.com/isoos/postgresql-dart/pull/417) by [davidmartos96](https://github.com/davidmartos96) ## 3.5.2 diff --git a/lib/src/pool/pool_impl.dart b/lib/src/pool/pool_impl.dart index c986e34..e70ee0a 100644 --- a/lib/src/pool/pool_impl.dart +++ b/lib/src/pool/pool_impl.dart @@ -232,7 +232,7 @@ class _PoolConnection implements Connection { this._pool, this._endpoint, this._connectionSettings, this._connection); bool _mayReuse(Endpoint endpoint, ResolvedConnectionSettings settings) { - if (_isInUse || endpoint != _endpoint || _isExpired()) { + if (_isInUse || endpoint != _endpoint || _isExpired() || !isOpen) { return false; } if (!_connectionSettings.isMatchingConnection(settings)) {