Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpvhY-0004JS-Rq for pgsql-jdbc@arkaria.postgresql.org; Wed, 24 Nov 2021 17:04:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpvhW-0005nm-Qy for pgsql-jdbc@arkaria.postgresql.org; Wed, 24 Nov 2021 17:04:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpvhW-0005nc-HL for pgsql-jdbc@lists.postgresql.org; Wed, 24 Nov 2021 17:04:54 +0000 Received: from out-20.smtp.github.com ([192.30.252.203]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpvhS-0001Jq-TQ for pgsql-jdbc@lists.postgresql.org; Wed, 24 Nov 2021 17:04:53 +0000 Received: from github.com (hubbernetes-node-eaf8ba6.va3-iad.github.net [10.48.124.52]) by smtp.github.com (Postfix) with ESMTPA id 630F3E04DA for ; Wed, 24 Nov 2021 09:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1637773489; bh=hTuE9pbhbCp5W+3xs4FuGpGptyZWhaSMGTC+MdjuWOM=; h=Date:From:To:Subject:From; b=gp62j0krY0gaI6mwUzxo6vFIocUGVovG4/8wKQDO+LTahG1pkHmPUbOFJAYjcCbjA eQrHQnqv592cJT6rWfO1vLkUKD0YBZ4Lxhh8qWiDb54Tz4PM8uU1zW8VbCPcpSPOoX tC6zYUvOheYBpIghWwTCgwlEJjrqNCV5oAr3hql4= Date: Wed, 24 Nov 2021 09:04:49 -0800 From: =?UTF-8?B?TWljaGHFgiBXeXJ6eWtvd3NraQ==?= To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] 194411: fix: Connection leak in ConnectionFactoryImpl#tryC... Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Branch: refs/heads/master=0D Home: https://github.com/pgjdbc/pgjdbc=0D Commit: 194411ab82c495d0a7997d0f9831c36c63b6bcb4=0D https://github.com/pgjdbc/pgjdbc/commit/194411ab82c495d0a7997d0f983= 1c36c63b6bcb4=0D Author: Micha=C5=82 Wyrzykowski =0D Date: 2021-11-24 (Wed, 24 Nov 2021)=0D =0D Changed paths:=0D M pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.j= ava=0D =0D Log Message:=0D -----------=0D fix: Connection leak in ConnectionFactoryImpl#tryConnect #2350 (#2351)=0D= =0D When `ConnectionFactoryImpl#tryConnect` fails with an exception,=0D a newly created PGStream is left without closing it. The finalizer=0D handles the close, so it's not a problem most of the time.=0D But Finalizer has no guarantees on the time when it'll close=0D the resource. The resource may hang open for a longer period.=0D =0D After the change PGStream is closed just before losing the reference.=0D =0D =0D