Bug #12362 No stack trace when exception is thrown in custom logger
Submitted: 3 Aug 2005 23:31 Modified: 4 Sep 2009 13:23
Reporter: Boris Burtin Email Updates:
Status: Verified Impact on me:
Category:Connector / J Severity:S4 (Feature request)
Version:3.1.10 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any

[3 Aug 2005 23:31] Boris Burtin
This one's pretty edge-casy, but I think it should be fixed because it was a pain to track down.

I'm using a custom logger with the "logger" connection property.  I had a bug in my logger code which threw a NullPointerException.  When this happens, the driver creates a new SQLException based on the NPE, but the stack trace from the NPE is thrown away, making it impossible to know where the NPE happened:

} catch (Exception ex) {
	SQLException sqlEx = new SQLException(ex.toString(),

At first I didn't even realize that it was a bug in my code, since I had no context.  I tried debugging the driver code in Eclipse, but for some reason the debugger didn't let me inspect the contents of the Exception object.  To figure out what was going wrong, I had to hack the ServerPreparedStatement code so that it logs the stack trace.

How to repeat:
Create a custom logger that throws an NPE and pass its class name to the "logger" property.

Suggested fix:
Either log the stack trace or pass the stack trace to the new SQLException object, rather than just calling ex.toString().
[1 Sep 2009 10:32] Tonci Grgin
Hi Boris.

Can you please tell me if the problem is still present in c/J 5.1?
[1 Sep 2009 17:29] Boris Burtin
Sorry, I don't know.  I'm no longer using the custom logger feature.
[2 Sep 2009 7:09] Tonci Grgin
No problem Boris, will consult others and see what's to be done.
In any case, I apologize for the delay in processing, somehow I missed this report (and several others).
[4 Sep 2009 13:23] Tonci Grgin
This seems still to be present, so verified as described.