You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/07/16 05:22:48 UTC

[camel] branch main updated (2c28733 -> 854a087)

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

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


    from 2c28733  Regen for commit 0eb4182bd0e1861d2fd1b7586ee9fef542484129
     new b5a95f8  https://issues.apache.org/jira/browse/CAMEL-16807 : Fixed a problem with KafkaConfiguration:copy()
     new 854a087  CAMEL-15663 Added validation errors info in exception message

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:
 .../jsonvalidator/JsonValidationException.java     |  7 +++++-
 .../JsonValidationExceptionTest.java}              | 27 +++++++++++++---------
 .../camel/component/kafka/KafkaConfiguration.java  |  1 +
 3 files changed, 23 insertions(+), 12 deletions(-)
 copy components/camel-json-validator/src/{main/java/org/apache/camel/component/jsonvalidator/DefaultJsonValidationErrorHandler.java => test/java/org/apache/camel/component/jsonvalidator/JsonValidationExceptionTest.java} (53%)

[camel] 01/02: https://issues.apache.org/jira/browse/CAMEL-16807 : Fixed a problem with KafkaConfiguration:copy()

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

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

commit b5a95f84a2c0d961bb1a79926f4db7fe939f0dc6
Author: Eric Wittmann <er...@gmail.com>
AuthorDate: Thu Jul 15 08:17:07 2021 -0400

    https://issues.apache.org/jira/browse/CAMEL-16807 : Fixed a problem with KafkaConfiguration:copy()
---
 .../main/java/org/apache/camel/component/kafka/KafkaConfiguration.java   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
index ffdc9ce..febab8c 100644
--- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
+++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
@@ -343,6 +343,7 @@ public class KafkaConfiguration implements Cloneable, HeaderFilterStrategyAware
     public KafkaConfiguration copy() {
         try {
             KafkaConfiguration copy = (KafkaConfiguration) clone();
+            copy.additionalProperties = new HashMap<>(this.additionalProperties);
             return copy;
         } catch (CloneNotSupportedException e) {
             throw new RuntimeCamelException(e);

[camel] 02/02: CAMEL-15663 Added validation errors info in exception message

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

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

commit 854a08789c9ec74af99d65f338cdbdd310bf5f00
Author: g.dedlovskiy <g....@isimplelab.com>
AuthorDate: Thu Jul 15 22:35:08 2021 +0300

    CAMEL-15663 Added validation errors info in exception message
---
 .../jsonvalidator/JsonValidationException.java     |  7 +++-
 .../jsonvalidator/JsonValidationExceptionTest.java | 43 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
index 917955c..0284ac1 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidationException.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.jsonvalidator;
 
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import com.networknt.schema.JsonSchema;
 import com.networknt.schema.ValidationMessage;
@@ -31,7 +32,7 @@ public class JsonValidationException extends ValidationException {
     private final Set<ValidationMessage> errors;
 
     public JsonValidationException(Exchange exchange, JsonSchema schema, Set<ValidationMessage> errors) {
-        super(exchange, "JSON validation error with " + errors.size() + " errors");
+        super(exchange, "JSON validation error with " + errors.size() + " errors:\n" + toString(errors));
         this.schema = schema;
         this.errors = errors;
     }
@@ -53,4 +54,8 @@ public class JsonValidationException extends ValidationException {
     public int getNumberOfErrors() {
         return errors.size();
     }
+
+    private static String toString(Set<ValidationMessage> errors) {
+        return errors.stream().map(ValidationMessage::toString).collect(Collectors.joining("\n"));
+    }
 }
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/JsonValidationExceptionTest.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/JsonValidationExceptionTest.java
new file mode 100644
index 0000000..aa1b812
--- /dev/null
+++ b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/JsonValidationExceptionTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.jsonvalidator;
+
+import java.text.MessageFormat;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import com.networknt.schema.ValidationMessage;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class JsonValidationExceptionTest {
+
+    @Test
+    void testErrorsInfoInMessage() {
+        Set<ValidationMessage> errors = new LinkedHashSet<>();
+        errors.add(createError("name: is missing but it is required"));
+        errors.add(createError("id: string found, integer expected"));
+        assertEquals(
+                "JSON validation error with 2 errors:\nname: is missing but it is required\nid: string found, integer expected",
+                new JsonValidationException(null, null, errors).getMessage());
+    }
+
+    private ValidationMessage createError(String msg) {
+        return new ValidationMessage.Builder().format(new MessageFormat(msg)).build();
+    }
+}