Thread: [pgjdbc/pgjdbc] 194411: fix: Connection leak in ConnectionFactoryImpl#tryC...

[pgjdbc/pgjdbc] 194411: fix: Connection leak in ConnectionFactoryImpl#tryC...

From
Michał Wyrzykowski
Date:
  Branch: refs/heads/master
  Home:   https://github.com/pgjdbc/pgjdbc
  Commit: 194411ab82c495d0a7997d0f9831c36c63b6bcb4
      https://github.com/pgjdbc/pgjdbc/commit/194411ab82c495d0a7997d0f9831c36c63b6bcb4
  Author: Michał Wyrzykowski <w.michal1@gmail.com>
  Date:   2021-11-24 (Wed, 24 Nov 2021)

  Changed paths:
    M pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java

  Log Message:
  -----------
  fix: Connection leak in ConnectionFactoryImpl#tryConnect #2350 (#2351)

When `ConnectionFactoryImpl#tryConnect` fails with an exception,
a newly created PGStream is left without closing it. The finalizer
handles the close, so it's not a problem most of the time.
But Finalizer has no guarantees on the time when it'll close
the resource. The resource may hang open for a longer period.

After the change PGStream is closed just before losing the reference.