8000 Don't leak connections when authentication fails. · emrul/postgres-async-driver@769f569 · GitHub
[go: up one dir, main page]

Skip to content

Commit 769f569

Browse files
committed
Don't leak connections when authentication fails.
1 parent cd7b7c1 commit 769f569

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/github/pgasync/impl/PgConnectionPool.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public Observable<Connection> getConnection() {
169169

170170
new PgConnection(openStream(address), dataConverter)
171171
.connect(username, password, database)
172+
.doOnError(__ -> release(null))
172173
.subscribe(subscriber);
173174
} finally {
174175
if (locked) {
@@ -200,7 +201,7 @@ private void releaseIfNotPipelining(Connection connection) {
200201

201202
@Override
202203
public void release(Connection connection) {
203-
boolean failed = !((PgConnection) connection).isConnected();
204+
boolean failed = connection == null || !((PgConnection) connection).isConnected();
204205

205206
Subscriber<? super Connection> next;
206207
lock.lock();

0 commit comments

Comments
 (0)
0