The most difficult debugging problem I've run across recently is deadlocks between asynchronous operations. For example, given two CompletionStage
chains, where the first chain invokes a method that depends upon the completion of the second chain, and the second chain invokes a method that depends upon the completion of the first chain. It isn't this obvious in real-life because the dependency tends to be hidden and sometimes deadlocks involve more than three parties.
Part of the problem is that there is no way to find out what a CompletableStage
is waiting on. This is because an operation references a CompletableStage
, not the other way around.
Most debuggers provide some level of deadlock detection nowadays, but this only applies to threads. How does one debug deadlocks between CompletableStage chains?