db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3401) Removing a ConnectionEventListener from a PooledConnection during its connectionClosed() callback causes other ConnectionEventListener callbacks to be missed
Date Tue, 27 May 2008 13:48:39 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600126#action_12600126
] 

Knut Anders Hatlen commented on DERBY-3401:
-------------------------------------------

I agree that copying the collection sounds like a reasonable approach. Strictly speaking,
we only need a copy if there are at least two listeners in the list, but it is perhaps not
worth the extra complexity to avoid copying 1-element lists. I'll try it and see how complex
it gets.

Alternatively, we could have a copy-on-write scheme so that we only pay the extra price if
we actually modify the list of listeners (this assumes that the listeners are triggered more
frequently than they are modified). For the statement event listeners, we could get this more
or less for free with java.util.concurrent.CopyOnWriteArrayList (new in Java 1.5) since that
code is compiled with the 1.6 compiler.

> Removing a ConnectionEventListener from a PooledConnection during its connectionClosed()
callback causes other ConnectionEventListener callbacks to be missed
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3401
>                 URL: https://issues.apache.org/jira/browse/DERBY-3401
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.4.1.3
>            Reporter: Daniel John Debrunner
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>
> A ConnectionEventListener should be able to remove itself as a listener during a callback
without affecting any other callbacks.
> DataSourceTest.subtestPooledRemoveListenerOnClose() tests the scenario but calls to it
will be commented out in the fixture testPooledReuseOnClose() (using this bug number).
> Issue is that such a remove will modify the eventListener Vector in EmbedPooledConnection
while it is being enumerated over.
> An idea for a fix would be to first change the Vector over to a new-style collection,
such as an implementation of List, then work off a copy of the collection when calling the
callbacks. I don't think eventListener needs to be a synchronized collection, its access should
be already synchronized on EmbedPooledConnection.
> I imagine that a similar issue exists for adding a new callback during callback processing,
fixing this bug would fix that issue as well though no tests have been written for the add
case.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message