vsilaev/tascalate-concurrent

orTime and submit combination

Closed this issue · 5 comments

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

Confirmed. The issue affects both orTimeout and onTimeout -- working on this

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>

Sorry, but how can I verify it with maven? Do I need a special repository? Maven says that this artifact doesn't exist.

It's necessary to clone a repo locally. Nevermind, I will release new build shortly.

Build is released with the fix mentioned