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 2023/09/14 08:46:54 UTC

[camel] branch main updated: CAMEL-19868: removed unused exception in URISupport.normalizeUri (#11391)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 62e0c748d97 CAMEL-19868: removed unused exception in URISupport.normalizeUri (#11391)
62e0c748d97 is described below

commit 62e0c748d97cf419ca353aaf841fe39e4f55ce96
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Thu Sep 14 10:46:45 2023 +0200

    CAMEL-19868: removed unused exception in URISupport.normalizeUri (#11391)
    
    This should simplify consolidating duplicate code from camel-core-catalog
---
 .../component/telegram/service/TelegramServiceRestBotAPIAdapter.java | 2 +-
 .../src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java | 3 ++-
 .../src/main/java/org/apache/camel/model/RouteDefinitionHelper.java  | 2 +-
 .../src/main/java/org/apache/camel/support/EndpointHelper.java       | 2 +-
 core/camel-util/src/main/java/org/apache/camel/util/URISupport.java  | 5 ++---
 .../src/test/java/org/apache/camel/test/infra/core/MockUtils.java    | 4 +++-
 6 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
index dcbcfed05ff..2a11dac72b3 100644
--- a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
+++ b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java
@@ -140,7 +140,7 @@ public class TelegramServiceRestBotAPIAdapter implements TelegramService {
 
             final HttpRequest request = HttpRequest.newBuilder().uri(URI.create(uri)).GET().build();
             return sendSyncRequest(request, UpdateResult.class);
-        } catch (URISyntaxException | UnsupportedEncodingException e) {
+        } catch (URISyntaxException e) {
             throw new RuntimeException(e);
         }
     }
diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
index 349e5ca2a12..89788104aa6 100644
--- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
+++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java
@@ -17,6 +17,7 @@
 package org.apache.camel.test.junit5;
 
 import java.lang.annotation.Annotation;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -869,7 +870,7 @@ public abstract class CamelTestSupport
         String n;
         try {
             n = URISupport.normalizeUri(uri);
-        } catch (Exception e) {
+        } catch (URISyntaxException e) {
             throw RuntimeCamelException.wrapRuntimeException(e);
         }
         // strip query
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
index d803efc03ad..9cbf27ccc3c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
@@ -114,7 +114,7 @@ public final class RouteDefinitionHelper {
     private static String normalizeUri(String uri) {
         try {
             return URISupport.normalizeUri(uri);
-        } catch (UnsupportedEncodingException | URISyntaxException e) {
+        } catch (URISyntaxException e) {
             // ignore
         }
         return null;
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
index c37820caa3f..a24f6101bcb 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/EndpointHelper.java
@@ -161,7 +161,7 @@ public final class EndpointHelper {
     public static String normalizeEndpointUri(String uri) {
         try {
             uri = URISupport.normalizeUri(uri);
-        } catch (Exception e) {
+        } catch (URISyntaxException e) {
             throw new ResolveEndpointFailedException(uri, e);
         }
         return uri;
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
index 76478f0ebdd..94e7c2c3fef 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/URISupport.java
@@ -541,7 +541,7 @@ public final class URISupport {
      * @throws UnsupportedEncodingException is thrown if encoding error
      */
     public static String appendParametersToURI(String originalURI, Map<String, Object> newParameters)
-            throws URISyntaxException, UnsupportedEncodingException {
+            throws URISyntaxException {
         URI uri = new URI(normalizeUri(originalURI));
         Map<String, Object> parameters = parseParameters(uri);
         parameters.putAll(newParameters);
@@ -559,12 +559,11 @@ public final class URISupport {
      * @param  uri                          the uri
      * @return                              the normalized uri
      * @throws URISyntaxException           in thrown if the uri syntax is invalid
-     * @throws UnsupportedEncodingException is thrown if encoding error
      * @see                                 #RAW_TOKEN_PREFIX
      * @see                                 #RAW_TOKEN_START
      * @see                                 #RAW_TOKEN_END
      */
-    public static String normalizeUri(String uri) throws URISyntaxException, UnsupportedEncodingException {
+    public static String normalizeUri(String uri) throws URISyntaxException {
         // try to parse using the simpler and faster Camel URI parser
         String[] parts = CamelURIParser.fastParseUri(uri);
         if (parts != null) {
diff --git a/test-infra/camel-test-infra-core/src/test/java/org/apache/camel/test/infra/core/MockUtils.java b/test-infra/camel-test-infra-core/src/test/java/org/apache/camel/test/infra/core/MockUtils.java
index c05a7a28bb9..c7aa6a1abd0 100644
--- a/test-infra/camel-test-infra-core/src/test/java/org/apache/camel/test/infra/core/MockUtils.java
+++ b/test-infra/camel-test-infra-core/src/test/java/org/apache/camel/test/infra/core/MockUtils.java
@@ -17,6 +17,8 @@
 
 package org.apache.camel.test.infra.core;
 
+import java.net.URISyntaxException;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.NoSuchEndpointException;
@@ -73,7 +75,7 @@ public final class MockUtils {
         String n;
         try {
             n = URISupport.normalizeUri(uri);
-        } catch (Exception e) {
+        } catch (URISyntaxException e) {
             throw RuntimeCamelException.wrapRuntimeException(e);
         }
         // strip query