Обсуждение: PGCopyOutputStream Doesn't Hold Connection

Поиск
Список
Период
Сортировка

PGCopyOutputStream Doesn't Hold Connection

От
Michael Daines
Дата:
Something that might be worth noting (in documentation?) is that the PGCopyOutputStream class doesn't hold a reference
toits Connection. 

We came across this because we were trying to keep our DB code separate from the logic, and we started getting errors
writingto the PGCopyOutputStream. We banged our heads against it for a while before realizing that the Connection was
gettinggarbage 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
responsibilityfor 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
findanything in our searches on the problem while we were having it.