You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/06/20 12:11:53 UTC

[camel] branch camel-3.20.x updated (5b21e54cd5a -> 8b36552236e)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 5b21e54cd5a Bump for next release
     new 761501cd9fb CAMEL-19476: rest-dsl - ClientRequestValidation accepted content-type may not validate correctly
     new 8b36552236e Regen

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 camel-dependencies/pom.xml                         | 23 +++++++-------
 .../camel/catalog/components/spring-rabbitmq.json  |  2 +-
 ...lidContentTypeClientRequestValidationTest.java} | 12 ++++----
 .../http/vertx/VertxPlatformHttpEngineTest.java    | 36 ++++++++++++++++++++++
 .../apache/camel/processor/RestBindingAdvice.java  |  6 ++--
 .../dsl/SpringRabbitMQEndpointBuilderFactory.java  | 16 ++++++----
 6 files changed, 68 insertions(+), 27 deletions(-)
 copy components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/{RestJettyInvalidJSonClientRequestValidationTest.java => RestJettyInvalidContentTypeClientRequestValidationTest.java} (85%)


[camel] 02/02: Regen

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8b36552236ed911400614d46f44f3771b2442c4d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jun 20 14:08:40 2023 +0200

    Regen
---
 camel-dependencies/pom.xml                         | 23 +++++++++++-----------
 .../camel/catalog/components/spring-rabbitmq.json  |  2 +-
 .../dsl/SpringRabbitMQEndpointBuilderFactory.java  | 16 +++++++++------
 3 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 70c6fd2a545..70d2f52ce63 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -17,7 +17,8 @@
     limitations under the License.
 
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache</groupId>
@@ -80,18 +81,18 @@
     <californium-scandium-version>2.7.4</californium-scandium-version>
     <californium-version>2.7.2</californium-version>
     <camel.failsafe.forkTimeout>600</camel.failsafe.forkTimeout>
-    <camel.osgi.activator />
-    <camel.osgi.dynamic />
+    <camel.osgi.activator></camel.osgi.activator>
+    <camel.osgi.dynamic></camel.osgi.dynamic>
     <camel.osgi.exclude.dependencies>false</camel.osgi.exclude.dependencies>
     <camel.osgi.export>${camel.osgi.export.pkg};-noimport:=true;${camel.osgi.version}</camel.osgi.export>
     <camel.osgi.export.pkg>$${replace;{local-packages};;;\;}</camel.osgi.export.pkg>
     <camel.osgi.failok>false</camel.osgi.failok>
     <camel.osgi.import>${camel.osgi.import.pkg}</camel.osgi.import>
-    <camel.osgi.import.additional />
-    <camel.osgi.import.before.defaults />
+    <camel.osgi.import.additional></camel.osgi.import.additional>
+    <camel.osgi.import.before.defaults></camel.osgi.import.before.defaults>
     <camel.osgi.import.camel.version>version="[$(version;==;${camel.osgi.version.clean}),$(version;=+;${camel.osgi.version.clean}))"</camel.osgi.import.camel.version>
     <camel.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</camel.osgi.import.default.version>
-    <camel.osgi.import.defaults />
+    <camel.osgi.import.defaults></camel.osgi.import.defaults>
     <camel.osgi.import.pkg>org.apache.camel.*;${camel.osgi.import.camel.version},
             ${camel.osgi.import.before.defaults},
             ${camel.osgi.import.defaults},
@@ -100,8 +101,8 @@
     <camel.osgi.import.strict.version>version="[$(version;===;${camel.osgi.version.clean}),$(version;==+;${camel.osgi.version.clean}))"</camel.osgi.import.strict.version>
     <camel.osgi.manifest>${project.build.outputDirectory}/META-INF/MANIFEST.MF</camel.osgi.manifest>
     <camel.osgi.private.pkg>!*</camel.osgi.private.pkg>
-    <camel.osgi.provide.capability />
-    <camel.osgi.require.capability />
+    <camel.osgi.provide.capability></camel.osgi.provide.capability>
+    <camel.osgi.require.capability></camel.osgi.require.capability>
     <camel.osgi.symbolic.name>${project.groupId}.${project.artifactId}</camel.osgi.symbolic.name>
     <camel.osgi.version>version=${project.version}</camel.osgi.version>
     <camel.surefire.fork.vmargs>-XX:+ExitOnOutOfMemoryError</camel.surefire.fork.vmargs>
@@ -154,9 +155,9 @@
     <cxf-version-range>[3.5,3.6)</cxf-version-range>
     <cxf-xjc-plugin-version>3.3.2</cxf-xjc-plugin-version>
     <cxf-xjc-utils-version>3.3.2</cxf-xjc-utils-version>
