From 9b38c3a70f0c785b9603ff1da508a81281489711 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Tue, 15 May 2012 15:41:57 -0400 Subject: [PATCH] minor: JRUBY hacks --- lib/mongo/util/tcp_socket.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/mongo/util/tcp_socket.rb b/lib/mongo/util/tcp_socket.rb index 3cb6faa..bdbcdf7 100644 --- a/lib/mongo/util/tcp_socket.rb +++ b/lib/mongo/util/tcp_socket.rb @@ -70,10 +70,14 @@ module Mongo if ready begin @socket.sysread(maxlen, buffer) - rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE, Errno::ETIMEDOUT, EOFError - raise ConnectionFailure - rescue Errno::EINTR, Errno::EIO, IOError - raise OperationFailure + rescue SystemCallError => ex + # Needed because sometimes JRUBY doesn't throw Errno::ECONNRESET as it should + # http://jira.codehaus.org/browse/JRUBY-6180 + raise ConnectionFailure, ex + rescue Errno::ENOTCONN, Errno::EBADF, Errno::ECONNRESET, Errno::EPIPE, Errno::ETIMEDOUT, EOFError => ex + raise ConnectionFailure, ex + rescue Errno::EINTR, Errno::EIO, IOError => ex + raise OperationFailure, ex end else raise OperationTimeout