Issue Details (XML | Word | Printable)

Key: DERBY-3307
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Knut Anders Hatlen
Reporter: Kristian Waagan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

NPE in PooledConnction event notification handling if a null listener is added

Created: 09/Jan/08 10:59 AM   Updated: 04/May/09 06:22 PM
Return to search
Component/s: JDBC
Affects Version/s: 10.3.2.1, 10.4.1.3
Fix Version/s: 10.4.2.0, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works d3307.diff 2008-06-10 09:36 AM Knut Anders Hatlen 4 kB
File Licensed for inclusion in ASF works derby-3307-1a-test_repro.diff 2008-01-09 11:01 AM Kristian Waagan 1 kB
Issue Links:
Incorporates
 

Resolution Date: 10/Jun/08 01:09 PM


 Description  « Hide
If a null reference is passed in to one of the ClientPooledConnection.addXEventListener, a NPE will be thrown if an event occurs.
I will attach a simple repro as a patch to the test jdbc4.StatementEventsTests. I believe the situation is the same for connection event listeners.

I have found no information in the specs regarding null listeners, but I assume it would be okay to ignore them.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kristian Waagan added a comment - 09/Jan/08 11:01 AM
'derby-3307-1a-test_repro.diff' can be used as a repro for this issue. It adds another test to jdbc4.StatementEventsTests.

Kristian Waagan added a comment - 03/Jun/08 12:59 PM
Note that the existing repro ('derby-3307-1a-test_repro.diff') only tests the statement event listener case, which has already been fixed (see DERBY-3695).
Another repro / test should be written for a connection event listener.

Knut Anders Hatlen added a comment - 03/Jun/08 01:08 PM
> I have found no information in the specs regarding null listeners, but I assume it would be okay to ignore them.

That's at least what the embedded driver does. And it would be consistent with how listeners work in the Swing/AWT world.

Knut Anders Hatlen added a comment - 10/Jun/08 09:36 AM
The attached patch adds a null check in ClientPooledConnection.addConnectionEventListener() and a regression test in J2EEDataSourceTest.

Knut Anders Hatlen added a comment - 10/Jun/08 09:38 AM
Committed revision 666040.

Knut Anders Hatlen added a comment - 10/Jun/08 01:09 PM
Merged to 10.4 and committed revision 666094.

Kristian Waagan added a comment - 10/Jun/08 01:41 PM
I verified the fix in trunk by running the repro after removing the code change in CPC. It fails with the code removed, and succeeds with the code in place.

Thank you Knut Anders!