I'm trying to get the stacktrace of the Thread.sleep
in the following code snippet. Right now, the only stacktrace I'm getting is the one created by Mutiny upon timing out (which isn't helpful). I've tried following things:
- Catch any exception on the long running code, that's not triggered
onCancellation
is invoked but the thread stacktrace is the one from theTimeOut
onTermination
is invoked but the throwable isnull
onFailure
after the timeout contains the stacktrace of theTimeOut
To give more context, in our case, we have a lot more going on which is long running and I can't pinpoint what exactly is causing the timeout. I would like to get the stacktrace of the long running code when the timeout happens so I know what needs to be fixed.
Uni.createFrom()
.completionStage(CompletableFuture.supplyAsync(() -> {
try {
Thread.sleep(20000);
} catch (Exception e) {
e.printStackTrace(); //not triggered
}
return "item";
}))
.onCancellation().invoke(() ->{
// stacktrace of timeout exception
})
.onTermination().invoke((s, throwable, aBoolean) -> {
// throwable is NULL
})
.ifNoItem().after(Duration.ofMillis(100)).fail()
.onFailure().invoke(ex -> {
ex.printStackTrace(); //try to get the stacktrace of the Thread.sleep
})
.onFailure().recoverWithItem("error")
.await().atMost(DEFAULT_TIMEOUT);
}
Thanks for assistance in advance!