This is an automated email from the ASF dual-hosted git repository.
zrlw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-hessian-lite.git
The following commit(s) were added to refs/heads/master by this push:
new 35c54e6c fix IdentityIntMap#toString IndexOutOfBoundsException
35c54e6c is described below
commit 35c54e6c14d7c20768105c2d9167cb9b2820f4e4
Author: wuwen <[email protected]>
AuthorDate: Wed Sep 10 10:07:38 2025 +0800
fix IdentityIntMap#toString IndexOutOfBoundsException
---
.../com/caucho/hessian/util/IdentityIntMap.java | 6 ++--
.../caucho/hessian/util/IdentityIntMapTest.java | 32 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git
a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java
b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java
index b604d5f1..1ec07b5b 100644
---
a/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java
+++
b/hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/util/IdentityIntMap.java
@@ -237,16 +237,18 @@ public class IdentityIntMap {
return System.identityHashCode(value);
}
+ @Override
public String toString() {
StringBuffer sbuf = new StringBuffer();
sbuf.append("IntMap[");
boolean isFirst = true;
- for (int i = 0; i <= _keys.length; i++) {
+ for (int i = 0; i < _keys.length; i++) {
if (_keys[i] != null) {
- if (!isFirst)
+ if (!isFirst) {
sbuf.append(", ");
+ }
isFirst = false;
sbuf.append(_keys[i]);
diff --git
a/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/util/IdentityIntMapTest.java
b/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/util/IdentityIntMapTest.java
new file mode 100644
index 00000000..90c46a09
--- /dev/null
+++
b/java-8-test/src/test/java/com/alibaba/com/caucho/hessian/util/IdentityIntMapTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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 com.alibaba.com.caucho.hessian.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class IdentityIntMapTest {
+
+ @Test
+ void fixToString() {
+ IdentityIntMap map = new IdentityIntMap(256);
+ map.put("a", 1, false);
+
+ Assertions.assertDoesNotThrow(map::toString);
+ Assertions.assertEquals("IntMap[a:1]", map.toString());
+ }
+}