[jira] Created: (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

JIRA jira@codehaus.org
java.nio.channels.CancelledKeyException in Jetty client
-------------------------------------------------------

                 Key: JETTY-1379
                 URL: http://jira.codehaus.org/browse/JETTY-1379
             Project: Jetty
          Issue Type: Bug
          Components: Client
    Affects Versions: 6.1.25
         Environment: Linux x86_64 GNU/Linux 2.6.18-194.el5
java: 1.6.0_21; vm version: 17.0-b16 (Java HotSpot(TM) 64-Bit Server VM); vendor: Sun Microsystems Inc.; vm vendor: Sun Microsystems Inc.

            Reporter: Michiel


We run a system where we have an embedded Jetty client doing a lot of small HTTP requests to an HTTP server. During a stress test, the following error occurred:

java.nio.channels.CancelledKeyException
        at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55)
        at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:59)
        at org.mortbay.io.nio.SelectChannelEndPoint.updateKey(SelectChannelEndPoint.java:325)
        at org.mortbay.io.nio.SelectChannelEndPoint.scheduleWrite(SelectChannelEndPoint.java:309)
        at org.mortbay.jetty.client.HttpConnection.send(HttpConnection.java:131)
        at org.mortbay.jetty.client.HttpDestination.doSend(HttpDestination.java:503)
        at org.mortbay.jetty.client.HttpDestination.send(HttpDestination.java:459)
        at org.mortbay.jetty.client.HttpClient.send(HttpClient.java:143)
        ...

Looking at the code in 6.1.25:


            if (getChannel().isOpen())
            {
=>              ops = ((_key!=null && _key.isValid())?_key.interestOps():-1);
                _interestOps =
                    ((!_dispatched || _readBlocked)  ? SelectionKey.OP_READ  : 0)
                |   ((!_writable   || _writeBlocked) ? SelectionKey.OP_WRITE : 0);
            }

there is a race condition where the key can be cancelled between the _key.isValid() check and calling _key.interestOps() which is likely to cause this exception. Looking at the Jetty-7 code:


            try
            {
                ops = ((_key!=null && _key.isValid())?_key.interestOps():-1);
            }
            catch(Exception e)
            {
                _key=null;
                Log.ignore(e);
            }

This catches a possible exception and sets the key to null. I suspect this code will fix the intermittent java.nio.channels.CancelledKeyException that we are seeing. Can this code be backported to Jetty-6?

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

[jira] Assigned: (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

JIRA jira@codehaus.org

     [ https://jira.codehaus.org/browse/JETTY-1379?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jan Bartel reassigned JETTY-1379:
---------------------------------

    Assignee: Greg Wilkins

Please check if it is ok to backport this fix to jetty-6.

> java.nio.channels.CancelledKeyException in Jetty client
> -------------------------------------------------------
>
>                 Key: JETTY-1379
>                 URL: https://jira.codehaus.org/browse/JETTY-1379
>             Project: Jetty
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: 6.1.25
>         Environment: Linux x86_64 GNU/Linux 2.6.18-194.el5
> java: 1.6.0_21; vm version: 17.0-b16 (Java HotSpot(TM) 64-Bit Server VM); vendor: Sun Microsystems Inc.; vm vendor: Sun Microsystems Inc.
>            Reporter: Michiel
>            Assignee: Greg Wilkins
>
> We run a system where we have an embedded Jetty client doing a lot of small HTTP requests to an HTTP server. During a stress test, the following error occurred:
> java.nio.channels.CancelledKeyException
>         at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55)
>         at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:59)
>         at org.mortbay.io.nio.SelectChannelEndPoint.updateKey(SelectChannelEndPoint.java:325)
>         at org.mortbay.io.nio.SelectChannelEndPoint.scheduleWrite(SelectChannelEndPoint.java:309)
>         at org.mortbay.jetty.client.HttpConnection.send(HttpConnection.java:131)
>         at org.mortbay.jetty.client.HttpDestination.doSend(HttpDestination.java:503)
>         at org.mortbay.jetty.client.HttpDestination.send(HttpDestination.java:459)
>         at org.mortbay.jetty.client.HttpClient.send(HttpClient.java:143)
>         ...
> Looking at the code in 6.1.25:
>             if (getChannel().isOpen())
>             {
> =>              ops = ((_key!=null && _key.isValid())?_key.interestOps():-1);
>                 _interestOps =
>                     ((!_dispatched || _readBlocked)  ? SelectionKey.OP_READ  : 0)
>                 |   ((!_writable   || _writeBlocked) ? SelectionKey.OP_WRITE : 0);
>             }
> there is a race condition where the key can be cancelled between the _key.isValid() check and calling _key.interestOps() which is likely to cause this exception. Looking at the Jetty-7 code:
>             try
>             {
>                 ops = ((_key!=null && _key.isValid())?_key.interestOps():-1);
>             }
>             catch(Exception e)
>             {
>                 _key=null;
>                 Log.ignore(e);
>             }
> This catches a possible exception and sets the key to null. I suspect this code will fix the intermittent java.nio.channels.CancelledKeyException that we are seeing. Can this code be backported to Jetty-6?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

[jira] (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

JIRA jira@codehaus.org
In reply to this post by JIRA jira@codehaus.org
Change By: Jan Bartel (03/Sep/12 1:41 AM)
Assignee: Greg Wilkins Jan Bartel
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|

[jira] (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

JIRA jira@codehaus.org
In reply to this post by JIRA jira@codehaus.org
Jan Bartel commented on Bug JETTY-1379

jetty-6 is mainly only having security patches applied to it, and releases are really prompted by security fixes. So realistically, I don't see us porting this to jetty-6. If this is commercially important to you, then I suggest perhaps you talk to http://www.webtide.com about support for an old version.

regards
Jan

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|

[jira] (JETTY-1379) java.nio.channels.CancelledKeyException in Jetty client

JIRA jira@codehaus.org
In reply to this post by JIRA jira@codehaus.org
Jan Bartel resolved Bug JETTY-1379 as Won't Fix
Change By: Jan Bartel (03/Sep/12 1:44 AM)
Resolution: Won't Fix
Status: Open Resolved
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email