Promise.allOf(listOfPromise) leaves one of the promises (activity) in pending state after another promise throws exception?

@Override
  public void act2() {
    throwException();
  }

  @Override
  public void act3() {
    Thread.sleep(10000);
    throwException();
  }

Promise<Void> promise1 = Async.procedure(sampleActivity::act2);
    Promise<Void> promise2 = Async.procedure(sampleActivity::act3);
List<Promise<Void>> promises = new ArrayList<>();
promises.add(promise1);
    promises.add(promise2);
try {
      Promise.allOf(promises).get();
    } catch (Exception e) {
      System.out.println("Exception encountered");
    }

Workflow method shown above. Upon workflow execution, act2 throws an error which is caught in the catch block and workflow gets completed. act3 ,on the other hand, sleeps for 10 seconds post which throws an error. The workflow, as can be seen in the screenshot, is marked completed but act3 still stays in pending.

Queries -

  1. What happens to pending promises when one of the promises throws exception?
  2. When a workflow gets completed, what happens to any pending activities?
  1. What happens to pending promises when one of the promises throws exception?

Nothing happens to them as all Promises are completely independent. But note that Promise.allOf throws immediately if any of the promises throws.

  1. When a workflow gets completed, what happens to any pending activities?

They are canceled. Note that for an activity to learn about cancellation, it has to heartbeat. Otherwise, it will complete and the result will be ignored.