You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Trejkaz (JIRA)" <ji...@apache.org> on 2008/05/15 06:13:55 UTC

[jira] Created: (DERBY-3675) ConcurrentModificationException on closing pooled connection

ConcurrentModificationException on closing pooled connection
------------------------------------------------------------

                 Key: DERBY-3675
                 URL: https://issues.apache.org/jira/browse/DERBY-3675
             Project: Derby
          Issue Type: Bug
          Components: Network Client
    Affects Versions: 10.4.1.3
            Reporter: Trejkaz


I'm seeing the following exception from calling close() on a connection returned from a CollectionPoolDataSource.

java.util.ConcurrentModificationException
	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
	at java.util.AbstractList$Itr.next(AbstractList.java:343)
	at org.apache.derby.client.ClientPooledConnection.recycleConnection(ClientPooledConnection.java:343)
	at org.apache.derby.client.am.LogicalConnection.close(LogicalConnection.java:83)

The only particularly unique thing about the area of the code where we're doing this is that we're closing it immediately after opening it, as an initial check to make sure it can connect.


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


[jira] Commented: (DERBY-3675) ConcurrentModificationException on closing pooled connection

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597884#action_12597884 ] 

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

I see how that could cause a ConcurrentModificationException. When the connection is closed, it simply iterates through the list of listeners. If one of the listeners is removed while iterating, the list is modified and the exception is thrown on the next operation on the list iterator. The code seems properly synchronized, so the only way this can happen is if one of the listeners adds or removes a listener. It should be easy to fix. We only need to create a copy of the list and iterate over the listeners in the copy instead of the original. This is by the way exactly what java.util.Observable does, so perhaps the cleanest way to fix it is to create a wrapper around java.util.Observer/java.util.Observable.

> ConcurrentModificationException on closing pooled connection
> ------------------------------------------------------------
>
>                 Key: DERBY-3675
>                 URL: https://issues.apache.org/jira/browse/DERBY-3675
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.4.1.3
>            Reporter: Trejkaz
>
> I'm seeing the following exception from calling close() on a connection returned from a CollectionPoolDataSource.
> java.util.ConcurrentModificationException
> 	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
> 	at java.util.AbstractList$Itr.next(AbstractList.java:343)
> 	at org.apache.derby.client.ClientPooledConnection.recycleConnection(ClientPooledConnection.java:343)
> 	at org.apache.derby.client.am.LogicalConnection.close(LogicalConnection.java:83)
> The only particularly unique thing about the area of the code where we're doing this is that we're closing it immediately after opening it, as an initial check to make sure it can connect.

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


[jira] Commented: (DERBY-3675) ConcurrentModificationException on closing pooled connection

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597449#action_12597449 ] 

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

Have you defined any connection event listeners on the pooled connection? And if you have, do any of the listeners add or remove listeners on the same pooled connection?

> ConcurrentModificationException on closing pooled connection
> ------------------------------------------------------------
>
>                 Key: DERBY-3675
>                 URL: https://issues.apache.org/jira/browse/DERBY-3675
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.4.1.3
>            Reporter: Trejkaz
>
> I'm seeing the following exception from calling close() on a connection returned from a CollectionPoolDataSource.
> java.util.ConcurrentModificationException
> 	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
> 	at java.util.AbstractList$Itr.next(AbstractList.java:343)
> 	at org.apache.derby.client.ClientPooledConnection.recycleConnection(ClientPooledConnection.java:343)
> 	at org.apache.derby.client.am.LogicalConnection.close(LogicalConnection.java:83)
> The only particularly unique thing about the area of the code where we're doing this is that we're closing it immediately after opening it, as an initial check to make sure it can connect.

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


[jira] Resolved: (DERBY-3675) ConcurrentModificationException on closing pooled connection

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3675?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen resolved DERBY-3675.
---------------------------------------

    Resolution: Duplicate

I'm marking this issue as resolved on the assumption that it is a duplicate of DERBY-3401. A fix for DERBY-3401 has been checked in on trunk and on the 10.4 branch.

> ConcurrentModificationException on closing pooled connection
> ------------------------------------------------------------
>
>                 Key: DERBY-3675
>                 URL: https://issues.apache.org/jira/browse/DERBY-3675
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.4.1.3
>            Reporter: Trejkaz
>
> I'm seeing the following exception from calling close() on a connection returned from a CollectionPoolDataSource.
> java.util.ConcurrentModificationException
> 	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
> 	at java.util.AbstractList$Itr.next(AbstractList.java:343)
> 	at org.apache.derby.client.ClientPooledConnection.recycleConnection(ClientPooledConnection.java:343)
> 	at org.apache.derby.client.am.LogicalConnection.close(LogicalConnection.java:83)
> The only particularly unique thing about the area of the code where we're doing this is that we're closing it immediately after opening it, as an initial check to make sure it can connect.

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


[jira] Commented: (DERBY-3675) ConcurrentModificationException on closing pooled connection

Posted by "Trejkaz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3675?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597869#action_12597869 ] 

Trejkaz commented on DERBY-3675:
--------------------------------

Not in our own code, but the connection pool manager does remove the listener like this:

private class PoolConnectionEventListener implements ConnectionEventListener {
    public void connectionClosed (ConnectionEvent event) {
        PooledConnection pconn = (PooledConnection) event.getSource();
        pconn.removeConnectionEventListener(this);
        recycleConnection(pconn);
    }
    public void connectionErrorOccurred (ConnectionEvent event) {
        PooledConnection pconn = (PooledConnection) event.getSource();
        pconn.removeConnectionEventListener (this);
        disposeConnection(pconn);
    }
}

And then it reattaches it when it gives the connection out again.


> ConcurrentModificationException on closing pooled connection
> ------------------------------------------------------------
>
>                 Key: DERBY-3675
>                 URL: https://issues.apache.org/jira/browse/DERBY-3675
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.4.1.3
>            Reporter: Trejkaz
>
> I'm seeing the following exception from calling close() on a connection returned from a CollectionPoolDataSource.
> java.util.ConcurrentModificationException
> 	at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
> 	at java.util.AbstractList$Itr.next(AbstractList.java:343)
> 	at org.apache.derby.client.ClientPooledConnection.recycleConnection(ClientPooledConnection.java:343)
> 	at org.apache.derby.client.am.LogicalConnection.close(LogicalConnection.java:83)
> The only particularly unique thing about the area of the code where we're doing this is that we're closing it immediately after opening it, as an initial check to make sure it can connect.

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