This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new b8f8856868 [ISSUE #10105] Fix ClassCastException in getLocks() method
(#10106)
b8f8856868 is described below
commit b8f8856868f52e5a1095e4696adf4ed30f0e2c89
Author: yx9o <[email protected]>
AuthorDate: Mon Feb 23 14:43:45 2026 +0800
[ISSUE #10105] Fix ClassCastException in getLocks() method (#10106)
---
.../store/lock/AdaptiveBackOffSpinLockImpl.java | 5 +--
.../lock/AdaptiveBackOffSpinLockImplTest.java | 38 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git
a/store/src/main/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImpl.java
b/store/src/main/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImpl.java
index 1dfbd4718b..3c0de97644 100644
---
a/store/src/main/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImpl.java
+++
b/store/src/main/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImpl.java
@@ -20,6 +20,7 @@ import org.apache.rocketmq.store.config.MessageStoreConfig;
import java.time.LocalTime;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -166,8 +167,8 @@ public class AdaptiveBackOffSpinLockImpl implements
AdaptiveBackOffSpinLock {
}
}
- public List<AdaptiveBackOffSpinLock> getLocks() {
- return (List<AdaptiveBackOffSpinLock>) this.locks.values();
+ public Collection<AdaptiveBackOffSpinLock> getLocks() {
+ return this.locks.values();
}
public void setLocks(Map<String, AdaptiveBackOffSpinLock> locks) {
diff --git
a/store/src/test/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImplTest.java
b/store/src/test/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImplTest.java
new file mode 100644
index 0000000000..a210f55b77
--- /dev/null
+++
b/store/src/test/java/org/apache/rocketmq/store/lock/AdaptiveBackOffSpinLockImplTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.rocketmq.store.lock;
+
+import org.junit.Test;
+
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class AdaptiveBackOffSpinLockImplTest {
+
+ @Test
+ public void testGetLocks() {
+ AdaptiveBackOffSpinLockImpl lockImpl = new
AdaptiveBackOffSpinLockImpl();
+ Collection<AdaptiveBackOffSpinLock> locks = lockImpl.getLocks();
+ assertEquals(2, locks.size());
+ for (AdaptiveBackOffSpinLock lock : locks) {
+ assertNotNull(lock);
+ }
+ }
+}