jruby/jruby — pull request #1581 by iconara (2014-03-25 15:41:50+00:00)
Title: Fix #1580

This fixes two different cases of the wrong exceptions being raised by `IO.select`.

The first case fixes #1580 where in some circumstances a `CancelledKeyException` is thrown and never handled. See that issue for a stress test that triggers the error. This makes `IO.select` raise `Errno::EBADF` instead of the Java exception.

The second case is something I discovered while fixing that issue: in some other circumstances an `IOException` is thrown with the message "Bad file descriptor". With the current automatic translation of `IOException` the Ruby code sees an `IOError`, but from the error message it's clear that it should be an `Errno::EBADF`.

Please review this properly, I haven't found any tests that cover this, and it's code that's really hard to test. I've also removed a big chunk of error handling code that never ran anyway (see the commit message), and if it's the case that this code should run then more code will be needed.