This is an automated email from the ASF dual-hosted git repository.
likeguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 0f6fa8fee feat remove hutool dependent (#4777)
0f6fa8fee is described below
commit 0f6fa8feec75151d1080819508e6468df082b640
Author: zhengpeng <[email protected]>
AuthorDate: Wed Jun 28 14:24:30 2023 +0800
feat remove hutool dependent (#4777)
* feat: remove hutool dependent
* Empty Commit to setup deployments
---------
Co-authored-by: dragon-zhang <[email protected]>
---
pom.xml | 1 -
shenyu-client/shenyu-client-core/pom.xml | 5 --
.../shenyu/client/core/utils/OpenApiUtils.java | 5 +-
.../shenyu/client/core/utils/UrlPathUtils.java | 61 ++++++++++++++++++++++
4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5667eb5e5..e84fb9613 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,6 @@
<properties>
<java.version>1.8</java.version>
- <hutool.version>5.8.18</hutool.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jasypt.version>1.9.2</jasypt.version>
<springfox.version>2.6.1</springfox.version>
diff --git a/shenyu-client/shenyu-client-core/pom.xml
b/shenyu-client/shenyu-client-core/pom.xml
index db9b3cb0b..f1ce6befb 100644
--- a/shenyu-client/shenyu-client-core/pom.xml
+++ b/shenyu-client/shenyu-client-core/pom.xml
@@ -86,11 +86,6 @@
<artifactId>shenyu-client-api-docs-annotations</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>cn.hutool</groupId>
- <artifactId>hutool-all</artifactId>
- <version>${hutool.version}</version>
- </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
diff --git
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java
index dbdb28071..81e861227 100644
---
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java
+++
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java
@@ -17,7 +17,6 @@
package org.apache.shenyu.client.core.utils;
-import cn.hutool.core.net.url.UrlPath;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
@@ -27,7 +26,6 @@ import org.springframework.web.bind.annotation.RequestPart;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -82,8 +80,7 @@ public class OpenApiUtils {
}
}
} else {
- UrlPath urlPath = UrlPath.of(path, Charset.defaultCharset());
- List<String> segments = urlPath.getSegments();
+ List<String> segments = UrlPathUtils.getSegments(path);
for (String segment : segments) {
if (EVERY_PATH.equals(segment)) {
Parameter parameter = new Parameter();
diff --git
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java
new file mode 100644
index 000000000..d4e93b4bc
--- /dev/null
+++
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/UrlPathUtils.java
@@ -0,0 +1,61 @@
+/*
+ * 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.shenyu.client.core.utils;
+
+import org.apache.commons.lang3.StringUtils;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * UrlPathUtils.
+ */
+public class UrlPathUtils {
+
+ public static final String SLASH = "/";
+
+ /**
+ * getSegments.
+ * @param path path
+ * @return segments
+ */
+ public static List<String> getSegments(final String path) {
+ String fixPath = fixPath(path);
+ if (StringUtils.isNotEmpty(fixPath)) {
+ return Arrays.asList(StringUtils.split(fixPath, SLASH));
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * remove '/' and namespace .
+ * @param path path
+ * @return fixpath
+ */
+ public static String fixPath(final String path) {
+ if (StringUtils.equals(SLASH, path)) {
+ return StringUtils.EMPTY;
+ }
+ String segmentStr = StringUtils.trim(path);
+ segmentStr = StringUtils.removeStart(segmentStr, SLASH);
+ segmentStr = StringUtils.removeEnd(segmentStr, SLASH);
+ segmentStr = StringUtils.trim(segmentStr);
+ return segmentStr;
+ }
+
+}