Bug in TypeInfoCache causes getObject to fail

From: till toenges <tt(at)kyon(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Bug in TypeInfoCache causes getObject to fail
Date: 2006-02-09 10:51:16
Message-ID: 43EB1EA4.4000506@kyon.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

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.

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 ;-)

Have a nice day...

Till

Attachment Content-Type Size
TypeInfoCache.java.diff text/plain 1.4 KB
PGObjectTest.java text/plain 5.1 KB
TypeInfoCache.java text/plain 7.5 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Grittner 2006-02-09 16:21:37 Re: PGobject returned from ResultSet.getObject
Previous Message Kris Jurka 2006-02-09 08:26:15 Re: Full XA availability ?