-    <cxf.codegen.jvmArgs />
+    <cxf.codegen.jvmArgs></cxf.codegen.jvmArgs>
     <cxf.codegenplugin.forkmode>true</cxf.codegenplugin.forkmode>
-    <cxf.xjc.jvmArgs />
+    <cxf.xjc.jvmArgs></cxf.xjc.jvmArgs>
     <datasonnet-mapper-version>2.1.4</datasonnet-mapper-version>
     <debezium-mysql-connector-version>8.0.28</debezium-mysql-connector-version>
     <debezium-version>1.9.6.Final</debezium-version>
@@ -432,7 +433,7 @@
     <nessus-ipfs-version>1.0.0.Beta4</nessus-ipfs-version>
     <nessus-weka-version>1.0.1</nessus-weka-version>
     <netty-reactive-streams-version>2.0.5</netty-reactive-streams-version>
-    <netty-version>4.1.92.Final</netty-version>
+    <netty-version>4.1.93.Final</netty-version>
     <networknt-json-schema-validator-version>1.0.73</networknt-json-schema-validator-version>
     <nimbus-jose-jwt>9.22</nimbus-jose-jwt>
     <nitrite-version>3.4.4</nitrite-version>
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spring-rabbitmq.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spring-rabbitmq.json
index 4d0d95c8614..43521761844 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spring-rabbitmq.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spring-rabbitmq.json
@@ -85,7 +85,7 @@
     "messageListenerContainerType": { "kind": "parameter", "displayName": "Message Listener Container Type", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "DMLC", "SMLC" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "DMLC", "description": "The type of the MessageListenerContainer" },
     "prefetchCount": { "kind": "parameter", "displayName": "Prefetch Count", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Tell the broker how many messages to send in a single request. Often this can be set quite high to improve throughput." },
     "retry": { "kind": "parameter", "displayName": "Retry", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.springframework.retry.interceptor.RetryOperationsInterceptor", "deprecated": false, "autowired": false, "secret": false, "description": "Custom retry configuration to use. If this is configured then the other settings such as maximumRetryAttempts for retry are not in use." },
-    "replyTimeout": { "kind": "parameter", "displayName": "Reply Timeout", "group": "producer", "label": "producer", "required": false, "type": "duration", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "5000", "description": "Specify the timeout in milliseconds to be used when waiting for a reply message when doing request\/reply messaging. The default value is 5 seconds. A negative value indicates an indefinite timeout." },
+    "replyTimeout": { "kind": "parameter", "displayName": "Reply Timeout", "group": "producer", "label": "producer", "required": false, "type": "duration", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "30000", "description": "Specify the timeout in milliseconds to be used when waiting for a reply message when doing request\/reply (InOut) messaging. The default value is 30 seconds. A negative value indicates an indefinite timeout (Beware th [...]
     "usePublisherConnection": { "kind": "parameter", "displayName": "Use Publisher Connection", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Use a separate connection for publishers and consumers" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may other [...]
     "args": { "kind": "parameter", "displayName": "Args", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "arg.", "multiValue": true, "deprecated": false, "autowired": false, "secret": false, "description": "Specify arguments for configuring the different RabbitMQ concepts, a different prefix is required for each element: arg.consumer. arg.exchange. arg.queue. arg.binding. arg.dlq.ex [...]
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpringRabbitMQEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpringRabbitMQEndpointBuilderFactory.java
index 2856e339d69..03ada76f6e1 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpringRabbitMQEndpointBuilderFactory.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpringRabbitMQEndpointBuilderFactory.java
@@ -1187,12 +1187,14 @@ public interface SpringRabbitMQEndpointBuilderFactory {
         }
         /**
          * Specify the timeout in milliseconds to be used when waiting for a
-         * reply message when doing request/reply messaging. The default value
-         * is 5 seconds. A negative value indicates an indefinite timeout.
+         * reply message when doing request/reply (InOut) messaging. The default
+         * value is 30 seconds. A negative value indicates an indefinite timeout
+         * (Beware that this will cause a memory leak if a reply is not
+         * received).
          * 
          * The option is a: &lt;code&gt;long&lt;/code&gt; type.
          * 
-         * Default: 5000
+         * Default: 30000
          * Group: producer
          * 
          * @param replyTimeout the value to set
@@ -1205,12 +1207,14 @@ public interface SpringRabbitMQEndpointBuilderFactory {
         }
         /**
          * Specify the timeout in milliseconds to be used when waiting for a
-         * reply message when doing request/reply messaging. The default value
-         * is 5 seconds. A negative value indicates an indefinite timeout.
+         * reply message when doing request/reply (InOut) messaging. The default
+         * value is 30 seconds. A negative value indicates an indefinite timeout
+         * (Beware that this will cause a memory leak if a reply is not
+         * received).
          * 
          * The option will be converted to a &lt;code&gt;long&lt;/code&gt; type.
          * 
-         * Default: 5000
+         * Default: 30000
          * Group: producer
          * 
          * @param replyTimeout the value to set


[camel] 01/02: CAMEL-19476: rest-dsl - ClientRequestValidation accepted content-type may not validate correctly

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 761501cd9fb12a6787127bca0e55b0d080279850
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jun 20 13:40:50 2023 +0200

    CAMEL-19476: rest-dsl - ClientRequestValidation accepted content-type may not validate correctly
---
 ...alidContentTypeClientRequestValidationTest.java | 67 ++++++++++++++++++++++
 .../http/vertx/VertxPlatformHttpEngineTest.java    | 36 ++++++++++++
 .../apache/camel/processor/RestBindingAdvice.java  |  6 +-
 3 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java
new file mode 100644
index 00000000000..59dcfcac051
--- /dev/null
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyInvalidContentTypeClientRequestValidationTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty.rest;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.base.HttpOperationFailedException;
+import org.apache.camel.model.rest.RestBindingMode;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class RestJettyInvalidContentTypeClientRequestValidationTest extends BaseJettyTest {
+
+    @Test
+    public void testJettyInvalidContentType() {
+        fluentTemplate = fluentTemplate.withHeader(Exchange.CONTENT_TYPE, "application/json")
+                .withHeader(Exchange.HTTP_METHOD, "post")
+                .withBody("{\"name\": \"Donald\"}")
+                .to("http://localhost:" + getPort() + "/users/123/update");
+
+        Exception ex = assertThrows(CamelExecutionException.class, () -> fluentTemplate.request(String.class));
+
+        // we send json but the service accepts only text/plain, so we get a 415
+        HttpOperationFailedException cause = assertIsInstanceOf(HttpOperationFailedException.class, ex.getCause());
+        assertEquals(415, cause.getStatusCode());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                // configure to use jetty on localhost with the given port
+                restConfiguration().component("jetty").host("localhost").port(getPort())
+                        .bindingMode(RestBindingMode.json)
+                        // turn on client request validation
+                        .clientRequestValidation(true);
+
+                // use the rest DSL to define the rest services
+                rest("/users/").post("{id}/update")
+                        .consumes("text/json").produces("application/json")
+                        .to("direct:update");
+                from("direct:update").setBody(constant("{ \"status\": \"ok\" }"));
+            }
+        };
+    }
+
+}
diff --git a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
index 4e15f971341..a02ab615c9e 100644
--- a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
+++ b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpEngineTest.java
@@ -45,6 +45,7 @@ import org.apache.camel.component.platform.http.HttpEndpointModel;
 import org.apache.camel.component.platform.http.PlatformHttpComponent;
 import org.apache.camel.component.platform.http.spi.Method;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.model.rest.RestBindingMode;
 import org.apache.camel.model.rest.RestParamType;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.support.jsse.KeyManagersParameters;
@@ -714,6 +715,41 @@ public class VertxPlatformHttpEngineTest {
         }
     }
 
+    @Test
+    public void testInvalidContentTypeClientRequestValidation() throws Exception {
+        final CamelContext context = createCamelContext();
+
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() {
+                    restConfiguration()
+                            .component("platform-http")
+                            .bindingMode(RestBindingMode.json)
+                            .clientRequestValidation(true);
+
+                    rest("/rest")
+                            .post("/validate/body").consumes("text/plain").produces("application/json")
+                            .to("direct:rest");
+                    from("direct:rest")
+                            .setBody(simple("Hello ${body}"));
+                }
+            });
+
+            context.start();
+
+            given()
+                    .when()
+                    .body("{\"name\": \"Donald\"}")
+                    .contentType("application/json")
+                    .post("/rest/validate/body")
+                    .then()
+                    .statusCode(415);
+        } finally {
+            context.stop();
+        }
+    }
+
     static CamelContext createCamelContext() throws Exception {
         return createCamelContext(null);
     }
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
index 8ddfedefeba..b6737e9f545 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
@@ -573,16 +573,16 @@ public class RestBindingAdvice implements CamelInternalProcessorAdvice<Map<Strin
         }
 
         boolean isXml = valid.contains("xml");
-        boolean isJson = valid.contains("json");
-
         if (isXml && !target.contains("xml")) {
             return false;
         }
+
+        boolean isJson = valid.contains("json");
         if (isJson && !target.contains("json")) {
             return false;
         }
 
-        return true;
+        return false;
     }
 
 }