From: Guillaume Cottenceau <gc@mnc.ch>
To: pgsql-jdbc@postgresql.org
Subject: NPE sent by driver when ResultSet's connection is closed, proposed patch
Date: 17 Dec 2004 10:43:29 +0100
Message-ID: <87k6rhl0ou.fsf@meuh.mnc.ch> (raw)
Hi,
I am having some trouble with java.sql.ResultSet being "closed"
when it should not in our application, and it has shown what is I
think a bug in the driver.
When the ResultSet is "closed", and I fire #next, I receive an
SQLException complaining that the connection is closed. But when
I fire #first, I receive a NullPointerException from driver code,
which is incorrect since java.sql.ResultSet states that #first
only throws SQLException. I have seen this problem in stable
version but have verified in CVS code that it should still
happen, since the attribute "rows" is not tested for null value,
as is done in #next.
Follows a proposed patch, however from a quick reading of the
code I think there is more missing (#afterLast, #beforeFirst..)
inline patch 1: ./AbstractJdbc2ResultSet.java (+3/-0 lines) download inline-1.patch--- postgres/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java 2004-11-19 04:18:51.000000000 +0100+++ ./AbstractJdbc2ResultSet.java 2004-12-17 10:30:37.062117093 +0100@@ -257,6 +257,9 @@
public boolean first() throws SQLException
{
+ if (rows == null)+ throw new PSQLException(GT.tr("This ResultSet is closed."), PSQLState.CONNECTION_DOES_NOT_EXIST);+
checkScrollable();
if (rows.size() <= 0)
--
Guillaume Cottenceau
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: gc@mnc.ch
Subject: Re: NPE sent by driver when ResultSet's connection is closed, proposed patch
In-Reply-To: <87k6rhl0ou.fsf@meuh.mnc.ch>
References: <87k6rhl0ou.fsf@meuh.mnc.ch>
* 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