This is an automated email from the ASF dual-hosted git repository.
Aias00 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 4b7ecea962 refactor(admin): remove unused deprecated registration lock
subsystem (#7426)
4b7ecea962 is described below
commit 4b7ecea9624529efcece28ab11bacbf468b3c148
Author: lymerin <[email protected]>
AuthorDate: Tue Oct 6 10:21:30 2026 +0800
refactor(admin): remove unused deprecated registration lock subsystem
(#7426)
---
.../admin/config/RegisterCenterConfiguration.java | 18 -----
.../shenyu/admin/lock/RegisterExecutionLock.java | 38 ---------
.../admin/lock/RegisterExecutionRepository.java | 47 -----------
.../impl/ForUpdateBackedRegisterExecutionLock.java | 92 ----------------------
...formTransactionRegisterExecutionRepository.java | 47 -----------
.../admin/lock/util/RegisterTransactionUtil.java | 56 -------------
.../ForUpdateBackedRegisterExecutionLockTest.java | 72 -----------------
.../lock/RegisterExecutionRepositoryTest.java | 48 -----------
8 files changed, 418 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/RegisterCenterConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/RegisterCenterConfiguration.java
index be5b4e1e1a..8397e476ed 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/RegisterCenterConfiguration.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/RegisterCenterConfiguration.java
@@ -18,17 +18,12 @@
package org.apache.shenyu.admin.config;
import
org.apache.shenyu.admin.disruptor.RegisterClientServerDisruptorPublisher;
-import org.apache.shenyu.admin.lock.RegisterExecutionRepository;
-import
org.apache.shenyu.admin.lock.impl.PlatformTransactionRegisterExecutionRepository;
-import org.apache.shenyu.admin.mapper.PluginMapper;
import org.apache.shenyu.admin.service.DiscoveryService;
import org.apache.shenyu.admin.service.register.ShenyuClientRegisterService;
import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig;
-import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.transaction.PlatformTransactionManager;
import java.util.List;
import java.util.Map;
@@ -67,17 +62,4 @@ public class RegisterCenterConfiguration {
return publisher;
}
- /**
- * Shenyu client server register server global lock repository.
- *
- * @param platformTransactionManager the platformTransactionManager
- * @param pluginMapper the shenyu pluginMapper
- * @return the shenyu server register repository
- */
- @Bean
- @ConditionalOnMissingBean(name = "registerExecutionRepository")
- public RegisterExecutionRepository registerExecutionRepository(final
PlatformTransactionManager platformTransactionManager, final PluginMapper
pluginMapper) {
- return new
PlatformTransactionRegisterExecutionRepository(platformTransactionManager,
pluginMapper);
- }
-
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionLock.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionLock.java
deleted file mode 100644
index fddf3a8c4d..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionLock.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.admin.lock;
-
-
-/**
- * The interface Register execution lock.
- * Deprecated: this class is deprecated and will be removed in the next major
version.
- * @since 2.6.1
- * @deprecated Please use {@link
org.springframework.integration.jdbc.lock.JdbcLockRegistry#obtain}.
- */
-@Deprecated
-public interface RegisterExecutionLock {
- /**
- * Acquire the client register lock.
- */
- void lock();
-
- /**
- * Release the client register lock.
- */
- void unlock();
-}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionRepository.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionRepository.java
deleted file mode 100644
index d47170dab2..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/RegisterExecutionRepository.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.admin.lock;
-
-/**
- * The interface Register execution repository.
- * Deprecated: this class is deprecated and will be removed in the next major
version.
- * @since 2.6.1
- * @deprecated Please use {@link
org.springframework.integration.jdbc.lock.DefaultLockRepository}.
- */
-@Deprecated
-public interface RegisterExecutionRepository {
- /**
- * Return the lock for the client register global allowing for the lock to
be acquired or released. Caution:
- * care should be made not to allow for a deadlock situation. If you
acquire a lock make sure you
- * release it when you are done. The general pattern for safely doing work
against a locked
- * client register follows:
- * <pre>
- * RegisterExecutionLock lock = repository.getLock(key);
- * lock.lock();
- * try {
- * // do register work
- * } finally {
- * lock.unlock();
- * }
- * </pre>
- * @param key the key
- * @return registerExecutionLock
- */
- RegisterExecutionLock getLock(String key);
-
-}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/ForUpdateBackedRegisterExecutionLock.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/ForUpdateBackedRegisterExecutionLock.java
deleted file mode 100644
index 5fc0b055b1..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/ForUpdateBackedRegisterExecutionLock.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.admin.lock.impl;
-
-import org.apache.shenyu.admin.lock.RegisterExecutionLock;
-import org.apache.shenyu.admin.lock.util.RegisterTransactionUtil;
-import org.apache.shenyu.admin.mapper.PluginMapper;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-
-/**
- * The type For update backed register execution lock.
- * Deprecated: this class is deprecated and will be removed in the next major
version.
- * @since 2.6.1
- * @deprecated Please use {@link
org.springframework.integration.jdbc.lock.JdbcLockRegistry#obtain}.
- */
-@Deprecated
-public class ForUpdateBackedRegisterExecutionLock implements
RegisterExecutionLock {
-
- private final PlatformTransactionManager transactionManager;
-
- private final PluginMapper pluginMapper;
-
- private final String name;
-
- private int lockTimeoutSeconds = 30;
-
- public ForUpdateBackedRegisterExecutionLock(final
PlatformTransactionManager transactionManager, final PluginMapper pluginMapper,
final String name) {
- this.transactionManager = transactionManager;
- this.pluginMapper = pluginMapper;
- this.name = name;
- }
-
- /**
- * select ... for update not allowing for the lock to be reentrant lock
- */
- @Override
- public void lock() {
- DefaultTransactionDefinition defaultTransactionDefinition = new
DefaultTransactionDefinition();
- defaultTransactionDefinition.setTimeout(lockTimeoutSeconds);
- TransactionStatus transaction =
transactionManager.getTransaction(defaultTransactionDefinition);
- RegisterTransactionUtil.set(transaction);
- pluginMapper.selectByNameForUpdate(name);
- }
-
- @Override
- public void unlock() {
- TransactionStatus transactionStatus = RegisterTransactionUtil.get();
- try {
- if (transactionStatus.isRollbackOnly()) {
- transactionManager.rollback(transactionStatus);
- return;
- }
- transactionManager.commit(transactionStatus);
- } finally {
- RegisterTransactionUtil.remove();
- }
- }
-
- /**
- * Returns the time period that can elapse before a timeout occurs on an
attempt to acquire a lock. The default is 30 seconds.
- * @return lockTimeoutSeconds
- */
- public int getLockTimeoutSeconds() {
- return lockTimeoutSeconds;
- }
-
- /**
- * Sets the time period that can elapse before a timeout occurs on an
attempt to acquire a lock. The
- * default is 30 seconds.
- * @param lockTimeoutSeconds the timeout period in seconds
- */
- public void setLockTimeoutSeconds(final int lockTimeoutSeconds) {
- this.lockTimeoutSeconds = lockTimeoutSeconds;
- }
-}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/PlatformTransactionRegisterExecutionRepository.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/PlatformTransactionRegisterExecutionRepository.java
deleted file mode 100644
index f085bc7bb0..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/impl/PlatformTransactionRegisterExecutionRepository.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.admin.lock.impl;
-
-import org.apache.shenyu.admin.lock.RegisterExecutionLock;
-import org.apache.shenyu.admin.lock.RegisterExecutionRepository;
-import org.apache.shenyu.admin.mapper.PluginMapper;
-import org.springframework.transaction.PlatformTransactionManager;
-
-/**
- * The type Platform transaction register execution repository.
- * Deprecated: this class is deprecated and will be removed in the next major
version.
- * @since 2.6.1
- * @deprecated Please use {@link
org.springframework.integration.jdbc.lock.DefaultLockRepository}.
- */
-@Deprecated
-public class PlatformTransactionRegisterExecutionRepository implements
RegisterExecutionRepository {
-
- private final PlatformTransactionManager platformTransactionManager;
-
- private final PluginMapper pluginMapper;
-
- public PlatformTransactionRegisterExecutionRepository(final
PlatformTransactionManager platformTransactionManager, final PluginMapper
pluginMapper) {
- this.platformTransactionManager = platformTransactionManager;
- this.pluginMapper = pluginMapper;
- }
-
- @Override
- public RegisterExecutionLock getLock(final String key) {
- return new
ForUpdateBackedRegisterExecutionLock(platformTransactionManager, pluginMapper,
key);
- }
-}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/util/RegisterTransactionUtil.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/util/RegisterTransactionUtil.java
deleted file mode 100644
index cbbdee313d..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/lock/util/RegisterTransactionUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.admin.lock.util;
-
-import org.springframework.core.NamedThreadLocal;
-import org.springframework.transaction.TransactionStatus;
-
-/**
- * The type Register transaction util.
- * @deprecated this class is deprecated and will be removed in the next major
version.
- *
- * @since 2.6.1
- */
-@Deprecated
-public final class RegisterTransactionUtil {
- private static final ThreadLocal<TransactionStatus>
TRANSACTION_INFO_HOLDER = new NamedThreadLocal<>("Current Shenyu Register
transaction");
-
- /**
- * set the transaction status.
- * @param status the transaction status
- */
- public static void set(final TransactionStatus status) {
- TRANSACTION_INFO_HOLDER.set(status);
- }
-
- /**
- * get the transaction status.
- * @return transaction status.
- */
- public static TransactionStatus get() {
- return TRANSACTION_INFO_HOLDER.get();
- }
-
- /**
- * remove transaction status.
- */
- public static void remove() {
- TRANSACTION_INFO_HOLDER.remove();
- }
-
-}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/ForUpdateBackedRegisterExecutionLockTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/ForUpdateBackedRegisterExecutionLockTest.java
deleted file mode 100644
index d63caa4681..0000000000
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/ForUpdateBackedRegisterExecutionLockTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.admin.lock;
-
-import org.apache.shenyu.admin.lock.impl.ForUpdateBackedRegisterExecutionLock;
-import org.apache.shenyu.admin.lock.util.RegisterTransactionUtil;
-import org.apache.shenyu.admin.mapper.PluginMapper;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.TransactionStatus;
-import org.springframework.transaction.support.DefaultTransactionDefinition;
-import org.springframework.transaction.support.DefaultTransactionStatus;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.any;
-
-@ExtendWith(MockitoExtension.class)
-public class ForUpdateBackedRegisterExecutionLockTest {
-
- private ForUpdateBackedRegisterExecutionLock lock;
-
- @Mock
- private PlatformTransactionManager transactionManager;
-
- @Mock
- private PluginMapper pluginMapper;
-
- @BeforeEach
- public void setup() {
- lock = new ForUpdateBackedRegisterExecutionLock(transactionManager,
pluginMapper, "testPlugin");
- }
-
- @Test
- public void lock() {
-
doReturn(mock(TransactionStatus.class)).when(transactionManager).getTransaction(any(DefaultTransactionDefinition.class));
- doReturn(null).when(pluginMapper).selectByNameForUpdate("testPlugin");
- lock.lock();
- verify(transactionManager,
times(1)).getTransaction(any(DefaultTransactionDefinition.class));
- verify(pluginMapper, times(1)).selectByNameForUpdate("testPlugin");
- }
-
- @Test
- public void unlock() {
- DefaultTransactionStatus status = new DefaultTransactionStatus(null,
true, true, false, false, null);
- RegisterTransactionUtil.set(status);
-
doNothing().when(transactionManager).commit(any(TransactionStatus.class));
- lock.unlock();
- verify(transactionManager,
times(1)).commit(any(TransactionStatus.class));
- }
-}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/RegisterExecutionRepositoryTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/RegisterExecutionRepositoryTest.java
deleted file mode 100644
index 11577ac483..0000000000
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/lock/RegisterExecutionRepositoryTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.admin.lock;
-
-import org.apache.shenyu.admin.lock.impl.ForUpdateBackedRegisterExecutionLock;
-import
org.apache.shenyu.admin.lock.impl.PlatformTransactionRegisterExecutionRepository;
-import org.apache.shenyu.admin.mapper.PluginMapper;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.mockito.junit.jupiter.MockitoSettings;
-import org.mockito.quality.Strictness;
-import org.springframework.transaction.PlatformTransactionManager;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-@ExtendWith(MockitoExtension.class)
-@MockitoSettings(strictness = Strictness.LENIENT)
-public class RegisterExecutionRepositoryTest {
- @Test
- public void getLock() {
- // Arrange
- final String key = "testKey";
- final PlatformTransactionManager platformTransactionManager =
mock(PlatformTransactionManager.class);
- final PluginMapper pluginMapper = mock(PluginMapper.class);
- final RegisterExecutionRepository repository = new
PlatformTransactionRegisterExecutionRepository(platformTransactionManager,
pluginMapper);
- // Act
- final RegisterExecutionLock lock = repository.getLock(key);
- // Assert
-
assertThat(lock).isInstanceOf(ForUpdateBackedRegisterExecutionLock.class);
- }
-}