Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
15 lines
875 B
Plaintext
15 lines
875 B
Plaintext
$ java --enable-preview StructuredDemo (JDK 27)
|
|
--- allSuccessfulOrThrow(): results as a List, failures as ExecutionException
|
|
results = [price=42, stock=7]
|
|
CHECK ok : join() returns the subtask results in fork order
|
|
caught java.util.concurrent.ExecutionException with cause java.lang.IllegalStateException: inventory service is down
|
|
CHECK ok : a failing subtask surfaces as ExecutionException(cause)
|
|
--- allSuccessfulOrThrow(Function): join() throws the exception type you choose
|
|
caught OrderFailed: order failed: inventory service is down
|
|
CHECK ok : the mapped exception wraps the original failure
|
|
--- withTimeout(...): what happens when the scope runs out of time
|
|
caught java.util.concurrent.ExecutionException
|
|
cause: java.util.concurrent.StructuredTaskScope$CancelledByTimeoutException
|
|
CHECK ok : a timeout is reported as CancelledByTimeoutException
|
|
exit=0
|