pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedNPE sent by driver when ResultSet's connection is closed, proposed patch
2+ messages / 2 participants
[nested] [flat]
* NPE sent by driver when ResultSet's connection is closed, proposed patch
@ 2004-12-17 09:43 Guillaume Cottenceau <gc@mnc.ch>
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Cottenceau @ 2004-12-17 09:43 UTC (permalink / raw)
To: pgsql-jdbc
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: NPE sent by driver when ResultSet's connection is closed,
@ 2004-12-17 21:36 Kris Jurka <books@ejurka.com>
parent: Guillaume Cottenceau <gc@mnc.ch>
0 siblings, 0 replies; 2+ messages in thread
From: Kris Jurka @ 2004-12-17 21:36 UTC (permalink / raw)
To: Guillaume Cottenceau <gc@mnc.ch>; +Cc: pgsql-jdbc
On Fri, 17 Dec 2004, Guillaume Cottenceau wrote:
> 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.
Well, no one really declares throwing NPE because it's a RuntimeException,
but yes this is a bug and has been on the todo list for a while. Your
complaint has motivated me to do this and I've committed a hopefully
complete fix to this whole class of problems to the cvs repository.
Kris Jurka
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-12-17 21:36 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-17 09:43 NPE sent by driver when ResultSet's connection is closed, proposed patch Guillaume Cottenceau <gc@mnc.ch>
2004-12-17 21:36 ` Re: NPE sent by driver when ResultSet's connection is closed, Kris Jurka <books@ejurka.com>
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