From: Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
Date: Wed, 02 Jul 2014 13:09:40 -0700
Message-ID: <53B46704.7060805@gmail.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
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
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbcAttachments:TestGetUDTs.java (text/x-java, 1.1K) download
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
* @author echatman
*/
public class TestGetUDTs {
private static final String HOST = "localhost";
private static final int PORT = 5432;
private static final String DBNAME = "test";
private static final String USERNAME = "postgres";
private static final String PASSWORD = "";
private static final String URL = "jdbc:postgresql://"+HOST+":"+PORT+"/"+DBNAME;
public static void main(String[] args) throws Exception {
for(int i = 0; i < 10; i++) {
System.out.println(i);
Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TEMPORARY TABLE temp_"+i+" ();");
stmt.close();
connection.close();
connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
connection.getMetaData().getTypeInfo();
connection.getMetaData().getUDTs(null, "information_schema", "%", null);
connection.close();
}
}
}
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: elizabeth.a.chatman@gmail.com
Subject: Re: NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
In-Reply-To: <53B46704.7060805@gmail.com>
References: <53B46704.7060805@gmail.com>
* 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