Affects Version/s: None
Fix Version/s: 2.1.1-beta
TestIPC timeouts occasionally, for example:
Look into the code, there is race condition in oah.ipc.Client, the race condition happen between RPC call thread and connection read response thread:
Connection.receiveRpcResponse-> call.setRpcResponse(value) -> notify Call Thread
Client.call -> Connection.addCall(retry with the same callId) -> notify read thread
calls.remove(callId) # intend to remove old call, but removes newly added call...
Connection.waitForWork end up wait maxIdleTime and close the connection. The call never get response and dead.
The problem doesn't show because previously callId is unique, we never accidentally remove newly added calls, but when retry added this race condition became possible.
To solve this, we can simply change order, remove the call first, then notify call thread.
Note there are many places need this order change(normal case, error case, cleanup case)
And there are some minor issues in TestIPC:
1. there are two method with same name:
void testSerial(int handlerCount, boolean handlerSleep, ...)
the second is not a test case(so should not use testXXX prefix), but somehow it causes testSerial(first one) run two times, see test report:
2. timeout annotation should be added, so next time related log is available.