Added also test covering the issue
…the main thread to invoke -cancel on the top-level request, which then synchrounsly eventually calls -cancel on the RKResponseMapperOperation, which will then call the -willFinish method. If this is exquisitely timed (such as in a callback of AFNetworkingOperationDidFinishNotification), then it can happen when the operation subthread has started to call -main but has not executed any code inside. When that happens, the -main method realizes it has been cancelled and immediately also calls -willFinish. Thus, two calls to -willFinish can be executing on separate threads at the same time. The code in -willFinish invokes the finish block, then nils it out so it can't be called again. However, that is not threadsafe, as both threads can invoke the block. When this happens, there is an RKStateMachine error as the second call will try to move to the finished state when it was already in the finished state. The fix is to add a synchronized block around the invocation of the finish block, which should ensure it can only be invoked once.
…ntity to server