BUG #4598: flaw in hashCode() method implementation of Connection class in postgresql-8.3-604.jdbc3.jar

From: "Radu Buzila" <radu(at)buzila(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4598: flaw in hashCode() method implementation of Connection class in postgresql-8.3-604.jdbc3.jar
Date: 2008-12-30 22:49:33
Message-ID: 200812302249.mBUMnXsv049575@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4598
Logged by: Radu Buzila
Email address: radu(at)buzila(dot)com
PostgreSQL version: 8.3
Operating system: Mac OS X (OS not relevant, I'm using the thin JDBC
driver: postgresql-8.3-604.jdbc3.jar)
Description: flaw in hashCode() method implementation of Connection
class in postgresql-8.3-604.jdbc3.jar
Details:

This issue occurs when using the 8.3 thin driver
(postgresql-8.3-604.jdbc3.jar):
I have a hash that uses connection objects as keys (the hash keeps some some
transaction state data). Adding to the hash works fine but when checking if
the hash has a certain key a null pointer exception is thrown. The key used
is a not-null Connection object
(org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection) and the hash is
not empty.

A printout of the hash looks like this:
{Pooled connection wrapping physical connection null=[], Pooled connection
wrapping physical connection null=[], Pooled connection wrapping physical
connection null=[]}
(my hash values are empty ArrayList objects (not null) at this point and the
keys are Connection objects).

When executing either
theHash.containsKey(someKey)
or
theHash.remove(someKey)
(where someKey is an instance of
org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection) a
NullPoinerException is thrown and the stack trace shows:
... at
org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$ConnectionHandler.in
voke(AbstractJdbc23PooledConnection.java:275)
at $Proxy0.hashCode(Unknown Source)
...

My immediate guess is that the method overriding Object.hashCode() is not
implemented properly and it throws a null pointer exception either in all
cases or only when the physical connection wrapped by the pooled connection
object is closed.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2008-12-30 22:50:53 Re: BUG #3818: Cross compilation problems
Previous Message Vincent Predoehl 2008-12-30 22:02:59 Re: Bug