This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch CAMEL-20692/set-default-value-for-loggingSizeLimit in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6727da3de5727c35a760116203a64f47ad3ba436 Author: Nicolas Filotto <[email protected]> AuthorDate: Fri Apr 19 19:37:27 2024 +0200 CAMEL-20692: camel-cxf - No Payload is logged when the logging feature is enabled --- .../org/apache/camel/component/cxf/jaxrs/cxfrs.json | 6 +++--- .../apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java | 15 ++++++++++----- .../org/apache/camel/component/cxf/jaxws/CxfEndpoint.java | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/camel-cxf/camel-cxf-rest/src/generated/resources/org/apache/camel/component/cxf/jaxrs/cxfrs.json b/components/camel-cxf/camel-cxf-rest/src/generated/resources/org/apache/camel/component/cxf/jaxrs/cxfrs.json index 06e5bb01cce..167b1b46756 100644 --- a/components/camel-cxf/camel-cxf-rest/src/generated/resources/org/apache/camel/component/cxf/jaxrs/cxfrs.json +++ b/components/camel-cxf/camel-cxf-rest/src/generated/resources/org/apache/camel/component/cxf/jaxrs/cxfrs.json @@ -50,8 +50,6 @@ "beanId": { "kind": "path", "displayName": "Bean Id", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To lookup an existing configured CxfRsEndpoint. Must used bean: as prefix." }, "address": { "kind": "path", "displayName": "Address", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The service publish address." }, "features": { "kind": "parameter", "displayName": "Features", "group": "common", "label": "", "required": false, "type": "array", "javaType": "java.util.List<org.apache.cxf.feature.Feature>", "deprecated": false, "autowired": false, "secret": false, "description": "Set the feature list to the CxfRs endpoint." }, - "loggingFeatureEnabled": { "kind": "parameter", "displayName": "Logging Feature Enabled", "group": "common", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "This option enables CXF Logging Feature which writes inbound and outbound REST messages to log." }, - "loggingSizeLimit": { "kind": "parameter", "displayName": "Logging Size Limit", "group": "common", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "description": "To limit the total size of number of bytes the logger will output when logging feature has been enabled." }, "modelRef": { "kind": "parameter", "displayName": "Model Ref", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option is used to specify the model file which is useful for the resource class without annotation. When using this option, then the service class can be omitted, to emulate document-only endpoints" }, "providers": { "kind": "parameter", "displayName": "Providers", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set custom JAX-RS provider(s) list to the CxfRs endpoint. You can specify a string with a list of providers to lookup in the registy separated by comma." }, "resourceClasses": { "kind": "parameter", "displayName": "Resource Classes", "group": "common", "label": "", "required": false, "type": "array", "javaType": "java.util.List<java.lang.Class<java.lang.Object>>", "deprecated": false, "autowired": false, "secret": false, "description": "The resource classes which you want to export as REST service. Multiple classes can be separated by comma." }, @@ -79,6 +77,8 @@ "defaultBus": { "kind": "parameter", "displayName": "Default Bus", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Will set the default bus when CXF endpoint create a bus by itself" }, "headerFilterStrategy": { "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter header to and from Camel message." }, "performInvocation": { "kind": "parameter", "displayName": "Perform Invocation", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "When the option is true, Camel will perform the invocation of the resource class instance and put the response object into the exchange for further processing." }, - "propagateContexts": { "kind": "parameter", "displayName": "Propagate Contexts", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "When the option is true, JAXRS UriInfo, HttpHeaders, Request and SecurityContext contexts will be available to custom CXFRS processors as typed Camel exchange properties. These contexts can be used to analyz [...] + "propagateContexts": { "kind": "parameter", "displayName": "Propagate Contexts", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "When the option is true, JAXRS UriInfo, HttpHeaders, Request and SecurityContext contexts will be available to custom CXFRS processors as typed Camel exchange properties. These contexts can be used to analyz [...] + "loggingFeatureEnabled": { "kind": "parameter", "displayName": "Logging Feature Enabled", "group": "logging", "label": "logging", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "This option enables CXF Logging Feature which writes inbound and outbound REST messages to log." }, + "loggingSizeLimit": { "kind": "parameter", "displayName": "Logging Size Limit", "group": "logging", "label": "logging", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 49152, "description": "To limit the total size of number of bytes the logger will output when logging feature has been enabled and -1 for no limit." } } } diff --git a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java index 09711197e16..97fefa84ffe 100644 --- a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java +++ b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java @@ -48,6 +48,7 @@ import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList; import org.apache.cxf.common.util.StringUtils; +import org.apache.cxf.ext.logging.AbstractLoggingInterceptor; import org.apache.cxf.ext.logging.LoggingFeature; import org.apache.cxf.feature.Feature; import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider; @@ -121,10 +122,10 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate private SSLContextParameters sslContextParameters; @UriParam(label = "producer") private HostnameVerifier hostnameVerifier; - @UriParam + @UriParam(label = "logging") private boolean loggingFeatureEnabled; - @UriParam - private int loggingSizeLimit; + @UriParam(label = "logging", defaultValue = "" + AbstractLoggingInterceptor.DEFAULT_LIMIT) + private int loggingSizeLimit = AbstractLoggingInterceptor.DEFAULT_LIMIT; @UriParam private boolean skipFaultLogging; @UriParam(label = "advanced", defaultValue = "30000", javaType = "java.time.Duration") @@ -377,7 +378,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate if (isLoggingFeatureEnabled()) { LoggingFeature loggingFeature = new LoggingFeature(); - if (getLoggingSizeLimit() > 0) { + if (getLoggingSizeLimit() >= -1) { loggingFeature.setLimit(getLoggingSizeLimit()); } factory.getFeatures().add(loggingFeature); @@ -527,9 +528,13 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate } /** - * To limit the total size of number of bytes the logger will output when logging feature has been enabled. + * To limit the total size of number of bytes the logger will output when logging feature has been enabled and -1 + * for no limit. */ public void setLoggingSizeLimit(int loggingSizeLimit) { + if (loggingSizeLimit < -1) { + throw new IllegalArgumentException("LoggingSizeLimit must be greater or equal to -1."); + } this.loggingSizeLimit = loggingSizeLimit; } diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java index b7bcadfa0c8..25d77839229 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfEndpoint.java @@ -191,7 +191,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade @UriParam(label = "logging") private boolean loggingFeatureEnabled; @UriParam(label = "logging", defaultValue = "" + AbstractLoggingInterceptor.DEFAULT_LIMIT) - private int loggingSizeLimit; + private int loggingSizeLimit = AbstractLoggingInterceptor.DEFAULT_LIMIT; @UriParam(label = "advanced") private boolean mtomEnabled; @UriParam(label = "advanced")
