orTime and submit combination
Closed this issue · 5 comments
DavDavid commented
When I execute this code:
CompletableTask
.submit(this::doTask, executor)
.orTimeout(Duration.ofSeconds(5L))
.whenComplete((res, err) -> {
if (res != null)
System.out.println(res);
else
System.out.println(err.getMessage());
});
private String doTask () throws Exception {
TimeUnit.SECONDS.sleep(3);
if (true)
throw new Exception("my error");
return "executed ok";
}
I never get "my error" exception after 3 secs, only TimeoutException after 5 secs with "Timeout after PT5S" message.
If I remove orTimeout(...) line, I get "my error" exception.
Is there any way to catch both exceptions?
Thanks
vsilaev commented
Confirmed. The issue affects both orTimeout and onTimeout -- working on this
vsilaev commented
Dav,
Could you please verify with the sources from master that the issues is fixed?
Please notice that the artifact has new coordinates:
<groupId>net.tascalate</groupId>
<artifactId>net.tascalate.concurrent</artifactId>
<version>1.0.0-SNAPSHOT</version>
DavDavid commented
Sorry, but how can I verify it with maven? Do I need a special repository? Maven says that this artifact doesn't exist.
vsilaev commented
It's necessary to clone a repo locally. Nevermind, I will release new build shortly.
vsilaev commented
Build is released with the fix mentioned