Injected Context becomes invalid after a service reference is invoked in SwitchYard
Issue
- If I have a Bean service that injects both the SwitchYard
Context
and a service reference, theContext
becomes invalid after invoking an operation on the service reference.
@Service(value = OuterService.class)
public class OuterServiceBean implements OuterService {
@Inject
private Context context;
@Inject @Reference
private InnerService inner;
@Override
public int getNumber(String in) {
// This succeeds
context.setProperty("FIRST", 1, Scope.EXCHANGE);
// Invoke the referenced service
int val = inner.parseNumber(in);
// This fails since it is after the reference invocation
context.setProperty("SECOND", 2, Scope.EXCHANGE);
return val;
}
}
- This service will throw an exception related to an invalid use of the
Context
:
java.lang.IllegalStateException: SWITCHYARD030422: Illegal call to get the SwitchYard Context; must be called within the execution of an ExchangeHandler chain.
Environment
- Red Hat JBoss Fuse Service Works (FSW)
- 6.0 (including roll-up patch #1-5)
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.