[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cu-dev] TCK test ContextServiceDefinitionServlet.testContextServiceDefinitionDefaults, ContextC
|
Hello,
I'm looging at the test
ContextServiceDefinitionServlet.testContextServiceDefinitionDefaults.
It uses ContextC. The code looks like this:
@ContextServiceDefinition(name
= "java:comp/concurrent/ContextC")
...
ContextService
contextService =
InitialContext.doLookup("java:comp/concurrent/ContextC");
StringContext.set("testContextServiceDefinitionDefaults-1");
Callable<String> callable =
contextService.contextualCallable(() -> {
...
});
StringContext.set("testContextServiceDefinitionDefaults-2");
assertEquals(callable.call(),
"testContextServiceDefinitionDefaults-1",
"Third-party context type StringContext must be
propagated to contextual Callable.");
assertEquals(tx.getStatus(), Status.STATUS_ACTIVE,
"Transaction must be restored on thread after contextual
proxy completes.");
There must be something I miss, because StringContext is not
propagated. The definition with default values looks like this:
@ContextServiceDefinition(name = "java:comp/concurrent/ContextC",
cleared=TRANSACTION, propagated=ALL_REMAINING, unchanged={})
* Does ALL_REMAINING mean also all custom thread context
providers?
* What should happen with the transaction, when used in cleared?
The javadoc says: context to clear whenever a thread runs the
contextual task or action. The thread's previous context is
restored afterward.
** I tried to find this in the discussion in MicroProfile, but it
didn't help. Does it mean, that the transaction should be
suspended before executing the task in a different thread?
Updating the definition this way improves things:
@ContextServiceDefinition(name = "java:comp/concurrent/ContextC",
propagated = {ALL_REMAINING, StringContext.NAME}, cleared = {})
Thank you,
Petr