X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 94C843CC24A for ; Fri, 17 Dec 2004 09:43:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 67222-01 for ; Fri, 17 Dec 2004 09:43:37 +0000 (GMT) Received: from mnc.ch (unknown [212.23.250.43]) by svr1.postgresql.org (Postfix) with ESMTP id 9F5283CC227 for ; Fri, 17 Dec 2004 09:43:37 +0000 (GMT) Received: (qmail 6027 invoked from network); 17 Dec 2004 10:43:35 +0100 Received: from 62-2-77-204.business.cablecom.ch (HELO meuh.mnc.ch) (62.2.77.204) by www.mnc.ch.com with SMTP; 17 Dec 2004 10:43:35 +0100 Received: by meuh.mnc.ch (Postfix, from userid 1000) id A815023F08B; Fri, 17 Dec 2004 10:43:29 +0100 (CET) To: pgsql-jdbc@postgresql.org Subject: NPE sent by driver when ResultSet's connection is closed, proposed patch From: Guillaume Cottenceau Date: 17 Dec 2004 10:43:29 +0100 Message-ID: <87k6rhl0ou.fsf@meuh.mnc.ch> Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/133 X-Sequence-Number: 11799 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..) --- 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