[ 
https://issues.apache.org/jira/browse/QPID-5796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Keith Wall updated QPID-5796:
-----------------------------

    Description: 
If the closure of the ConnectionRegistry races with a incoming connection 
close, there is the possibility of the a AIOOBException within the 
close(replyText) method.

This issue is longstanding, but could previously only manifest on Broker 
shutdown.  With recent work on 0.29, it is now possible for the user to stop 
the virtual host (or virtualhostnode) at runtime, meaning this problem could 
manifest at non-shutdown situations too.

{code:java}
public void close(final String replyText)
    {
        synchronized(this)
        {
            for(AMQConnectionModel conn : _registry)
            {
                conn.stop();
            }
        }

        if (_logger.isDebugEnabled())
        {
            _logger.debug("Closing connection registry :" + _registry.size() + 
" connections.");
        }
        while (!_registry.isEmpty())
        {
             # <----  another thread closes a connection
            AMQConnectionModel connection = _registry.get(0);  # !#% AIOOB
            closeConnection(connection, AMQConstant.CONNECTION_FORCED, 
replyText);
        }
    }
{code}

I forced this issue to occur by opening a large number of messaging connections 
then stopping the virtualhostnode from the Web Management Console.
The following stack trace results:

{noformat}
2014-07-22 22:15:43,568 WARN  [qtp1081024101-26] (rest.RestServlet) - Caught 
exception
java.lang.ArrayIndexOutOfBoundsException: 0
        at 
java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:368)
        at 
java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:377)
        at 
org.apache.qpid.server.connection.ConnectionRegistry.close(ConnectionRegistry.java:75)
        at 
org.apache.qpid.server.connection.ConnectionRegistry.close(ConnectionRegistry.java:49)
        at 
org.apache.qpid.server.virtualhost.AbstractVirtualHost.onClose(AbstractVirtualHost.java:648)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject.close(AbstractConfiguredObject.java:445)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject$1.performAction(AbstractConfiguredObject.java:418)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject$1.performAction(AbstractConfiguredObject.java:414)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject.applyToChildren(AbstractConfiguredObject.java:586)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject.closeChildren(AbstractConfiguredObject.java:413)
        at 
org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode.stopAndSetStateTo(AbstractVirtualHostNode.java:189)
        at 
org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode.doStop(AbstractVirtualHostNode.java:184)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject.attainState(AbstractConfiguredObject.java:652)
        at 
org.apache.qpid.server.model.AbstractConfiguredObject.attainStateIfResolved(AbstractConfiguredObject.java:632)
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
{noformat}


  was:
If the closure of the ConnectionRegistry races with a incoming connection 
close, there is the possibility of the a AIOOBException within the 
close(replyText) method.

This issue is longstanding, but could previously only manifest on Broker 
shutdown.  With recent work on 0.29, it is now possible for the user to stop 
the virtual host (or virtualhostnode) at runtime, meaning this problem could 
manifest at non-shutdown situations too.

{code:java}
public void close(final String replyText)
    {
        synchronized(this)
        {
            for(AMQConnectionModel conn : _registry)
            {
                conn.stop();
            }
        }

        if (_logger.isDebugEnabled())
        {
            _logger.debug("Closing connection registry :" + _registry.size() + 
" connections.");
        }
        while (!_registry.isEmpty())
        {
             # <----  another thread closes a connection
            AMQConnectionModel connection = _registry.get(0);  # !#% AIOOB
            closeConnection(connection, AMQConstant.CONNECTION_FORCED, 
replyText);
        }
    }
{code}


> ConnectionRegistry may suffer an ArrayIndexOutOfBounds if closed at the same 
> moment as a messaging connection is closed
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: QPID-5796
>                 URL: https://issues.apache.org/jira/browse/QPID-5796
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Broker
>    Affects Versions: 0.29
>            Reporter: Keith Wall
>
> If the closure of the ConnectionRegistry races with a incoming connection 
> close, there is the possibility of the a AIOOBException within the 
> close(replyText) method.
> This issue is longstanding, but could previously only manifest on Broker 
> shutdown.  With recent work on 0.29, it is now possible for the user to stop 
> the virtual host (or virtualhostnode) at runtime, meaning this problem could 
> manifest at non-shutdown situations too.
> {code:java}
> public void close(final String replyText)
>     {
>         synchronized(this)
>         {
>             for(AMQConnectionModel conn : _registry)
>             {
>                 conn.stop();
>             }
>         }
>         if (_logger.isDebugEnabled())
>         {
>             _logger.debug("Closing connection registry :" + _registry.size() 
> + " connections.");
>         }
>         while (!_registry.isEmpty())
>         {
>              # <----  another thread closes a connection
>             AMQConnectionModel connection = _registry.get(0);  # !#% AIOOB
>             closeConnection(connection, AMQConstant.CONNECTION_FORCED, 
> replyText);
>         }
>     }
> {code}
> I forced this issue to occur by opening a large number of messaging 
> connections then stopping the virtualhostnode from the Web Management Console.
> The following stack trace results:
> {noformat}
> 2014-07-22 22:15:43,568 WARN  [qtp1081024101-26] (rest.RestServlet) - Caught 
> exception
> java.lang.ArrayIndexOutOfBoundsException: 0
>       at 
> java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:368)
>       at 
> java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:377)
>       at 
> org.apache.qpid.server.connection.ConnectionRegistry.close(ConnectionRegistry.java:75)
>       at 
> org.apache.qpid.server.connection.ConnectionRegistry.close(ConnectionRegistry.java:49)
>       at 
> org.apache.qpid.server.virtualhost.AbstractVirtualHost.onClose(AbstractVirtualHost.java:648)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject.close(AbstractConfiguredObject.java:445)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject$1.performAction(AbstractConfiguredObject.java:418)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject$1.performAction(AbstractConfiguredObject.java:414)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject.applyToChildren(AbstractConfiguredObject.java:586)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject.closeChildren(AbstractConfiguredObject.java:413)
>       at 
> org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode.stopAndSetStateTo(AbstractVirtualHostNode.java:189)
>       at 
> org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode.doStop(AbstractVirtualHostNode.java:184)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:606)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject.attainState(AbstractConfiguredObject.java:652)
>       at 
> org.apache.qpid.server.model.AbstractConfiguredObject.attainStateIfResolved(AbstractConfiguredObject.java:632)
>       at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to