BUG org.postgresql.Driver.connect() distorts InterruptedException

From: Andreas Rudolph <andreas(dot)rudolph(at)spontech-spine(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: BUG org.postgresql.Driver.connect() distorts InterruptedException
Date: 2013-08-09 08:35:53
Message-ID: F6FBC511-F1BA-4ED7-B0E1-F3EB702A3077@spontech-spine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi there!

+ JDBC driver build number
9.1-903

+ Server
PostgreSQL 9.1.9 on i686-pc-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 32-bit

+ Error message / stack trace

org.postgresql.util.PSQLException: Beim Verbindungsversuch trat eine Unterbrechung auf.
at org.postgresql.Driver$ConnectThread.getResult(Driver.java:365)
at org.postgresql.Driver.connect(Driver.java:269)

+ Description

Recently I discovered this problem because it prevents to tell other SQLExceptions and interruption apart (in the exception handlers). After examining the source of org.postgresql.Driver I noticed that org.postgresql.Driver$ConnectThread.getResult catches InterruptedException and throws a org.postgresql.util.PSQLException instead BUT without supplying the InterruptedException as the cause (exception chaining) and without resetting the interrupted flag via Thread.currentThread().interrupt() (SQL error code / SQL state is unspecific, too). Please note that this behavior is present in 9.2-1003, too.

Therefore I suggest that the handling of InterruptedException should be changed so it becomes more interoperable with client code that needs to handle SQLExceptions differently from thread interruption -- in a concurrent environment an already scheduled database query may become obsolete before it finishes because another query may be needed for example because of user intervention.

Greetings

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Paquier 2013-08-11 22:35:55 Some link errors on jdbc.postgresql.org
Previous Message Alexandre Gattiker 2013-08-06 20:55:07 Re: JDBC driver 9.2 sending arbitrary timezone