You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by il...@apache.org on 2019/07/18 03:45:38 UTC
[dubbo] branch master updated: Fixed IndexOutOfBoundsException
(#4515)
This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 8a50b2f Fixed IndexOutOfBoundsException (#4515)
8a50b2f is described below
commit 8a50b2f7830ba720dfba0cb29a7660cfb4ffba23
Author: Maximilian Gama <ma...@yahoo.com>
AuthorDate: Thu Jul 18 06:45:30 2019 +0300
Fixed IndexOutOfBoundsException (#4515)
---
dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java | 4 ++++
.../src/test/java/org/apache/dubbo/common/io/BytesTest.java | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java b/dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java
index 263e7b9..5112dcf 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/io/Bytes.java
@@ -730,8 +730,12 @@ public class Bytes {
char pc = code[64];
if (str.charAt(off + len - 2) == pc) {
size -= 2;
+ --num;
+ rem = 2;
} else if (str.charAt(off + len - 1) == pc) {
size--;
+ --num;
+ rem = 3;
}
} else {
if (rem == 2) {
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/io/BytesTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/io/BytesTest.java
index 71b915c..cae1a83 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/common/io/BytesTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/common/io/BytesTest.java
@@ -91,6 +91,14 @@ public class BytesTest {
}
@Test
+ public void testBase642bCharArrCall() {
+ byte[] stringCall = Bytes.base642bytes("ZHViYm8=", C64);
+ byte[] charArrCall = Bytes.base642bytes("ZHViYm8=", C64.toCharArray());
+
+ assertThat(stringCall, is(charArrCall));
+ }
+
+ @Test
public void testHex() {
String str = Bytes.bytes2hex(b1);
assertThat(b1, is(Bytes.hex2bytes(str)));