Repository: huaweicloud/sermant
Issue: 【bug】fix the registry plugin bugs

### What happened?

can not work

### How can we reproduce it (as minimally and precisely as possible)?

no

### Anything else we need to know?

_No response_

### Sermant version

<details>
0.6.0
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```
</details>


Changed files:
sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/utils/RequestInterceptorUtils.java

diff --git a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/utils/RequestInterceptorUtils.java b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/utils/RequestInterceptorUtils.java
index 0ed24ac4..63471709 100644
--- a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/utils/RequestInterceptorUtils.java
+++ b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/utils/RequestInterceptorUtils.java
@@ -31,6 +31,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -62,23 +63,27 @@ public class RequestInterceptorUtils {
      */
     public static Map<String, String> recovertUrl(String url) {
         if (StringUtils.isEmpty(url)) {
-            return new HashMap<>();
+            return Collections.emptyMap();
         }
-        Map<String, String> result = new HashMap<>();
-        String scheme = url.substring(0, url.indexOf(HttpConstants.HTTP_URL_DOUBLIE_SLASH));
         String temp = url.substring(url.indexOf(HttpConstants.HTTP_URL_DOUBLIE_SLASH)
-                + HttpConstants.HTTP_URL_DOUBLIE_SLASH.length());
+            + HttpConstants.HTTP_URL_DOUBLIE_SLASH.length());
         int slashLen = 1;
 
         // 剔除域名之后的path
         temp = temp.substring(temp.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH) + slashLen);
 
         // 服务名
-        String host = temp.substring(0, temp.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH));
+        int index = temp.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH);
+        if (index == -1) {
+            return Collections.emptyMap();
+        }
+        String host = temp.substring(0, index);
 
         // 请求路径
         String path = temp.substring(temp.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH));
+        Map<String, String> result = new HashMap<>();
         result.put(HttpConstants.HTTP_URI_HOST, host);
+        String scheme = url.substring(0, url.indexOf(HttpConstants.HTTP_URL_DOUBLIE_SLASH));
         result.put(HttpConstants.HTTP_URL_SCHEME, scheme);
         result.put(HttpConstants.HTTP_URI_PATH, path);
         return result;
@@ -92,7 +97,7 @@ public class RequestInterceptorUtils {
      */
     public static void printRequestLog(String source, Map<String, String> hostAndPath) {
         String path = String.format(Locale.ENGLISH, "/%s%s", hostAndPath.get(HttpConstants.HTTP_URI_HOST),
-                hostAndPath.get(HttpConstants.HTTP_URI_PATH));
+            hostAndPath.get(HttpConstants.HTTP_URI_PATH));
         LOGGER.log(Level.FINE, String.format(Locale.ENGLISH, "[%s] request [%s] has been intercepted!", source, path));
         RECORDER.beforeRequest();
     }
@@ -138,11 +143,11 @@ public class RequestInterceptorUtils {
                 return method.invoke(context.getObject(), context.getArguments());
             } catch (IllegalAccessException e) {
                 LOGGER.log(Level.SEVERE, String.format(Locale.ENGLISH, "Can not invoke method [%s]",
-                        context.getMethod().getName()), e);
+                    context.getMethod().getName()), e);
             } catch (InvocationTargetException e) {
                 invokerContext.setEx(e.getTargetException());
                 LOGGER.log(Level.FINE, String.format(Locale.ENGLISH, "invoke method [%s] failed",
-                        context.getMethod().getName()), e.getTargetException());
+                    context.getMethod().getName()), e);
             }
             return Optional.empty();
         };
@@ -158,11 +163,11 @@ public class RequestInterceptorUtils {
     public static String buildUrl(Map<String, String> urlIfo, ServiceInstance serviceInstance) {
         StringBuilder urlBuild = new StringBuilder();
         urlBuild.append(urlIfo.get(HttpConstants.HTTP_URL_SCHEME))
-                .append(HttpConstants.HTTP_URL_DOUBLIE_SLASH)
-                .append(serviceInstance.getIp())
-                .append(HttpConstants.HTTP_URL_COLON)
-                .append(serviceInstance.getPort())
-                .append(urlIfo.get(HttpConstants.HTTP_URI_PATH));
+            .append(HttpConstants.HTTP_URL_DOUBLIE_SLASH)
+            .append(serviceInstance.getIp())
+            .append(HttpConstants.HTTP_URL_COLON)
+            .append(serviceInstance.getPort())
+            .append(urlIfo.get(HttpConstants.HTTP_URI_PATH));
         return urlBuild.toString();
     }
 
@@ -186,9 +191,9 @@ public class RequestInterceptorUtils {
             return result;
         }
         result.put(HttpConstants.HTTP_URI_HOST,
-                tempPath.substring(0, tempPath.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH)));
+            tempPath.substring(0, tempPath.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH)));
         result.put(HttpConstants.HTTP_URI_PATH,
-                tempPath.substring(tempPath.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH)));
+            tempPath.substring(tempPath.indexOf(HttpConstants.HTTP_URL_SINGLE_SLASH)));
         return result;
     }
 
@@ -204,14 +209,14 @@ public class RequestInterceptorUtils {
     public static String buildUrlWithIp(URI uri, ServiceInstance serviceInstance, String path, String method) {
         StringBuilder urlBuild = new StringBuilder();
         urlBuild.append(uri.getScheme())
-                .append(HttpConstants.HTTP_URL_DOUBLIE_SLASH)
-                .append(serviceInstance.getIp())
-                .append(HttpConstants.HTTP_URL_COLON)
-                .append(serviceInstance.getPort())
-                .append(path);
+            .append(HttpConstants.HTTP_URL_DOUBLIE_SLASH)
+            .append(serviceInstance.getIp())
+            .append(HttpConstants.HTTP_URL_COLON)
+            .append(serviceInstance.getPort())
+            .append(path);
         if (method.equals(HttpConstants.HTTP_GET)) {
             urlBuild.append(HttpConstants.HTTP_URL_UNKNOWN)
-                    .append(uri.getQuery());
+                .append(uri.getQuery());
         }
         return urlBuild.toString();
     }