Details
-
Bug
-
Status: Closed (View Workflow)
-
Trivial
-
Resolution: Fixed
-
1.1.5
-
None
-
None
Description
I have a simple pool implementation, which deregisteres itself as listener from a pooled connection, when the method close is called on the pooled
connection.
The close method calls the internal method fireConnectionClosed which notifies all registered listeners. Thus even my pool implementation, which
upon notifications removes itself as listener. Upon returning back to the calling
fireConnectionClosed method a ConcurrentModificationException, because the for loop over the listeners got modified. BTW everything happens within the same Thread.
If you want to be drop in replacement you can consider this as bug, else an
improvement.
A simple fix is to use a CopyOnWriteArrayList for the List instances for
connectionEventListeners and statementEventListeners of the MySQLPooledConnection. This even doesn't break the minimum requirements for the driver regarding the java version, because CopyOnWriteArrayList wa introduced in Java 1.5.