X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 75FA09DC851 for ; Thu, 9 Feb 2006 12:29:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76180-05 for ; Thu, 9 Feb 2006 12:29:38 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by postgresql.org (Postfix) with SMTP id DE63A9DC81C for ; Thu, 9 Feb 2006 12:29:37 -0400 (AST) Received: (qmail 2966 invoked by uid 1112); 9 Feb 2006 16:29:37 -0000 Date: Thu, 9 Feb 2006 11:29:37 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: till toenges cc: pgsql-jdbc@postgresql.org Subject: Re: Bug in TypeInfoCache causes getObject to fail In-Reply-To: <43EB1EA4.4000506@kyon.de> Message-ID: References: <43EB1EA4.4000506@kyon.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.094 required=5 tests=[AWL=0.094] X-Spam-Score: 0.094 X-Spam-Level: X-Archive-Number: 200602/69 X-Sequence-Number: 14666 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