You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2021/01/14 12:26:29 UTC

[camel-kafka-connector] 12/14: Use the StandardsCharset to avoid the UnsupportedEncodingException

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

orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git

commit 03f9486c52912b9037bc04d81d2eef98cd47218d
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Wed Jan 13 15:26:01 2021 +0100

    Use the StandardsCharset to avoid the UnsupportedEncodingException
---
 .../rabbitmq/sink/RabbitMQSinkITCase.java            | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/tests/itests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/sink/RabbitMQSinkITCase.java b/tests/itests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/sink/RabbitMQSinkITCase.java
index 8635469..d2c3ad6 100644
--- a/tests/itests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/sink/RabbitMQSinkITCase.java
+++ b/tests/itests-rabbitmq/src/test/java/org/apache/camel/kafkaconnector/rabbitmq/sink/RabbitMQSinkITCase.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.kafkaconnector.rabbitmq.sink;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.CountDownLatch;
 
 import com.rabbitmq.client.DeliverCallback;
@@ -63,22 +63,16 @@ public class RabbitMQSinkITCase extends AbstractKafkaTest {
     }
 
     private boolean checkRecord(Delivery rabbitMQDelivery) {
-        try {
-            String message = new String(rabbitMQDelivery.getBody(), "UTF-8");
-            LOG.debug("Received: {}", message);
-
-            received++;
+        String message = new String(rabbitMQDelivery.getBody(), StandardCharsets.UTF_8);
+        LOG.debug("Received: {}", message);
 
-            if (received == expect) {
-                return false;
-            }
+        received++;
 
-            return true;
-        } catch (UnsupportedEncodingException e) {
-            LOG.error("Failed to read message: {}", e.getMessage(), e);
-            fail("Failed to read message: " + e.getMessage());
+        if (received == expect) {
             return false;
         }
+
+        return true;
     }
 
     private void runBasicStringTest(ConnectorPropertyFactory connectorPropertyFactory) throws Exception {