You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/20 15:02:02 UTC
[dubbo] branch 3.0 updated: fix StringIndexOutOfBoundsException at
addParam() (#8799)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new cf5eb3d fix StringIndexOutOfBoundsException at addParam() (#8799)
cf5eb3d is described below
commit cf5eb3d3fbdcf54ac2a2709136b8ab7804ea1df4
Author: zrlw <zr...@sina.com>
AuthorDate: Mon Sep 20 23:01:53 2021 +0800
fix StringIndexOutOfBoundsException at addParam() (#8799)
---
.../src/main/java/org/apache/dubbo/common/URLStrParser.java | 4 ++--
dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java b/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
index 0dde194..61b37db 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/URLStrParser.java
@@ -277,7 +277,7 @@ public final class URLStrParser {
if (isEncoded) {
String name = decodeComponent(str, nameStart, valueStart - 3, false, tempBuf);
String value;
- if (valueStart == valueEnd) {
+ if (valueStart >= valueEnd) {
value = name;
} else {
value = decodeComponent(str, valueStart, valueEnd, false, tempBuf);
@@ -290,7 +290,7 @@ public final class URLStrParser {
} else {
String name = str.substring(nameStart, valueStart - 1);
String value;
- if (valueStart == valueEnd) {
+ if (valueStart >= valueEnd) {
value = name;
} else {
value = str.substring(valueStart, valueEnd);
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
index a34045e..089bf1b 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/URLTest.java
@@ -1041,5 +1041,9 @@ public class URLTest {
Assertions.assertEquals("registry", url.getParameter("protocol"));
}
-
+ @Test
+ public void test_valueOfHasNameWithoutValue() throws Exception {
+ URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue");
+ Assertions.assertEquals("noValue", url.getParameter("noValue"));
+ }
}