Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X2RhA-0003H3-2T for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Jul 2014 21:04:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X2Rh9-00025F-JA for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Jul 2014 21:03:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X2Rh8-000257-RI for pgsql-jdbc@postgresql.org; Wed, 02 Jul 2014 21:03:58 +0000 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X2Rh5-0004lc-Rr for pgsql-jdbc@postgresql.org; Wed, 02 Jul 2014 21:03:56 +0000 Received: by mail-pd0-f181.google.com with SMTP id v10so12551951pde.12 for ; Wed, 02 Jul 2014 14:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=vVrAGidxeA1mmKYaIzPUcOzHQnPoM1YaKFIeMNuRhsI=; b=fP1gdSBXByr7VnDy2Q3usItmghNKWKdkfsAC8uxfkeGjqhM6mPgMOQm9L4wJaRZ6Xz 3feCYz2IQr4wHGKIGRl5FrGgaLNWoYHpXb0ayiDtv46qkEx0czLLwSpbT8TrnrGwrosy VItOJWQsBQIL+ytRvmQ0lF47mjlMFf0msk3/Pe4kHw1eii6o+7SozyXCR4Wxe3Zv1XKU 8Iy/nlJIKtCStWvbDio0CCNucFnZyvMTt9tY2TGPTb8U5PJGZ/PcM1nf68qmtbafi23W 9HTufgPzT7laBsjrrBMmlGbPbJow4qv8HVL3Zuk/QgUWNXoFq3lDY86DFRkFqa7oSh+2 B0Lw== X-Received: by 10.66.141.165 with SMTP id rp5mr395051pab.90.1404335033865; Wed, 02 Jul 2014 14:03:53 -0700 (PDT) Received: from [10.222.0.161] ([64.125.71.142]) by mx.google.com with ESMTPSA id qv9sm38400601pbc.71.2014.07.02.14.03.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 14:03:53 -0700 (PDT) Message-ID: <53B473B7.2020803@gmail.com> Date: Wed, 02 Jul 2014 14:03:51 -0700 From: Elizabeth Chatman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs References: <53B46704.7060805@gmail.com> In-Reply-To: <53B46704.7060805@gmail.com> Content-Type: multipart/mixed; boundary="------------000305090601080003040502" X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------000305090601080003040502 Content-Type: multipart/alternative; boundary="------------010104070706010404090704" --------------010104070706010404090704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Proposed patch attached, to avoid adding null keys to the cache. - Elizabeth Chatman On 07/02/2014 01:09 PM, Elizabeth Chatman wrote: > I am encountering an intermittent NullPointerException when I call > connection.getMetaData().getUDTs(). I traced it to a null key in > TypeInfoCache._pgNameToSQLType, inserted by a previous call to > connection.getMetaData().getTypeInfo(), as a result of a lingering > temporary table. > > I attached a basic reproducer. For me it usually fails on the second > or third time through the loop. > > I am using the latest driver (9.3-1101-jdbc41), and I get the same > results running against 9.2 and 9.3 servers. > > - Elizabeth Chatman --------------010104070706010404090704 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Proposed patch attached, to avoid adding null keys to the cache.
- Elizabeth Chatman

On 07/02/2014 01:09 PM, Elizabeth Chatman wrote:
I am encountering an intermittent NullPointerException when I call connection.getMetaData().getUDTs(). I traced it to a null key in TypeInfoCache._pgNameToSQLType, inserted by a previous call to connection.getMetaData().getTypeInfo(), as a result of a lingering temporary table.

I attached a basic reproducer. For me it usually fails on the second or third time through the loop.

I am using the latest driver (9.3-1101-jdbc41), and I get the same results running against 9.2 and 9.3 servers.

- Elizabeth Chatman

--------------010104070706010404090704-- --------------000305090601080003040502 Content-Type: text/x-patch; name="TypeInfoCache.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="TypeInfoCache.patch" diff --git a/org/postgresql/jdbc2/TypeInfoCache.java b/org/postgresql/jdbc2/TypeInfoCache.java index 59a44c5..be5a012 100644 --- a/org/postgresql/jdbc2/TypeInfoCache.java +++ b/org/postgresql/jdbc2/TypeInfoCache.java @@ -241,7 +241,9 @@ public class TypeInfoCache implements TypeInfo { } rs.close(); - _pgNameToSQLType.put(pgTypeName, type); + if(pgTypeName != null) { + _pgNameToSQLType.put(pgTypeName, type); + } return type.intValue(); } --------------000305090601080003040502 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --------------000305090601080003040502--