Re: Bug in TypeInfoCache causes getObject to fail

From: Kris Jurka <books(at)ejurka(dot)com>
To: till toenges <tt(at)kyon(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bug in TypeInfoCache causes getObject to fail
Date: 2006-02-09 16:29:37
Message-ID: Pine.BSO.4.61.0602091120040.31185@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thu, 9 Feb 2006, till toenges wrote:

> i have found a race condition in org.postgresql.jdbc2.TypeInfoCache. A Map is
> created as a static member, but reinitialized for every new instance of
> TypeInfoCache. That causes a race condition in ResultSet.getObject(...),
> which then returns PGobject instead of the correct type. Probably causes
> other problems as well. I have attached a test case. The test case works best
> on smp machines (tested on a 4 way), where it fails almost every time.

Nice work. Applied to 8.1 and HEAD.

> Also the maps in TypeInfoCache are created as synchronizedMaps, which is
> unneccessary, slow and a potential source for further side effects. I have
> removed that as well, and attached a fixed version of TypeInfoCache from
> build 404. I leave the application of the fixes to the current and other
> versions as an exercise to the committer ;-)

Actually it is necessary for the maps to be synchronized because at any
time a client may call PGConnection.addDataType which will modify the
maps.

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2006-02-09 17:31:51 New releases for 8.0, 8.1, and 8.2dev
Previous Message Kevin Grittner 2006-02-09 16:21:37 Re: PGobject returned from ResultSet.getObject