orpiske commented on code in PR #10399:
URL: https://github.com/apache/camel/pull/10399#discussion_r1231235901


##########
core/camel-util/src/main/java/org/apache/camel/util/UnsafeUriCharactersDecoder.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.util;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class UnsafeUriCharactersDecoder {
+    private static final Map<String,String> unsafeStringsRfc1738;
+
+    static {
+        unsafeStringsRfc1738 = new HashMap<>();
+        unsafeStringsRfc1738.put("%22","\"");
+        unsafeStringsRfc1738.put("%3C","<");
+        unsafeStringsRfc1738.put("%3E",">");
+        unsafeStringsRfc1738.put("%7B","{");
+        unsafeStringsRfc1738.put("%7D","}");
+        unsafeStringsRfc1738.put("%7C","|");
+        unsafeStringsRfc1738.put("%5C","\\\\");
+        unsafeStringsRfc1738.put("%5E","^");
+        unsafeStringsRfc1738.put("%7E","~");
+        unsafeStringsRfc1738.put("%5B","[");
+        unsafeStringsRfc1738.put("%5D","]");
+        unsafeStringsRfc1738.put("%60","`");
+        unsafeStringsRfc1738.put("%20"," ");
+        unsafeStringsRfc1738.put("%23","#");
+    }
+
+    public static String decode(String uri){

Review Comment:
   Maybe add a bit more comments on this method? Ideally, a unit test case so 
that we/contributors/users know what to expect as in and out of this method?



##########
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java:
##########
@@ -710,21 +715,28 @@ public Collection<Endpoint> removeEndpoints(String uri) 
throws Exception {
             answer.add(oldEndpoint);
             stopServices(oldEndpoint);
         } else {
-            List<NormalizedUri> toRemove = new ArrayList<>();
-            for (Map.Entry<NormalizedUri, Endpoint> entry : 
endpoints.entrySet()) {
-                oldEndpoint = entry.getValue();
-                if (EndpointHelper.matchEndpoint(this, 
oldEndpoint.getEndpointUri(), uri)) {
-                    try {
-                        stopServices(oldEndpoint);
-                    } catch (Exception e) {
-                        LOG.warn("Error stopping endpoint {}. This exception 
will be ignored.", oldEndpoint, e);
+            String decodeUri = unsafeUriCharactersDecodeWithOutPercent(uri);
+            oldEndpoint = endpoints.remove(getEndpointKey(decodeUri));
+            if(oldEndpoint != null){
+                answer.add(oldEndpoint);
+                stopServices(oldEndpoint);
+            } else {
+                List<NormalizedUri> toRemove = new ArrayList<>();
+                for (Map.Entry<NormalizedUri, Endpoint> entry : 
endpoints.entrySet()) {
+                    oldEndpoint = entry.getValue();
+                    if (EndpointHelper.matchEndpoint(this, 
oldEndpoint.getEndpointUri(), uri)) {
+                        try {
+                            stopServices(oldEndpoint);
+                        } catch (Exception e) {
+                            LOG.warn("Error stopping endpoint " + oldEndpoint 
+ ". This exception will be ignored.", e);

Review Comment:
   Just one minor thing. Log like we used to do before (i.e.; using log 
markers). Like this:
   ```
   LOG.warn("Error stopping endpoint {}. This exception will be ignored.", 
oldEndpoint, e);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to