Strange Jedis.eval() socket closed exception

257 views
Skip to first unread message

jedix

unread,
Mar 15, 2013, 7:29:05 PM3/15/13
to jedis...@googlegroups.com
Hello,

I have codes that basically build a buffer of Lua script and then send it jedis.eval() for execution. The maven/surefire unit tests for codes have been working fine for days. Then I made some changes that would eliminate one or two script calls and are in no way relating to the lua buffering framework I have, then I suddenly see reproducible "socket is closed" exception at Jedis.eval() when running the tests in maven/surefire. The test class still runs successfully using the IDEA TestNG run target.

Here is the errors:

Caused by: java.net.SocketException: Socket is closed
    at java.net.Socket.setKeepAlive(Socket.java:1179)
    at redis.clients.jedis.Connection.setTimeoutInfinite(Connection.java:41)
    at redis.clients.jedis.Jedis.eval(Jedis.java:2763)
    at com.x.LuaScript.eval(LuaScript.java:400)
    at com.x.MyProcess.execute(MyProcess.java:279) // MyProcess.execute() will use the same jedis connections multiple times to retrieve data, before calling eval()

The call line is extremely simple:

                return jedis.eval(script, 0, arguments.keySet().toArray(new String[arguments.size()]));

Now, if I just add a call jedis.ping() right before the eval

                jedis.ping(); // for unknown reason, the eval() call below throw an SocketException complaing socket is closed in one maven test!
                return jedis.eval(script, 0, arguments.keySet().toArray(new String[arguments.size()]));

The problem goes way and all unit tests pass in maven run.

Note some tests (in the same test class) use Mockito and PowerMock to mock the Jedis connection. However, after removing all mocks and disabling PM for the test class, I still get the same error (without the mockito/powermock calls in the stacktrace, so it is hard to blame those complex mocking facility.)

Something smell fishy here. If the socket is really timed out, the ping() would fail. It feels like setKeepAlive() shouldn't be called in some situation?

Thanks!

jedix

unread,
Mar 22, 2013, 1:37:20 PM3/22/13
to jedis...@googlegroups.com
Hi, any thought on this?
Reply all
Reply to author
Forward
0 new messages