Re: Bug in TypeInfoCache causes getObject to fail - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Bug in TypeInfoCache causes getObject to fail
Date
Msg-id Pine.BSO.4.61.0602091120040.31185@leary.csoft.net
Whole thread Raw
In response to Bug in TypeInfoCache causes getObject to fail  (till toenges <tt@kyon.de>)
Responses Re: Bug in TypeInfoCache causes getObject to fail  (till toenges <tt@kyon.de>)
List 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

pgsql-jdbc by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: PGobject returned from ResultSet.getObject
Next
From: Kris Jurka
Date:
Subject: New releases for 8.0, 8.1, and 8.2dev