Hi all,
This is related to fixing the JiRA [1].
Currently, during an Auth failure of an API call APIM executes following
code pieces to send an error response message to the caller.
1. Building the message [2]:
org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext)
messageContext).
getAxis2MessageContext();
RelayUtils.buildMessage(axis2MC);
2. After that, detaching the existing payload from the messageContext and
applying a faulty payload which is sent back to the caller[3]:
Iterator<OMElement> childElements =
messageContext.getEnvelope().getBody().getChildElements();
if(childElements != null){
while(childElements.hasNext()){
OMElement child = childElements.next();
child.detach();
}
}
messageContext.getEnvelope().getBody().addChild(payload);
Here *payload* is an OMElement type object, built as a POX message.
As we can see, the *RelayUtils.buildMessage(axis2MC) *does an unnecessary
amount of execution and its effort is wasted as the built message is
dropped during step 2. Even in the step 2, it loops through all OMElements
of the existing payload in the message context and remove each and every
child one by one. If some one sends a large payload these executions could
be costly.
Are there any better way to set a payload to the message context other than
the above method?
Any suggestions are much appreciated.
Thanks,
Malintha
[1] https://wso2.org/jira/browse/APIMANAGER-4024
[2]
https://github.com/wso2/carbon-apimgt/blob/435163dd0f60058d8cfecbb0c4230984f0882fb6/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/APIAuthenticationHandler.java#L169
[3]
https://github.com/wso2/carbon-apimgt/blob/435163dd0f60058d8cfecbb0c4230984f0882fb6/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/Utils.java#L96
--
Malintha Amarasinghe
Software Engineer
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/
Mobile : +94 712383306
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev