[camel] branch master updated (8a242ab26 -> 7bcda65)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated (8a242ab26 -> 7bcda65)

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

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


    from 8a242ab26 CAMEL-15101: header binding mismatch
     new f15a623  CAMEL-15097: camel-core - Java DSL forbid multiple route inputs with from from from to
     new 7bcda65  camel-file - Work better on Java 8 due to java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear

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:
 .../org/apache/camel/component/file/FileOperations.java     | 13 ++++++++++---
 .../main/java/org/apache/camel/model/RouteDefinition.java   |  3 +++
 ...lidConfiguredTest.java => RouteOneInputAllowedTest.java} | 13 ++++++-------
 3 files changed, 19 insertions(+), 10 deletions(-)
 copy core/camel-core/src/test/java/org/apache/camel/processor/{OnCompletionInvalidConfiguredTest.java => RouteOneInputAllowedTest.java} (73%)

Reply | Threaded
Open this post in threaded view
|

[camel] 01/02: CAMEL-15097: camel-core - Java DSL forbid multiple route inputs with from from from to

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

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

commit f15a6239bd0af2cf4cbb0caf06fad7d7532f5b42
Author: Claus Ibsen <[hidden email]>
AuthorDate: Fri May 22 13:19:01 2020 +0200

    CAMEL-15097: camel-core - Java DSL forbid multiple route inputs with from from from to
---
 .../org/apache/camel/model/RouteDefinition.java    |  3 ++
 .../camel/processor/RouteOneInputAllowedTest.java  | 45 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/RouteDefinition.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/RouteDefinition.java
index e301408..9fd44a1 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/RouteDefinition.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/RouteDefinition.java
@@ -697,6 +697,9 @@ public class RouteDefinition extends OutputDefinition<RouteDefinition> implement
      */
     @XmlElementRef(required = false)
     public void setInput(FromDefinition input) {
+        if (this.input != null && input != null && this.input != input) {
+            throw new IllegalArgumentException("Only one input is allowed per route. Cannot accept input: " + input);
+        }
         // required = false: in rest-dsl you can embed an in-lined route which
         // does not have a <from> as its implied to be the rest endpoint
         this.input = input;
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/RouteOneInputAllowedTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/RouteOneInputAllowedTest.java
new file mode 100644
index 0000000..b8e9957
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/RouteOneInputAllowedTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class RouteOneInputAllowedTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testOneInput() throws Exception {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:a").from("direct:b").to("mock:ab");
+                }
+            });
+            fail("Should fail");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Only one input is allowed per route. Cannot accept input: From[direct:b]", e.getMessage());
+        }
+    }
+
+}

Reply | Threaded
Open this post in threaded view
|

[camel] 02/02: camel-file - Work better on Java 8 due to java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear

davsclaus-2
In reply to this post by davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

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

commit 7bcda658c0441866e68647074c33795547282bbc
Author: Claus Ibsen <[hidden email]>
AuthorDate: Fri May 22 13:19:21 2020 +0200

    camel-file - Work better on Java 8 due to java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear
---
 .../org/apache/camel/component/file/FileOperations.java     | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java b/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java
index 41cbe23..bb7018a 100644
--- a/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java
+++ b/components/camel-file/src/main/java/org/apache/camel/component/file/FileOperations.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.Writer;
+import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.SeekableByteChannel;
@@ -449,17 +450,23 @@ public class FileOperations implements GenericFileOperations<File> {
             int bytesRead;
             while ((bytesRead = in.read(buffer)) != -1) {
                 if (bytesRead < size) {
-                    byteBuffer.limit(bytesRead);
+                    // to be compatible with java 8
+                    Buffer buf = byteBuffer;
+                    buf.limit(bytesRead);
                 }
                 out.write(byteBuffer);
-                byteBuffer.clear();
+                // to be compatible with java 8
+                Buffer buf = byteBuffer;
+                buf.clear();
             }
 
             boolean append = endpoint.getFileExist() == GenericFileExist.Append;
             if (append && exists && endpoint.getAppendChars() != null) {
                 byteBuffer = ByteBuffer.wrap(endpoint.getAppendChars().getBytes());
                 out.write(byteBuffer);
-                byteBuffer.clear();
+                // to be compatible with java 8
+                Buffer buf = byteBuffer;
+                buf.clear();
             }
 
         } finally {