From derby-dev-return-1584-apmail-db-derby-dev-archive=db.apache.org@db.apache.org Fri Jan 07 14:23:39 2005 Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 12266 invoked from network); 7 Jan 2005 14:23:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Jan 2005 14:23:39 -0000 Received: (qmail 60038 invoked by uid 500); 7 Jan 2005 14:23:38 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 59906 invoked by uid 500); 7 Jan 2005 14:23:37 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 59891 invoked by uid 99); 7 Jan 2005 14:23:37 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from e2.ny.us.ibm.com (HELO e2.ny.us.ibm.com) (32.97.182.142) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 07 Jan 2005 06:23:36 -0800 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e2.ny.us.ibm.com (8.12.10/8.12.10) with ESMTP id j07ENY9W027129 for ; Fri, 7 Jan 2005 09:23:34 -0500 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j07ENXaI256374 for ; Fri, 7 Jan 2005 09:23:33 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j07ENXgi031142 for ; Fri, 7 Jan 2005 09:23:33 -0500 Received: from debrunners.com (sig-9-48-118-64.mts.ibm.com [9.48.118.64]) by d01av03.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j07ENWgH031109 for ; Fri, 7 Jan 2005 09:23:33 -0500 Message-ID: <41DE9B49.4080309@debrunners.com> Date: Fri, 07 Jan 2005 06:23:05 -0800 From: Daniel John Debrunner User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4.1) Gecko/20031008 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Development Subject: Re: [jira] Commented: (DERBY-95) NPE when passing in url instead of database name to EmbeddedXADataSource References: <789965253.1105079173074.JavaMail.jira@ajax.apache.org> In-Reply-To: <789965253.1105079173074.JavaMail.jira@ajax.apache.org> X-Enigmail-Version: 0.76.8.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Shreyas Kaushik (JIRA) wrote: > [ http://issues.apache.org/jira/browse/DERBY-95?page=comments#action_57371 ] > > Shreyas Kaushik commented on DERBY-95: > -------------------------------------- > > The EmbeddedXADataSource.getConnection() does not return null, the call to this methods throws a NPE because the EmbeddedDriver.getConnection() returns null and an attempt is made to close the connection assuming that it will not return a null. I was basing my comments on your first comment in Derby-95 that says the EmbeddedXADataSource.getConnection() is returning null and the NPE happens when the getConnection().close() is executed. [by EmbeddedXADataSource.getConnection(), I mean the getConnection() method that EmbeddedXADataSource inherits.] Is this not the case? > Here an NPE needs to be caught becuase the EmbeddedDriver.getConnection can return null when > > 1) A database does not exist ( Url is valid Is this true? I thought an exception was thrown if the database could not be found. > 2) The Url is invalid ( which is the case here ) > > After this NPE is caught we need to throw a SQLException saying that the DB doesn't exist. > > I hope everyone is ok with this approach, please comment and kindly vote for the suggested fix. In general code in Derby does not catch NPEs, but avoids them with checks to see a reference is null before using it. Dan. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFB3ptJIv0S4qsbfuQRAoYPAJjgw0KtpMyE8Nj6Y6EgBmEujCJKAKDf6tpD 4yFQybYzB6PBc8L7TUAClQ== =NwGv -----END PGP SIGNATURE-----