Re: org.postgresql.Driver not thread-safe

From: Kris Jurka <books(at)ejurka(dot)com>
To: Karl von Randow <karl(at)xk72(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: org.postgresql.Driver not thread-safe
Date: 2003-11-16 01:17:12
Message-ID: Pine.LNX.4.33.0311152014010.14784-200000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Sun, 16 Nov 2003, Karl von Randow wrote:

> Hi all,
>
> It seems that org.postgresql.Driver isn't thread safe, as it stores details
> from the connection URL to the connect method in an instance variable
> "props" - and there is no synchronisation. The DriverManager
> (java.sql.DriverManager) returns the same instance of the
> org.postgresql.Driver to each getDriver(String url ) method and probably all
> of the others. Hence the problem with multiple threads connecting at the
> same time, the threads obtain the same Driver instance and the connection
> details from different threads can become muddled.

Yes, good catch.

> I've made a simple patch against the REL_7_3_STABLE branch of Driver.java.in
> which removes the use of the instance variable. I'm going to test this patch
> immediately.

In the future when submitting patches please use a context diff (-c)
format and attach it to the email so it avoids line wrapping.

Here is the corresponding patch against cvs tip which should also apply
cleanly to the 7.4 branch.

Kris Jurka

Attachment Content-Type Size
driver.threadsafe.patch text/plain 4.0 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Karl von Randow 2003-11-16 02:22:26 Re: org.postgresql.Driver not thread-safe
Previous Message Karl von Randow 2003-11-15 22:35:00 org.postgresql.Driver not thread-safe