pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Daines <ax2groin@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: PGCopyOutputStream Doesn't Hold Connection
Date: Wed, 17 Oct 2012 13:46:07 -0700 (PDT)
Message-ID: <461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com> (raw)

Something that might be worth noting (in documentation?) is that the PGCopyOutputStream class doesn't hold a reference to its Connection.

We came across this because we were trying to keep our DB code separate from the logic, and we started getting errors writing to the PGCopyOutputStream. We banged our heads against it for a while before realizing that the Connection 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 share with other people, since we couldn't find anything in our searches on the problem while we were having it.




Message-ID: <461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com>
Permalink:  ../461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com/
Also on:    postgresql.org/message-id/461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: ax2groin@gmail.com
  Subject: Re: PGCopyOutputStream Doesn't Hold Connection
  In-Reply-To: <461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com>
  References: <461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox