pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
3+ messages / 2 participants
[nested] [flat]

* NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
@ 2014-07-02 20:09  Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Elizabeth Chatman @ 2014-07-02 20:09 UTC (permalink / raw)
  To: pgsql-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-jdbc

Attachments:

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(); } } }
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
@ 2014-07-02 21:03  Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
  parent: Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Elizabeth Chatman @ 2014-07-02 21:03 UTC (permalink / raw)
  To: pgsql-jdbc

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 

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

Attachments:

TypeInfoCache.patch (text/x-patch, 508B) download 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(); }
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs
@ 2014-07-04 10:19  Dave Cramer <pg@fastcrypt.com>
  parent: Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Dave Cramer @ 2014-07-04 10:19 UTC (permalink / raw)
  To: Elizabeth Chatman <elizabeth.a.chatman@gmail.com>; +Cc: pgsql-jdbc

Thanks !

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On 2 July 2014 17:03, Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
wrote:

>  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
>
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2014-07-04 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02 20:09 NullPointerException in AbstractJdbc2DatabaseMetaData.getUDTs Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
2014-07-02 21:03 ` Elizabeth Chatman <elizabeth.a.chatman@gmail.com>
2014-07-04 10:19   ` Dave Cramer <pg@fastcrypt.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