Skip to content

Commit

Permalink
Set client component as SOAP API for soap calls (#3045)
Browse files Browse the repository at this point in the history
* set client component as SOAP API for soap calls

* clear CarbonConstants.LogEventConstants.CLIENT_COMPONENT in MDC

* move CLIENT_COMPONENT clearing to CarbonContextCreatorValve
  • Loading branch information
AnuradhaSK committed Aug 27, 2021
1 parent 9fa49f8 commit e37d719
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.MDC;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.services.authentication.*;
Expand Down Expand Up @@ -100,7 +101,7 @@ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(userName);
}
}

MDC.put(CarbonConstants.LogEventConstants.CLIENT_COMPONENT, "SOAP API");
return InvocationResponse.CONTINUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.catalina.valves.ValveBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.MDC;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.RegistryType;
import org.wso2.carbon.registry.api.RegistryService;
Expand Down Expand Up @@ -58,6 +60,7 @@ public void invoke(Request request, Response response) throws IOException, Servl
} catch (Exception e) {
log.error("Could not handle request: " + request.getRequestURI(), e);
} finally {
MDC.remove(CarbonConstants.LogEventConstants.CLIENT_COMPONENT);
// This will destroy the carbon context holder on the current thread after
// invoking subsequent valves.
PrivilegedCarbonContext.destroyCurrentContext();
Expand Down

0 comments on commit e37d719

Please sign in to comment.