Use the StandardsCharset to avoid the UnsupportedEncodingException
*/
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,8 +63,7 @@ public class RabbitMQSinkITCase extends AbstractKafkaTest {
}
private boolean checkRecord(Delivery rabbitMQDelivery) {
- try {
- String message = new String(rabbitMQDelivery.getBody(), "UTF-8");
+ String message = new String(rabbitMQDelivery.getBody(), StandardCharsets.UTF_8);
LOG.debug("Received: {}", message);
received++;
@@ -74,11 +73,6 @@ public class RabbitMQSinkITCase extends AbstractKafkaTest {
}
return true;
- } catch (UnsupportedEncodingException e) {
- LOG.error("Failed to read message: {}", e.getMessage(), e);
- fail("Failed to read message: " + e.getMessage());
- return false;
- }
}
private void runBasicStringTest(ConnectorPropertyFactory connectorPropertyFactory) throws Exception {
