Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LoadBalance parent endpoint from fault stack after a successful child invocation #2291

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.synapse.endpoints.AbstractEndpoint;
import org.apache.synapse.endpoints.Endpoint;
import org.apache.synapse.endpoints.FailoverEndpoint;
import org.apache.synapse.endpoints.LoadbalanceEndpoint;
import org.apache.synapse.endpoints.OAuthConfiguredHTTPEndpoint;
import org.apache.synapse.endpoints.dispatch.Dispatcher;
import org.apache.synapse.endpoints.auth.oauth.MessageCache;
Expand Down Expand Up @@ -600,13 +601,19 @@ private void handleMessage(String messageID ,MessageContext response,
if(failOver) {
popFailOverEPFromFaultStack(synapseOutMsgCtx);
}
if (isChildOfLoadBalanceEP(successfulEndpoint)) {
popLoadBalanceEPFromFaultStack(synapseOutMsgCtx);
}
}

} else if(successfulEndpoint != null) {
successfulEndpoint.onSuccess();
if(failOver) {
popFailOverEPFromFaultStack(synapseOutMsgCtx);
}
if (isChildOfLoadBalanceEP(successfulEndpoint)) {
popLoadBalanceEPFromFaultStack(synapseOutMsgCtx);
}
}

synapseInMessageContext.setTo(
Expand Down Expand Up @@ -812,6 +819,30 @@ private void popFailOverEPFromFaultStack(org.apache.synapse.MessageContext synCt
}
}

/**
* Check if the endpoint is a child of LoadBalance EP.
*
* @param endpoint Endpoint to be checked.
* @return true if the given endpoint is a child of a LoadBalance EP.
*/
private boolean isChildOfLoadBalanceEP(Endpoint endpoint) {
if (endpoint instanceof AbstractEndpoint) {
Endpoint parentEndpoint = ((AbstractEndpoint) endpoint).getParentEndpoint();
return parentEndpoint instanceof LoadbalanceEndpoint;
}
return false;
}

private void popLoadBalanceEPFromFaultStack(org.apache.synapse.MessageContext synCtx) {
Stack<FaultHandler> faultStack = synCtx.getFaultStack();
if (faultStack != null && !faultStack.isEmpty()) {
Object o = faultStack.peek();
if (o instanceof LoadbalanceEndpoint) {
faultStack.pop();
}
}
}

/**
* Log the WARN when response receiving after synapse endpoint timeout.
* @param messageID messageID
Expand Down
Loading