Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
3.4.4
-
None
-
None
-
Unknown
Description
Hello.
The context is message logs in case of rest services exposed when we have multiple resources exposed on the same JAX-RS server.
What we see is the current logging name for message logs look like:
<org.apache.cxf.services.ResourceClass.REQ_IN>
<org.apache.cxf.services.ResourceClass.RESP_OUT>
However it is not always the correct resource class name that is logged, the request path does not match the resource path but on another resource exposed on the server.
After investigation I could find that the name comes from org.apache.cxf.jaxrs.JAXRSServiceImpl#getName used to create the endpoint info org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean#createEndpointInfo
Where we can see:
{{ public QName getName() {}}
{{ if (serviceName != null) {}}
{{ return serviceName;}}
{{ }}}
{{ if (address == null && !classResourceInfos.isEmpty()) {}}
{{ Class<?> primaryClass = classResourceInfos.get(0).getServiceClass();}}
{{ String ns = PackageUtils.getNamespace(PackageUtils.getPackageName(primaryClass));}}
{{ return new QName(ns, primaryClass.getSimpleName());}}
{{ }}}
{{ return new QName(address, "WebClient");}}
{{ }}}
And we can see the first resource found is used as name. but this does not always reflect the class targetted.
This name is used to log the message there org.apache.cxf.ext.logging.event.DefaultLogEventMapper#setEpInfo
{{ event.setPortTypeName(endpoint.getName());}}
But while debugging I could see that the message exchange actually contains the current class resource definition at the key "root.resource.class" set by the JAXRSInInterceptor, and this would actually set the correct class name.
Thanks and best regards.
Baptiste.