[
https://issues.apache.org/jira/browse/SYNAPSE-451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lucas Moten updated SYNAPSE-451:
--------------------------------
Description:
See also: JIRAs <a
href="https://issues.apache.org/jira/browse/SYNAPSE-437">Apache
SYNAPSE-437</a>, <a href="https://wso2.org/jira/browse/ESBJAVA-422">WSO2
ESBJAVA-422</a>
Thus far, this mostly appears to be an issue with CalloutMediator, because it's
mediate method depends upon init() having been run to setup the ServiceClient.
A FilterMediator extends AbstractListMediator, but for the else branch, uses a
ListMediator.
When synapse initializes inline sequences as part of SynapseConfiguration, the
init method of SequenceMediator is called. This in turn calls init of its
superclass, which is AbstractListMediator. In that class, all child mediators
that are instances of ManagedLifecycle are in turn initialized.
For the FilterMediator, the 'then' branch, as an AbstractListMediator being an
instance of ManagedLifecycle is initialized at startup. However, the 'else'
branch, being declared as a ListMediator, will not be. Thus, it appears as
though any mediator requiring initialization inside of the Filter else branch
will fail (NullPointerException) when it is referenced.
The workaround is to use named sequences wherever possible, and reference that
instead, as the 'else' branch of a FilterMediator can alternatively use an
elseKey.
However, this workaround appears to have limits when it comes to the
SwitchMediator. Inline sequences are handled inside of SwitchCase as an
AnonymousListMediator and like the FilterMediator, aren't initialized by top
level in/out inline target sequences. Since SwitchMediators don't have the
option of referencing a registry key for a named sequence initialized at
startup, I believe this breaks the ability to run certain child mediators that
require initialization of objects that only occur when init is called.
For example, this cannot work because the inline sequence is not initialized
<switch>
<case>
<callout>...</callout>
</case>
</switch>
For filters, this cannot work because inline sequences are not initialized
<filter>
<then>..</then>
<else>
<callout>
</else>
</filter>
But this can
<filter>
<callout>
</filter>
as can this
<filter>
<then>
<callout>
</then>
</filter>
and this
<sequence name="namedsequence">
<callout>
</sequence>
<filter>
<then>..</then>
<else sequence="namedsequence">
</filter>
was:
<p>See also: JIRAs <a
href="https://issues.apache.org/jira/browse/SYNAPSE-437">Apache
SYNAPSE-437</a>, <a href="https://wso2.org/jira/browse/ESBJAVA-422">WSO2
ESBJAVA-422</a></p>
<p>Thus far, this mostly appears to be an issue with CalloutMediator, because
it's mediate method depends upon init() having been run to setup the
ServiceClient.</p>
<p>A FilterMediator extends AbstractListMediator, but for the else branch, uses
a ListMediator.</p>
<p>When synapse initializes inline sequences as part of SynapseConfiguration,
the init method of SequenceMediator is called. This in turn calls init of its
superclass, which is AbstractListMediator. In that class, all child mediators
that are instances of ManagedLifecycle are in turn initialized.</p>
<p>For the FilterMediator, the 'then' branch, as an AbstractListMediator being
an instance of ManagedLifecycle is initialized at startup. However, the 'else'
branch, being declared as a ListMediator, will not be. Thus, it appears as
though any mediator requiring initialization inside of the Filter else branch
will fail (NullPointerException) when it is referenced.</p>
<p>A workaround is to use named sequences wherever possible, and reference that
instead, as the 'else' branch of a FilterMediator can alternatively use an
elseKey.</p>
<p>However, this workaround appears to have limits when it comes to the
SwitchMediator. Inline sequences are handled inside of SwitchCase as an
AnonymousListMediator and like the FilterMediator, aren't initialized by top
level in/out inline target sequences. Since SwitchMediators don't have the
option of referencing a registry key for a named sequence initialized at
startup, I believe this breaks the ability to run certain child mediators that
require initialization of objects that only occur when init is called.</p>
<p>For example, this cannot work because the inline sequence is not
initialized, and thus callout isn't initialized</p>
<pre>
<switch>
<case>
<callout>...</callout>
</case>
</switch>
</pre>
<p>For filters, this cannot work because inline sequences are not
initialized</p><pre>
<filter>
<then>..</then>
<else>
<callout>
</else>
</filter>
</pre>
<p>But this can</p><pre>
<filter>
<callout>
</filter>
</pre>
<p>as can this</p><pre>
<filter>
<then>
<callout>
</then>
</filter>
</pre>
<p>and this</p><pre>
<sequence name="namedsequence">
<callout>
</sequence>
<filter>
<then>..</then>
<else sequence="namedsequence">
</filter
</pre>
> Selection Mediators don't carry initialization through all branches
> -------------------------------------------------------------------
>
> Key: SYNAPSE-451
> URL: https://issues.apache.org/jira/browse/SYNAPSE-451
> Project: Synapse
> Issue Type: Bug
> Components: Core
> Reporter: Lucas Moten
>
> See also: JIRAs <a
> href="https://issues.apache.org/jira/browse/SYNAPSE-437">Apache
> SYNAPSE-437</a>, <a href="https://wso2.org/jira/browse/ESBJAVA-422">WSO2
> ESBJAVA-422</a>
> Thus far, this mostly appears to be an issue with CalloutMediator, because
> it's mediate method depends upon init() having been run to setup the
> ServiceClient.
> A FilterMediator extends AbstractListMediator, but for the else branch, uses
> a ListMediator.
> When synapse initializes inline sequences as part of SynapseConfiguration,
> the init method of SequenceMediator is called. This in turn calls init of
> its superclass, which is AbstractListMediator. In that class, all child
> mediators that are instances of ManagedLifecycle are in turn initialized.
> For the FilterMediator, the 'then' branch, as an AbstractListMediator being
> an instance of ManagedLifecycle is initialized at startup. However, the
> 'else' branch, being declared as a ListMediator, will not be. Thus, it
> appears as though any mediator requiring initialization inside of the Filter
> else branch will fail (NullPointerException) when it is referenced.
> The workaround is to use named sequences wherever possible, and reference
> that instead, as the 'else' branch of a FilterMediator can alternatively use
> an elseKey.
> However, this workaround appears to have limits when it comes to the
> SwitchMediator. Inline sequences are handled inside of SwitchCase as an
> AnonymousListMediator and like the FilterMediator, aren't initialized by top
> level in/out inline target sequences. Since SwitchMediators don't have the
> option of referencing a registry key for a named sequence initialized at
> startup, I believe this breaks the ability to run certain child mediators
> that require initialization of objects that only occur when init is called.
> For example, this cannot work because the inline sequence is not initialized
> <switch>
> <case>
> <callout>...</callout>
> </case>
> </switch>
> For filters, this cannot work because inline sequences are not initialized
> <filter>
> <then>..</then>
> <else>
> <callout>
> </else>
> </filter>
> But this can
> <filter>
> <callout>
> </filter>
> as can this
> <filter>
> <then>
> <callout>
> </then>
> </filter>
> and this
> <sequence name="namedsequence">
> <callout>
> </sequence>
> <filter>
> <then>..</then>
> <else sequence="namedsequence">
> </filter>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]