From: | Tarjei Skorgenes <tarjei(dot)skorgenes(at)himolde(dot)no> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Cc: | Barry Lind <blind(at)xythos(dot)com> |
Subject: | Patch for possible PSQLException bug |
Date: | 2003-03-02 12:24:06 |
Message-ID: | 20030302122406.GG9079@sfrn-spcb18.himolde.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
After trying the new SSL functionality in the driver I stumbled upon the
following bug in PSQLException:
The no-parameter constructor of SQLException is called at the beginning of every
constructor in PSQLException. This can lead to a NullPointerException
if the user has set the loglevel to something > 0. When loglevel is
greater than 0 Driver.java calls DriverManager.setLogWriter(System.out).
All messages are printed to this logwriter. The no-parameter
constructor for SQLException prints the stacktrace of the current
exception to this logwriter whenever it is instantiated. Since
PSQLException inherits from SQLException the toString method of
PSQLException will return null since the translate method won't have
been called yet.
As a consequence an attempt will be made to print the return value from
toString() to the logwriter and this will result in a
NullPointerException being thrown. This might be categorized as a bug in
PrintWriter but any user trying to use the jdbc driver with loglevel > 0
might stumble upon it.
I've cooked up a JUnit testcase that checks for the error and I've made a
simple one-liner patch to get toString() to return "" if message hasn't been
initialized yet.
--
Tarjei Skorgenes
tarjei(dot)skorgenes(at)himolde(dot)no
Attachment | Content-Type | Size |
---|---|---|
bug.diff | text/plain | 399 bytes |
test-util.diff | text/plain | 4.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Uwe Kubosch | 2003-03-02 12:52:19 | binary data |
Previous Message | Paul Sorenson | 2003-03-01 00:27:50 | Re: Can't update rows in tables qualified with schema names |