Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TOaft-00018q-4v for pgsql-jdbc@postgresql.org; Wed, 17 Oct 2012 20:57:09 +0000 Received: from news.hub.org ([200.46.204.72]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TOafn-0002VF-8B for pgsql-jdbc@postgresql.org; Wed, 17 Oct 2012 20:57:08 +0000 Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.5/8.14.5) with ESMTP id q9HKv0gt004467 for ; Wed, 17 Oct 2012 17:57:00 -0300 (ADT) (envelope-from news@news.hub.org) Received: from news.hub.org (news@localhost) by news.hub.org (8.14.5/8.14.5/Submit) with NNTP id q9HKk8HX098099 for pgsql-jdbc@postgresql.org; Wed, 17 Oct 2012 17:46:08 -0300 (ADT) (envelope-from news) Received: by 10.224.223.14 with SMTP id ii14mr12468338qab.3.1350506767712; Wed, 17 Oct 2012 13:46:07 -0700 (PDT) Received: by 10.52.66.235 with SMTP id i11mr3268281vdt.7.1350506767688; Wed, 17 Oct 2012 13:46:07 -0700 (PDT) X-Newsgroups: pgsql.interfaces.jdbc Date: Wed, 17 Oct 2012 13:46:07 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=64.125.235.2; posting-account=7GHbwQoAAAASrOQWIMsSRsYh0K75f89B User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com> Subject: PGCopyOutputStream Doesn't Hold Connection From: Michael Daines Injection-Date: Wed, 17 Oct 2012 20:46:07 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable To: pgsql-jdbc@postgresql.org X-Pg-Spam-Score: -1.4 (-) X-Archive-Number: 201210/74 X-Sequence-Number: 23398 Something that might be worth noting (in documentation?) is that the PGCopy= OutputStream class doesn't hold a reference to its Connection. We came across this because we were trying to keep our DB code separate fro= m the logic, and we started getting errors writing to the PGCopyOutputStrea= m. We banged our heads against it for a while before realizing that the Con= nection was getting garbage collected while we were still writing to it. Our solution was to extend PGCopyOutputStream and hold on to the Connection= in that child class, also giving it responsibility for closing it. I'm not sure I would call this a defect, but it is something I wanted to sh= are with other people, since we couldn't find anything in our searches on t= he problem while we were having it.