MicroProfile® Context Propagation 1.2 Release Review

End Date of the Review Period

Reviews run for a minimum of one week. The outcome of the review is decided on this date. This is the last day to make comments or ask questions about this review.


Context Propagation 1.2


MicroProfile Context Propagation 1.2 provides APIs for obtaining CompletableFutures that are backed by managed threads (threads that are managed by the container), with the ability to capture context from the thread that creates the CompletableFuture and apply it when running the CompletionStage action.  This enables CompletionStage actions to rely on having predictable thread context and enables users of these CompletionStages to guard against unintentional donation of thread context.

Example of ManagedExecutor, which contextualizes all dependent stages:

ManagedExecutor executor = ManagedExecutor.builder()
.propagated(ThreadContext.CDI, ThreadContext.APPLICATION)
CompletableFuture<Integer> stage = executor

Example of ThreadContext for granular contextualization of a single stage:

ThreadContext threadContext = ThreadContext.builder()
.cleared(ThreadContext.SECURITY, ThreadContext.TRANSACTION)
Function<Integer, Double> getItemCost = threadContext.contextualFunction(id -> {
// java:comp, java:module, java:app lookups require the application's context
DataSource ds = InitialContext.doLookup("java:app/env/jdbc/ds1");
unmanagedStage4 = unmanagedStage1.thenApply(getProductId)

Conforms To UI/UX Guidelines
Not verified