This is an automated email from the ASF dual-hosted git repository.
hefengen 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 03a665f06 [type:fix] Polish Code. (#4945)
03a665f06 is described below
commit 03a665f06b22a033b504b1d3a5905b9309c9abda
Author: gongzhongqiang <[email protected]>
AuthorDate: Thu Aug 3 18:29:24 2023 +0800
[type:fix] Polish Code. (#4945)
* [type:fix] Polish Code.
* [type:fix] Polish Code.
* address comment
* fix ci
* address comment
* fix ci
---------
Co-authored-by: gongzhongqiang <[email protected]>
Co-authored-by: moremind <[email protected]>
---
.../shenyu/admin/config/DataSyncConfiguration.java | 6 +++---
.../admin/service/impl/TagRelationServiceImpl.java | 2 +-
.../apache/shenyu/admin/service/impl/TagServiceImpl.java | 2 +-
.../admin/service/manager/impl/SwaggerDocParser.java | 2 +-
.../shenyu/admin/AbstractReflectGetterSetterTest.java | 4 ++--
.../apache/shenyu/admin/aspect/PageableAspectTest.java | 10 +++++-----
.../shenyu/admin/controller/ApiControllerTest.java | 4 ++--
.../shenyu/admin/controller/AppAuthControllerTest.java | 4 ++--
.../admin/controller/DataPermissionControllerTest.java | 8 ++++----
.../shenyu/admin/controller/MetaDataControllerTest.java | 4 ++--
.../admin/controller/PermissionControllerTest.java | 13 ++++++++-----
.../shenyu/admin/controller/PluginControllerTest.java | 16 ++++++++--------
.../shenyu/admin/controller/SandboxControllerTest.java | 3 +--
.../subscriber/MetadataExecutorSubscriberTest.java | 3 ++-
.../subscriber/URIRegisterExecutorSubscriberTest.java | 3 ++-
.../shenyu/admin/listener/apollo/ApolloClientTest.java | 12 ++++++------
.../listener/apollo/ApolloDataChangedListenerTest.java | 16 ++++++++--------
.../shenyu/admin/mapper/DiscoveryUpstreamMapperTest.java | 10 +++++-----
.../shenyu/admin/mapper/MockRequestRecordMapperTest.java | 2 +-
.../shenyu/admin/mapper/ProxySelectorMapperTest.java | 9 +++++----
.../admin/service/DiscoveryUpstreamServiceTest.java | 6 +++---
.../shenyu/admin/shiro/bean/StatelessAuthFilterTest.java | 7 ++++---
.../admin/shiro/config/ShiroConfigurationTest.java | 5 +++--
.../apache/shenyu/admin/shiro/config/ShiroRealmTest.java | 3 ++-
.../org/apache/shenyu/admin/utils/HttpUtilsTest.java | 2 +-
.../shenyu/client/core/shutdown/ShutdownHookManager.java | 8 ++++----
.../dubbo/validation/AlibabaDubboClientValidator.java | 10 ++++------
.../dubbo/validation/ApacheDubboClientValidator.java | 10 ++++------
.../springcloud/annotation/ShenyuDeleteMappingTest.java | 2 +-
.../springcloud/annotation/ShenyuGetMappingTest.java | 2 +-
.../springcloud/annotation/ShenyuPatchMappingTest.java | 2 +-
.../springcloud/annotation/ShenyuPostMappingTest.java | 2 +-
.../springcloud/annotation/ShenyuPutMappingTest.java | 2 +-
.../init/SpringCloudClientEventListenerTest.java | 6 +++---
.../springmvc/annotation/ShenyuDeleteMappingTest.java | 2 +-
.../springmvc/annotation/ShenyuGetMappingTest.java | 2 +-
.../springmvc/annotation/ShenyuPatchMappingTest.java | 2 +-
.../springmvc/annotation/ShenyuPostMappingTest.java | 2 +-
.../springmvc/annotation/ShenyuPutMappingTest.java | 2 +-
.../springmvc/init/SpringMvcClientEventListenerTest.java | 8 ++++----
.../client/tars/TarsServiceBeanPostProcessorTest.java | 8 ++++----
.../websocket/init/ShenyuServerEndpointerExporter.java | 2 +-
.../shenyu/common/enums/PluginHandlerEventEnum.java | 2 +-
.../org/apache/shenyu/common/enums/TrieEventEnum.java | 2 +-
.../common/cache/MemorySafeWindowTinyLFUMapTest.java | 2 +-
.../apache/shenyu/common/cache/WindowTinyLFUMapTest.java | 2 ++
.../org/apache/shenyu/common/dto/WebsocketDataTest.java | 7 ++++---
.../convert/rule/impl/ModifyResponseRuleHandleTest.java | 7 ++++---
.../convert/rule/impl/ParamMappingRuleHandleTest.java | 7 ++++---
.../convert/selector/SpringCloudSelectorHandleTest.java | 3 ++-
.../org/apache/shenyu/common/utils/ThreadUtilsTest.java | 2 +-
.../org/apache/shenyu/loadbalancer/entity/Upstream.java | 4 ++--
.../apache/shenyu/loadbalancer/spi/P2cLoadBalancer.java | 2 +-
.../spi/ShortestResponseLoadBalancerTest.java | 4 ++--
.../executor/RedisRateLimiterScriptsTest.java | 8 ++++----
.../resilience4j/handler/Resilience4JHandlerTest.java | 8 ++++----
.../config/ClickHouseLogCollectConfigTest.java | 4 ++--
.../apache/shenyu/plugin/divide/DividePluginTest.java | 5 +++--
.../plugin/mqtt/handler/MqttPluginDataHandler.java | 4 +---
.../shenyu/plugin/brpc/spi/SharedThreadPoolFactory.java | 4 ++--
.../apache/dubbo/cache/ApacheDubboConfigCacheTest.java | 1 -
.../shenyu/plugin/sofa/cache/ApplicationConfigCache.java | 1 -
.../shenyu/plugin/tars/cache/ApplicationConfigCache.java | 1 -
.../context/SpringCloudShenyuContextDecoratorTest.java | 4 ++--
.../handler/SpringCloudPluginDataHandlerTest.java | 2 +-
.../shenyu/plugin/websocket/WebSocketPluginTest.java | 2 +-
.../context/WebSocketShenyuContextDecoratorTest.java | 2 +-
.../handler/WebSocketPluginDataHandlerTest.java | 8 ++++----
.../rewrite/handler/RewritePluginDataHandlerTest.java | 8 ++++----
.../register/client/server/apollo/ApolloClientTest.java | 15 ++++++++-------
.../PolarisClientServerRegisterRepositoryTest.java | 2 +-
.../client/server/zookeeper/ZookeeperClient.java | 3 ++-
.../ZookeeperClientServerRegisterRepository.java | 6 +++---
.../shenyu/register/client/apollo/ApolloClientTest.java | 12 ++++++------
.../register/client/http/utils/OkHttpToolsTest.java | 2 +-
.../polaris/PolarisClientRegisterRepositoryTest.java | 2 +-
.../register/client/zookeeper/ZookeeperClient.java | 3 ++-
.../apache/shenyu/registry/apollo/ApolloClientTest.java | 12 ++++++------
.../shenyu/registry/zookeeper/ZookeeperClient.java | 3 ++-
.../sdk/spring/proxy/ShenyuClientMethodHandler.java | 2 +-
.../shenyu/sdk/spring/support/SpringMvcContract.java | 14 ++++++--------
.../sync/data/nacos/config/NacosACMConfigTest.java | 11 +++++------
.../shenyu/sync/data/nacos/config/NacosConfigTest.java | 11 +++++------
.../sync/data/polaris/handler/PolarisMockConfigFile.java | 2 +-
.../shenyu/sync/data/zookeeper/ZookeeperClient.java | 3 ++-
.../org/apache/shenyu/web/handler/ShenyuWebHandler.java | 2 +-
86 files changed, 223 insertions(+), 216 deletions(-)
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
index 5ef6ddae9..6f657d8f5 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
@@ -68,7 +68,7 @@ import
org.springframework.web.socket.server.standard.ServerEndpointExporter;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Objects;
import java.util.Properties;
@@ -234,7 +234,7 @@ public class DataSyncConfiguration {
@ConditionalOnMissingBean(ConfigFileService.class)
public ConfigFileService polarisConfigFileService(final
PolarisProperties polarisProperties) {
com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
-
configuration.getConfigFile().getServerConnector().setAddresses(Arrays.asList(polarisProperties.getUrl()));
+
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
return
ConfigFileServiceFactory.createConfigFileService(configuration);
}
@@ -247,7 +247,7 @@ public class DataSyncConfiguration {
@ConditionalOnMissingBean(ConfigFilePublishService.class)
public ConfigFilePublishService polarisConfigFilePublishService(final
PolarisProperties polarisProperties) {
com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
-
configuration.getConfigFile().getServerConnector().setAddresses(Arrays.asList(polarisProperties.getUrl()));
+
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
return
ConfigFileServicePublishFactory.createConfigFilePublishService(configuration);
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagRelationServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagRelationServiceImpl.java
index 69140a9b2..9964a9f26 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagRelationServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagRelationServiceImpl.java
@@ -34,7 +34,7 @@ import org.springframework.stereotype.Service;
@Service
public class TagRelationServiceImpl implements TagRelationService {
- private TagRelationMapper tagRelationMapper;
+ private final TagRelationMapper tagRelationMapper;
public TagRelationServiceImpl(final TagRelationMapper tagRelationMapper) {
this.tagRelationMapper = tagRelationMapper;
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagServiceImpl.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagServiceImpl.java
index 543d5a5a1..e95582555 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagServiceImpl.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagServiceImpl.java
@@ -45,7 +45,7 @@ import org.springframework.stereotype.Service;
@Service
public class TagServiceImpl implements TagService {
- private TagMapper tagMapper;
+ private final TagMapper tagMapper;
public TagServiceImpl(final TagMapper tagMapper) {
this.tagMapper = tagMapper;
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
index 03175efc4..5d33b241c 100755
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
@@ -317,7 +317,7 @@ public class SwaggerDocParser implements DocParser {
private RefInfo getRefInfo(final JsonObject jsonObject) {
JsonElement refElement;
- boolean isArray = Objects.isNull(jsonObject.get("type")) ? false :
"array".equals(jsonObject.get("type").getAsString());
+ boolean isArray = Objects.nonNull(jsonObject.get("type")) &&
"array".equals(jsonObject.get("type").getAsString());
if (isArray) {
refElement = jsonObject.getAsJsonObject("items").get("$ref");
} else {
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/AbstractReflectGetterSetterTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/AbstractReflectGetterSetterTest.java
index 51f586af0..54550cdc2 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/AbstractReflectGetterSetterTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/AbstractReflectGetterSetterTest.java
@@ -27,7 +27,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Timestamp;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -88,7 +87,7 @@ public abstract class AbstractReflectGetterSetterTest {
protected abstract Class<?> getTargetClass();
protected Set<String> getExcludeFields() {
- return new HashSet<>(Arrays.asList("serialVersionUID"));
+ return new HashSet<>(Collections.singletonList("serialVersionUID"));
}
/**
@@ -97,6 +96,7 @@ public abstract class AbstractReflectGetterSetterTest {
* @throws Exception maybe throw reflect Exception.
*/
@Test
+ @SuppressWarnings("all")
public void testGetAndSet() throws Exception {
Class<?> clazz = getTargetClass();
Object target = clazz.getDeclaredConstructor().newInstance();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/aspect/PageableAspectTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/aspect/PageableAspectTest.java
index 15ddda91e..dcb071836 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/aspect/PageableAspectTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/aspect/PageableAspectTest.java
@@ -102,11 +102,11 @@ public class PageableAspectTest {
page.setPages(20);
page.setTotal(1000);
pageableAspect.convert(page, pageParameter);
- assertTrue(page.getPageNum() == pageParameter.getCurrentPage());
- assertTrue(page.getPageSize() == pageParameter.getPageSize());
- assertTrue(page.getPages() == pageParameter.getTotalPage());
- assertTrue(page.getTotal() == pageParameter.getTotalCount());
- assertTrue(page.getPageSize() == pageParameter.getOffset());
+ assertEquals(page.getPageNum(), pageParameter.getCurrentPage());
+ assertEquals(page.getPageSize(), pageParameter.getPageSize());
+ assertEquals(page.getPages(), pageParameter.getTotalPage());
+ assertEquals(page.getTotal(), pageParameter.getTotalCount());
+ assertEquals(page.getPageSize(), pageParameter.getOffset());
}
@Test
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiControllerTest.java
index 0eb11ac73..f7e13afe6 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/ApiControllerTest.java
@@ -109,8 +109,8 @@ public final class ApiControllerTest {
.param("apiPath", "string")
.param("state", "0")
.param("tagId", "")
- .param("currentPage", pageParameter.getCurrentPage() +
"")
- .param("pageSize", pageParameter.getPageSize() + ""))
+ .param("currentPage",
String.valueOf(pageParameter.getCurrentPage()))
+ .param("pageSize",
String.valueOf(pageParameter.getPageSize())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.QUERY_SUCCESS)))
.andExpect(jsonPath("$.data.dataList[0].contextPath",
is(apiVO.getContextPath())))
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java
index b443fe5c2..5424031a8 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java
@@ -189,8 +189,8 @@ public final class AppAuthControllerTest {
this.mockMvc.perform(MockMvcRequestBuilders.get("/appAuth/findPageByQuery")
.param("appKey", "testAppKey")
.param("phone", "18600000000")
- .param("currentPage", pageParameter.getCurrentPage() + "")
- .param("pageSize", pageParameter.getPageSize() + ""))
+ .param("currentPage",
String.valueOf(pageParameter.getCurrentPage()))
+ .param("pageSize",
String.valueOf(pageParameter.getPageSize())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.QUERY_SUCCESS)))
.andExpect(jsonPath("$.data.dataList[0].appKey",
is(appAuthVO.getAppKey())))
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/DataPermissionControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/DataPermissionControllerTest.java
index 8a0d9510a..596b616cb 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/DataPermissionControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/DataPermissionControllerTest.java
@@ -77,8 +77,8 @@ public class DataPermissionControllerTest {
new SelectorQuery(pluginId, name, pageParameter),
userId)).willReturn(commonPager);
this.mockMvc.perform(MockMvcRequestBuilders.get("/data-permission/selector")
- .param("currentPage", currentPage + "")
- .param("pageSize", pageSize + "")
+ .param("currentPage", String.valueOf(currentPage))
+ .param("pageSize", String.valueOf(pageSize))
.param("userId", userId)
.param("pluginId", pluginId)
.param("name", name))
@@ -102,8 +102,8 @@ public class DataPermissionControllerTest {
new RuleQuery(selectorId, name, pageParameter),
userId)).willReturn(commonPager);
this.mockMvc.perform(MockMvcRequestBuilders.get("/data-permission/rules")
- .param("currentPage", currentPage + "")
- .param("pageSize", pageSize + "")
+ .param("currentPage", String.valueOf(currentPage))
+ .param("pageSize", String.valueOf(pageSize))
.param("userId", userId)
.param("selectorId", selectorId)
.param("name", name))
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MetaDataControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MetaDataControllerTest.java
index 1fa925aa8..a4627e3a5 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MetaDataControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/MetaDataControllerTest.java
@@ -101,8 +101,8 @@ public final class MetaDataControllerTest {
given(this.metaDataService.listByPage(metaDataQuery)).willReturn(commonPager);
this.mockMvc.perform(MockMvcRequestBuilders.get("/meta-data/queryList")
.param("path", "path")
- .param("currentPage", pageParameter.getCurrentPage() + "")
- .param("pageSize", pageParameter.getPageSize() + ""))
+ .param("currentPage",
String.valueOf(pageParameter.getCurrentPage()))
+ .param("pageSize",
String.valueOf(pageParameter.getPageSize())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.QUERY_SUCCESS)))
.andExpect(jsonPath("$.data.dataList[0].appName",
is(metaDataVO.getAppName())))
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PermissionControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PermissionControllerTest.java
index 746e23b61..40e26fab2 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PermissionControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PermissionControllerTest.java
@@ -19,6 +19,9 @@ package org.apache.shenyu.admin.controller;
import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
import org.apache.shenyu.admin.model.vo.PermissionMenuVO;
+import org.apache.shenyu.admin.model.vo.PermissionMenuVO.AuthPerm;
+import org.apache.shenyu.admin.model.vo.PermissionMenuVO.MenuInfo;
+import org.apache.shenyu.admin.model.vo.PermissionMenuVO.Meta;
import org.apache.shenyu.admin.service.PermissionService;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.common.exception.CommonErrorCode;
@@ -28,7 +31,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import java.util.Arrays;
+import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -53,10 +56,10 @@ public class PermissionControllerTest {
@Test
public void testGetUserPermissionByToken() {
final PermissionMenuVO permissionMenuVO = new PermissionMenuVO(
- Arrays.asList(new PermissionMenuVO.MenuInfo("id", "name",
"url", "component",
- new PermissionMenuVO.Meta("icon", "title"),
Arrays.asList(), 0)),
- Arrays.asList(new PermissionMenuVO.AuthPerm("perms1",
"description1", "icon")),
- Arrays.asList(new PermissionMenuVO.AuthPerm("perms2",
"description2", "icon")));
+ Collections.singletonList(new MenuInfo("id", "name", "url",
"component",
+ new Meta("icon", "title"), Collections.emptyList(),
0)),
+ Collections.singletonList(new AuthPerm("perms1",
"description1", "icon")),
+ Collections.singletonList(new AuthPerm("perms2",
"description2", "icon")));
when(mockPermissionService.getPermissionMenu("token")).thenReturn(permissionMenuVO);
final ShenyuAdminResult result =
permissionController.getUserPermissionByToken("token");
assertThat(result.getCode(), is(CommonErrorCode.SUCCESSFUL));
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PluginControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PluginControllerTest.java
index 669023cf9..39a8d90b7 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PluginControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/PluginControllerTest.java
@@ -109,8 +109,8 @@ public final class PluginControllerTest {
this.mockMvc.perform(MockMvcRequestBuilders.get("/plugin")
.param("name", "t_n")
.param("enabled", "1")
- .param("currentPage", pageParameter.getCurrentPage() + "")
- .param("pageSize", pageParameter.getPageSize() + ""))
+ .param("currentPage",
String.valueOf(pageParameter.getCurrentPage()))
+ .param("pageSize",
String.valueOf(pageParameter.getPageSize())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.QUERY_SUCCESS)))
.andExpect(jsonPath("$.data.dataList[0].name",
is(pluginVO.getName())))
@@ -152,9 +152,9 @@ public final class PluginControllerTest {
this.mockMvc.perform(MockMvcRequestBuilders.multipart("/plugin")
.file(file)
.param("name", pluginDTO.getName())
- .param("enabled", pluginDTO.getEnabled() + "")
+ .param("enabled",
String.valueOf(pluginDTO.getEnabled()))
.param("role", pluginDTO.getRole())
- .param("sort", pluginDTO.getSort() + ""))
+ .param("sort", String.valueOf(pluginDTO.getSort())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.CREATE_SUCCESS)))
.andReturn();
@@ -166,9 +166,9 @@ public final class PluginControllerTest {
.file(file)
.param("id", pluginDTO.getId())
.param("name", pluginDTO.getName())
- .param("enabled", pluginDTO.getEnabled() + "")
+ .param("enabled",
String.valueOf(pluginDTO.getEnabled()))
.param("role", pluginDTO.getRole())
- .param("sort", pluginDTO.getSort() + ""))
+ .param("sort", String.valueOf(pluginDTO.getSort())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message",
is(ShenyuResultMessage.UPDATE_SUCCESS)))
.andReturn();
@@ -179,9 +179,9 @@ public final class PluginControllerTest {
.file(file)
.param("id", pluginDTO.getId())
.param("name", pluginDTO.getName())
- .param("enabled", pluginDTO.getEnabled() + "")
+ .param("enabled",
String.valueOf(pluginDTO.getEnabled()))
.param("role", pluginDTO.getRole())
- .param("sort", pluginDTO.getSort() + ""))
+ .param("sort", String.valueOf(pluginDTO.getSort())))
.andExpect(status().isOk())
.andExpect(jsonPath("$.message", Matchers.containsString("The
system is busy, please try again later")))
.andReturn();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/SandboxControllerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/SandboxControllerTest.java
index a50af0f5f..71efe1362 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/SandboxControllerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/SandboxControllerTest.java
@@ -38,7 +38,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -73,7 +72,7 @@ public final class SandboxControllerTest {
AppAuthDO appAuthDO = buildAppAuthDO();
ProxyGatewayDTO proxyGatewayDTO = buildProxyGatewayDTO();
when(this.appAuthService.findByAppKey(any())).thenReturn(appAuthDO);
- MockHttpServletResponse response = mockMvc.perform((RequestBuilder)
MockMvcRequestBuilders.post("/sandbox/proxyGateway")
+ MockHttpServletResponse response =
mockMvc.perform(MockMvcRequestBuilders.post("/sandbox/proxyGateway")
.contentType(MediaType.APPLICATION_JSON)
.content(GsonUtils.getInstance().toJson(proxyGatewayDTO)))
.andReturn().getResponse();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/MetadataExecutorSubscriberTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/MetadataExecutorSubscriberTest.java
index fe8952386..61f9e799a 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/MetadataExecutorSubscriberTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/MetadataExecutorSubscriberTest.java
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -60,7 +61,7 @@ public class MetadataExecutorSubscriberTest {
public void testExecutor() {
List<MetaDataRegisterDTO> list = new ArrayList<>();
metadataExecutorSubscriber.executor(list);
- assertEquals(true, list.isEmpty());
+ assertTrue(list.isEmpty());
list.add(MetaDataRegisterDTO.builder().appName("test").build());
ShenyuClientRegisterService service =
mock(ShenyuClientRegisterService.class);
when(shenyuClientRegisterService.get(any())).thenReturn(service);
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/URIRegisterExecutorSubscriberTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/URIRegisterExecutorSubscriberTest.java
index dca0897fa..0f5cc6156 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/URIRegisterExecutorSubscriberTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/disruptor/subscriber/URIRegisterExecutorSubscriberTest.java
@@ -37,6 +37,7 @@ import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -64,7 +65,7 @@ public class URIRegisterExecutorSubscriberTest {
public void testExecutor() {
List<URIRegisterDTO> list = new ArrayList<>();
uriRegisterExecutorSubscriber.executor(list);
- assertEquals(true, list.isEmpty());
+ assertTrue(list.isEmpty());
list.add(URIRegisterDTO.builder().rpcType(RpcTypeEnum.HTTP.getName())
.appName("test").contextPath("/test").build());
ShenyuClientRegisterService service =
mock(ShenyuClientRegisterService.class);
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloClientTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloClientTest.java
index 3b813376a..10385d90f 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloClientTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloClientTest.java
@@ -65,9 +65,9 @@ public class ApolloClientTest {
*/
@Test
public void testGetItemValue() {
-
when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("42");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("42");
assertEquals("42", apolloClient.getItemValue("Key"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
/**
@@ -76,9 +76,9 @@ public class ApolloClientTest {
@Test
public void testCreateOrUpdateItem() {
doNothing().when(apolloClient)
- .createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ .createOrUpdateItem(Mockito.any(), Mockito.<Object>any(),
Mockito.any());
apolloClient.createOrUpdateItem("Key", (Object) "Value", "Comment");
- verify(apolloClient).createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ verify(apolloClient).createOrUpdateItem(Mockito.any(),
Mockito.<Object>any(), Mockito.any());
}
/**
@@ -86,9 +86,9 @@ public class ApolloClientTest {
*/
@Test
public void testPublishNamespace() {
- doNothing().when(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ doNothing().when(apolloClient).publishNamespace(Mockito.any(),
Mockito.any());
apolloClient.publishNamespace("Dr", "1.0.2");
- verify(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ verify(apolloClient).publishNamespace(Mockito.any(), Mockito.any());
}
}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListenerTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListenerTest.java
index 89812e72c..b30ed7e2c 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListenerTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListenerTest.java
@@ -63,11 +63,11 @@ public class ApolloDataChangedListenerTest {
@Test
public void testPublishConfig() {
doNothing().when(apolloClient)
- .createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
- doNothing().when(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ .createOrUpdateItem(Mockito.any(), Mockito.<Object>any(),
Mockito.any());
+ doNothing().when(apolloClient).publishNamespace(Mockito.any(),
Mockito.any());
apolloDataChangedListener.publishConfig("42", "Data");
- verify(apolloClient).createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
- verify(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ verify(apolloClient).createOrUpdateItem(Mockito.any(),
Mockito.<Object>any(), Mockito.any());
+ verify(apolloClient).publishNamespace(Mockito.any(), Mockito.any());
}
/**
@@ -75,9 +75,9 @@ public class ApolloDataChangedListenerTest {
*/
@Test
public void testGetConfig() {
-
when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("42");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("42");
assertEquals("42", apolloDataChangedListener.getConfig("42"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
/**
@@ -85,9 +85,9 @@ public class ApolloDataChangedListenerTest {
*/
@Test
public void testGetConfig2() {
- when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("");
assertEquals("{}", apolloDataChangedListener.getConfig("42"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DiscoveryUpstreamMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DiscoveryUpstreamMapperTest.java
index b6fbbc445..27c810fa2 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DiscoveryUpstreamMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/DiscoveryUpstreamMapperTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
import javax.annotation.Resource;
import java.sql.Timestamp;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -53,7 +53,7 @@ class DiscoveryUpstreamMapperTest extends
AbstractSpringIntegrationTest {
@Test
void selectByIds() {
- List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Arrays.asList(discoveryUpstreamDO.getId()));
+ List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Collections.singletonList(discoveryUpstreamDO.getId()));
assertEquals(1, dos.size());
assertEquals("1", dos.get(0).getDiscoveryHandlerId());
}
@@ -69,15 +69,15 @@ class DiscoveryUpstreamMapperTest extends
AbstractSpringIntegrationTest {
discoveryUpstreamDO.setDiscoveryHandlerId("2");
discoveryUpstreamMapper.update(discoveryUpstreamDO);
- List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Arrays.asList(discoveryUpstreamDO.getId()));
+ List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Collections.singletonList(discoveryUpstreamDO.getId()));
assertEquals("2", dos.get(0).getDiscoveryHandlerId());
}
@Test
void deleteByIds() {
-
discoveryUpstreamMapper.deleteByIds(Arrays.asList(discoveryUpstreamDO.getId()));
- List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Arrays.asList(discoveryUpstreamDO.getId()));
+
discoveryUpstreamMapper.deleteByIds(Collections.singletonList(discoveryUpstreamDO.getId()));
+ List<DiscoveryUpstreamDO> dos =
discoveryUpstreamMapper.selectByIds(Collections.singletonList(discoveryUpstreamDO.getId()));
assertEquals(0, dos.size());
}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
index b9dbc5e64..15fbff6f2 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/MockRequestRecordMapperTest.java
@@ -62,7 +62,7 @@ public class MockRequestRecordMapperTest extends
AbstractSpringIntegrationTest {
assertEquals(queryResult.getPathVariable(), "");
assertEquals(queryResult.getQuery(), "");
assertEquals(queryResult.getHeader(), "");
- assertEquals(queryResult.getBody(), null);
+ assertNull(queryResult.getBody());
}
@Test
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/ProxySelectorMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/ProxySelectorMapperTest.java
index 91d28a9dc..09934ff04 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/ProxySelectorMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/ProxySelectorMapperTest.java
@@ -27,10 +27,11 @@ import org.junit.jupiter.api.Test;
import javax.annotation.Resource;
import java.sql.Timestamp;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
class ProxySelectorMapperTest extends AbstractSpringIntegrationTest {
@@ -88,7 +89,7 @@ class ProxySelectorMapperTest extends
AbstractSpringIntegrationTest {
@Test
void selectByIds() {
- List<ProxySelectorDO> list =
proxySelectorMapper.selectByIds(Arrays.asList(proxySelectorDO.getId()));
+ List<ProxySelectorDO> list =
proxySelectorMapper.selectByIds(Collections.singletonList(proxySelectorDO.getId()));
assertEquals(list.size(), 1);
assertEquals(list.get(0).getName(), "test");
}
@@ -96,9 +97,9 @@ class ProxySelectorMapperTest extends
AbstractSpringIntegrationTest {
@Test
void deleteByIds() {
-
proxySelectorMapper.deleteByIds(Arrays.asList(proxySelectorDO.getId()));
+
proxySelectorMapper.deleteByIds(Collections.singletonList(proxySelectorDO.getId()));
Boolean b = proxySelectorMapper.existed(1);
- assertEquals(null, b);
+ assertNull(b);
}
private ProxySelectorDO build() {
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/DiscoveryUpstreamServiceTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/DiscoveryUpstreamServiceTest.java
index c20589401..2a685ed12 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/DiscoveryUpstreamServiceTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/DiscoveryUpstreamServiceTest.java
@@ -41,7 +41,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
-import java.util.Arrays;
+import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
@@ -116,7 +116,7 @@ class DiscoveryUpstreamServiceTest {
@Test
void delete() {
-
given(discoveryUpstreamMapper.deleteByIds(Arrays.asList("1"))).willReturn(1);
- assertEquals(ShenyuResultMessage.DELETE_SUCCESS,
discoveryUpstreamService.delete(Arrays.asList("1")));
+
given(discoveryUpstreamMapper.deleteByIds(Collections.singletonList("1"))).willReturn(1);
+ assertEquals(ShenyuResultMessage.DELETE_SUCCESS,
discoveryUpstreamService.delete(Collections.singletonList("1")));
}
}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/bean/StatelessAuthFilterTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/bean/StatelessAuthFilterTest.java
index 3fa99ccba..467f4898f 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/bean/StatelessAuthFilterTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/bean/StatelessAuthFilterTest.java
@@ -33,7 +33,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.lang.reflect.Method;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -60,13 +61,13 @@ public final class StatelessAuthFilterTest {
@Test
public void testIsAccessAllowed() {
Object obj = mock(Object.class);
- assertEquals(false,
statelessAuthFilter.isAccessAllowed(httpServletRequest, httpServletResponse,
obj));
+ assertFalse(statelessAuthFilter.isAccessAllowed(httpServletRequest,
httpServletResponse, obj));
}
@Test
public void testOnAccessDenied() throws Exception {
when(httpServletRequest.getMethod()).thenReturn(HttpMethod.OPTIONS.name());
- assertEquals(true,
statelessAuthFilter.onAccessDenied(httpServletRequest, httpServletResponse));
+ assertTrue(statelessAuthFilter.onAccessDenied(httpServletRequest,
httpServletResponse));
}
@Test
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroConfigurationTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroConfigurationTest.java
index c06c83a8d..d3cc1040e 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroConfigurationTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroConfigurationTest.java
@@ -39,6 +39,7 @@ import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -87,9 +88,9 @@ public final class ShiroConfigurationTest {
@Test
public void testGetDefaultAdvisorAutoProxyCreator() {
- DefaultAdvisorAutoProxyCreator creator =
shiroConfiguration.getDefaultAdvisorAutoProxyCreator();
+ DefaultAdvisorAutoProxyCreator creator =
ShiroConfiguration.getDefaultAdvisorAutoProxyCreator();
assertNotNull(creator);
- assertEquals(true, creator.isProxyTargetClass());
+ assertTrue(creator.isProxyTargetClass());
}
@Test
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroRealmTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroRealmTest.java
index 355733ab2..845bfe2aa 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroRealmTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/shiro/config/ShiroRealmTest.java
@@ -42,6 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -67,7 +68,7 @@ public final class ShiroRealmTest {
@Test
public void testSupports() {
BearerToken token = mock(BearerToken.class);
- assertEquals(true, shiroRealm.supports(token));
+ assertTrue(shiroRealm.supports(token));
}
@Test
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/utils/HttpUtilsTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/utils/HttpUtilsTest.java
index 507de9734..04ac1561c 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/utils/HttpUtilsTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/utils/HttpUtilsTest.java
@@ -37,7 +37,7 @@ public class HttpUtilsTest {
private static final String ACTUAL_PARAM_URL =
"http://127.0.0.1/?param-1=123¶m-2=456";
- private Map<String, Object> formMap = new HashMap<>();
+ private final Map<String, Object> formMap = new HashMap<>();
{
formMap.put("param-1", "123");
diff --git
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java
index e8aef67f0..bbe10a5e4 100644
---
a/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java
+++
b/shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/shutdown/ShutdownHookManager.java
@@ -37,10 +37,10 @@ public final class ShutdownHookManager {
private static final Logger LOG =
LoggerFactory.getLogger(ShutdownHookManager.class);
- private Set<HookEntry> hooks =
+ private final Set<HookEntry> hooks =
Collections.synchronizedSet(new HashSet<HookEntry>());
- private AtomicBoolean shutdownInProgress = new AtomicBoolean(false);
+ private final AtomicBoolean shutdownInProgress = new AtomicBoolean(false);
private ShutdownHookManager() {
@@ -167,9 +167,9 @@ public final class ShutdownHookManager {
*/
private static class HookEntry {
- private Runnable hook;
+ private final Runnable hook;
- private int priority;
+ private final int priority;
HookEntry(final Runnable hook, final int priority) {
this.hook = hook;
diff --git
a/shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/validation/AlibabaDubboClientValidator.java
b/shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/validation/AlibabaDubboClientValidator.java
index 9cc35b732..96502c3da 100644
---
a/shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/validation/AlibabaDubboClientValidator.java
+++
b/shenyu-client/shenyu-client-dubbo/shenyu-client-alibaba-dubbo/src/main/java/org/apache/shenyu/client/alibaba/dubbo/validation/AlibabaDubboClientValidator.java
@@ -185,12 +185,10 @@ public class AlibabaDubboClientValidator implements
Validator {
private static boolean hasConstraintParameter(final Method method) {
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- if (parameterAnnotations.length > 0) {
- for (Annotation[] annotations : parameterAnnotations) {
- for (Annotation annotation : annotations) {
- if
(annotation.annotationType().isAnnotationPresent(Constraint.class)) {
- return true;
- }
+ for (Annotation[] annotations : parameterAnnotations) {
+ for (Annotation annotation : annotations) {
+ if
(annotation.annotationType().isAnnotationPresent(Constraint.class)) {
+ return true;
}
}
}
diff --git
a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java
b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java
index 373cc65b4..3f5c559a8 100644
---
a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java
+++
b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/main/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidator.java
@@ -197,12 +197,10 @@ public class ApacheDubboClientValidator implements
Validator {
private static boolean hasConstraintParameter(final Method method) {
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
- if (parameterAnnotations.length > 0) {
- for (Annotation[] annotations : parameterAnnotations) {
- for (Annotation annotation : annotations) {
- if
(annotation.annotationType().isAnnotationPresent(Constraint.class)) {
- return true;
- }
+ for (Annotation[] annotations : parameterAnnotations) {
+ for (Annotation annotation : annotations) {
+ if
(annotation.annotationType().isAnnotationPresent(Constraint.class)) {
+ return true;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java
index f68d6d254..7bacb7536 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuDeleteMappingTest.java
@@ -71,7 +71,7 @@ public class ShenyuDeleteMappingTest {
@ShenyuDeleteMapping(value = "/{id}", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String delete(@PathVariable final String id) {
- return "" + id;
+ return id;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java
index ce34d375e..bcdb0ecbc 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuGetMappingTest.java
@@ -71,7 +71,7 @@ public class ShenyuGetMappingTest {
@ShenyuGetMapping(value = "/{id}", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String get(@PathVariable final String id) {
- return "" + id;
+ return id;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java
index 294d8ca6a..85a8d0ebe 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPatchMappingTest.java
@@ -71,7 +71,7 @@ public class ShenyuPatchMappingTest {
@ShenyuPatchMapping(value = "/patch", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String patch(@RequestBody final String operator) {
- return "" + operator;
+ return operator;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java
index 4db8a4f7b..010c05292 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPostMappingTest.java
@@ -71,7 +71,7 @@ public class ShenyuPostMappingTest {
@ShenyuPostMapping(value = "/save", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String save(@RequestBody final String body) {
- return "" + body;
+ return body;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java
index 5e2ba19f1..2acb6bf64 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/annotation/ShenyuPutMappingTest.java
@@ -71,7 +71,7 @@ public class ShenyuPutMappingTest {
@ShenyuPutMapping(value = "/put", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String put(@RequestBody final String body) {
- return "" + body;
+ return body;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java
index b11ab06aa..176c3402e 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springcloud/src/test/java/org/apache/shenyu/client/springcloud/init/SpringCloudClientEventListenerTest.java
@@ -119,7 +119,7 @@ public final class SpringCloudClientEventListenerTest {
private SpringCloudClientEventListener
buildSpringCloudClientEventListener(final boolean full) {
Properties properties = new Properties();
properties.setProperty("contextPath", "/test");
- properties.setProperty("isFull", full + "");
+ properties.setProperty("isFull", String.valueOf(full));
properties.setProperty("ip", "127.0.0.1");
properties.setProperty("port", "8081");
properties.setProperty("username", "admin");
@@ -143,13 +143,13 @@ public final class SpringCloudClientEventListenerTest {
@PostMapping("/save")
@ShenyuSpringCloudClient(path = "/order/save")
public String save(@RequestBody final String body) {
- return "" + body;
+ return body;
}
@PostMapping("/update")
@ShenyuSpringCloudClient(path = "")
public String update(@RequestBody final String body) {
- return "" + body;
+ return body;
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java
index 2637d4606..f11fee6b4 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuDeleteMappingTest.java
@@ -72,7 +72,7 @@ public class ShenyuDeleteMappingTest {
@ShenyuDeleteMapping(value = "/{id}", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String delete(@PathVariable final String id) {
- return "" + id;
+ return id;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java
index 7fffef813..e96d9a8ea 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuGetMappingTest.java
@@ -72,7 +72,7 @@ public class ShenyuGetMappingTest {
@ShenyuGetMapping(value = "/{id}", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String get(@PathVariable final String id) {
- return "" + id;
+ return id;
}
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java
index 4ff365f8f..167dc0592 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPatchMappingTest.java
@@ -72,7 +72,7 @@ public class ShenyuPatchMappingTest {
@ShenyuPatchMapping(value = "/patch", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String patch(@RequestBody final String operator) {
- return "" + operator;
+ return operator;
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java
index 73920dcea..431702c58 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPostMappingTest.java
@@ -72,7 +72,7 @@ public class ShenyuPostMappingTest {
@ShenyuPostMapping(value = "/save", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String save(@RequestBody final String body) {
- return "" + body;
+ return body;
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java
index f17ada984..3522d777d 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/annotation/ShenyuPutMappingTest.java
@@ -72,7 +72,7 @@ public class ShenyuPutMappingTest {
@ShenyuPutMapping(value = "/put", ruleName = "divide", enabled =
false, desc = "it`s test.")
public String put(@RequestBody final String body) {
- return "" + body;
+ return body;
}
}
diff --git
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java
index 44b1a713f..89df6b2d9 100644
---
a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java
+++
b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/test/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListenerTest.java
@@ -128,7 +128,7 @@ public class SpringMvcClientEventListenerTest {
private SpringMvcClientEventListener
buildSpringMvcClientEventListener(final boolean full, final boolean port) {
Properties properties = new Properties();
properties.setProperty("contextPath", "/mvc");
- properties.setProperty("isFull", full + "");
+ properties.setProperty("isFull", String.valueOf(full));
properties.setProperty("ip", "127.0.0.1");
if (port) {
properties.setProperty("port", "8289");
@@ -194,14 +194,14 @@ public class SpringMvcClientEventListenerTest {
@RequestMapping("/hello2/*")
static class SpringMvcClientTestBean2 {
public String test(final String hello) {
- return hello + "";
+ return hello;
}
}
@RestController
static class SpringMvcClientTestBean3 {
public String test(final String hello) {
- return hello + "";
+ return hello;
}
}
@@ -209,7 +209,7 @@ public class SpringMvcClientEventListenerTest {
@ShenyuSpringMvcClient(path = "/order/*")
static class SpringMvcClientTestBean4 {
public String test(final String hello) {
- return hello + "";
+ return hello;
}
}
diff --git
a/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java
b/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java
index ddd4f4cae..65217573f 100644
---
a/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java
+++
b/shenyu-client/shenyu-client-tars/src/test/java/org/apache/shenyu/client/tars/TarsServiceBeanPostProcessorTest.java
@@ -123,12 +123,12 @@ public final class TarsServiceBeanPostProcessorTest {
static class TarsDemoService {
@ShenyuTarsClient("hello")
public String test(final String hello) {
- return hello + "";
+ return hello;
}
@ShenyuTarsClient("hello2/*")
public String test2(final String hello) {
- return hello + "";
+ return hello;
}
}
@@ -136,7 +136,7 @@ public final class TarsServiceBeanPostProcessorTest {
@ShenyuTarsClient("hello2/*")
static class TarsDemoService2 {
public String test(final String hello) {
- return hello + "";
+ return hello;
}
}
@@ -144,7 +144,7 @@ public final class TarsServiceBeanPostProcessorTest {
@ShenyuTarsClient
static class TarsDemoService3 {
public String test(final String hello) {
- return hello + "";
+ return hello;
}
}
}
diff --git
a/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java
b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java
index 4dbf7f95e..09a87510f 100644
---
a/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java
+++
b/shenyu-client/shenyu-client-websocket/shenyu-client-spring-websocket/src/main/java/org/apache/shenyu/client/spring/websocket/init/ShenyuServerEndpointerExporter.java
@@ -84,7 +84,7 @@ public class ShenyuServerEndpointerExporter extends
WebApplicationObjectSupport
ServerEndpointConfig.Configurator configurator = null;
if
(!configuratorClazz.equals(ServerEndpointConfig.Configurator.class)) {
try {
- configurator = (ServerEndpointConfig.Configurator)
annotation.configurator().getConstructor().newInstance();
+ configurator =
annotation.configurator().getConstructor().newInstance();
} catch (ReflectiveOperationException ex) {
LOG.error("ShenyuServerEndpoint configurator init fail! Class
name: {}, configurator name: {}", pojo.getName(),
annotation.configurator().getName());
throw new ShenyuException(ex);
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java
index 0d13d6c6f..36b59d600 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginHandlerEventEnum.java
@@ -40,5 +40,5 @@ public enum PluginHandlerEventEnum {
/**
* plugin sorted.
*/
- SORTED;
+ SORTED
}
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java
index 66e982859..090e1568d 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/TrieEventEnum.java
@@ -35,5 +35,5 @@ public enum TrieEventEnum {
/**
* Shenyu Trie remove event.
*/
- REMOVE;
+ REMOVE
}
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java
index b0ac08a19..0984f117c 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/cache/MemorySafeWindowTinyLFUMapTest.java
@@ -73,7 +73,7 @@ public class MemorySafeWindowTinyLFUMapTest {
@Test
public void testWindowTinyLFUOutOufMemoryException() {
- final int mb = 1 * 1024 * 1024;
+ final int mb = 1024 * 1024;
for (int i = 0; i < 1000; i++) {
MemorySafeWindowTinyLFUMap<String, Byte[]> instance = new
MemorySafeWindowTinyLFUMap<>(1, 1024);
instance.put(String.valueOf(1), new Byte[mb]);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java
index a2ae1450f..8996b9895 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/cache/WindowTinyLFUMapTest.java
@@ -28,6 +28,7 @@ import java.util.Map;
public class WindowTinyLFUMapTest {
@Test
+ @SuppressWarnings("all")
public void weakKeyCache() {
Map<String, String> map = new WindowTinyLFUMap<>(100, 100,
Boolean.TRUE);
String key1 = new String("abc");
@@ -40,6 +41,7 @@ public class WindowTinyLFUMapTest {
}
@Test
+ @SuppressWarnings("all")
public void strongKeyCache() {
Map<String, String> map = new WindowTinyLFUMap<>(100, 100,
Boolean.FALSE);
String key1 = new String("abc");
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java
index fb8979bdc..311a75a09 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/WebsocketDataTest.java
@@ -20,6 +20,7 @@ package org.apache.shenyu.common.dto;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -35,7 +36,7 @@ public class WebsocketDataTest {
@Test
public void testGetterSetter() {
WebsocketData<AppAuthData> websocketData = new WebsocketData<>(
- "groupType", "eventType", Arrays.asList(new AppAuthData()));
+ "groupType", "eventType", Collections.singletonList(new
AppAuthData()));
websocketData.setGroupType("groupType1");
websocketData.setEventType("eventType1");
@@ -49,9 +50,9 @@ public class WebsocketDataTest {
@Test
public void testEqualsAndHashCode() {
WebsocketData<AppAuthData> websocketData1 = new WebsocketData<>(
- "groupType", "eventType", Arrays.asList(new AppAuthData()));
+ "groupType", "eventType", Collections.singletonList(new
AppAuthData()));
WebsocketData<AppAuthData> websocketData2 = new WebsocketData<>(
- "groupType", "eventType", Arrays.asList(new AppAuthData()));
+ "groupType", "eventType", Collections.singletonList(new
AppAuthData()));
Set<WebsocketData> set = new HashSet<>();
set.add(websocketData1);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
index db7ad437c..695c42507 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ModifyResponseRuleHandleTest.java
@@ -18,9 +18,10 @@
package org.apache.shenyu.common.dto.convert.rule.impl;
import com.google.common.collect.ImmutableSet;
+import
org.apache.shenyu.common.dto.convert.rule.impl.ParamMappingRuleHandle.ParamMapInfo;
import org.junit.jupiter.api.Test;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -43,8 +44,8 @@ public class ModifyResponseRuleHandleTest {
handle.setReplaceHeaderKeys(new HashMap<>());
handle.setRemoveHeaderKeys(new HashSet<>());
handle.setStatusCode(1);
- handle.setAddBodyKeys(Arrays.asList(new
ParamMappingRuleHandle.ParamMapInfo()));
- handle.setReplaceBodyKeys(Arrays.asList(new
ParamMappingRuleHandle.ParamMapInfo()));
+ handle.setAddBodyKeys(Collections.singletonList(new ParamMapInfo()));
+ handle.setReplaceBodyKeys(Collections.singletonList(new
ParamMapInfo()));
handle.setRemoveBodyKeys(new HashSet<>());
assertThat(handle.getAddHeaders(), is(notNullValue()));
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java
index 9310e6f94..90dada1ca 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/rule/impl/ParamMappingRuleHandleTest.java
@@ -18,9 +18,10 @@
package org.apache.shenyu.common.dto.convert.rule.impl;
import com.google.common.collect.ImmutableSet;
+import
org.apache.shenyu.common.dto.convert.rule.impl.ParamMappingRuleHandle.ParamMapInfo;
import org.junit.jupiter.api.Test;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -51,8 +52,8 @@ public class ParamMappingRuleHandleTest {
ParamMappingRuleHandle handle = new ParamMappingRuleHandle();
handle.setRemoveParameterKeys(new HashSet<>());
- handle.setReplaceParameterKeys(Arrays.asList(new
ParamMappingRuleHandle.ParamMapInfo()));
- handle.setAddParameterKeys(Arrays.asList(new
ParamMappingRuleHandle.ParamMapInfo()));
+ handle.setReplaceParameterKeys(Collections.singletonList(new
ParamMapInfo()));
+ handle.setAddParameterKeys(Collections.singletonList(new
ParamMapInfo()));
assertThat(handle.getRemoveParameterKeys(), is(notNullValue()));
assertThat(handle.getReplaceParameterKeys(), is(notNullValue()));
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java
index d6d941de4..5c5198bde 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/dto/convert/selector/SpringCloudSelectorHandleTest.java
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
+import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
@@ -34,7 +35,7 @@ public class SpringCloudSelectorHandleTest {
@Test
public void testBuilderAndGetterSetter() {
SpringCloudSelectorHandle selectorHandle =
SpringCloudSelectorHandle.builder().serviceId("serviceId")
- .gray(true).divideUpstreams(Arrays.asList(new
DivideUpstream())).build();
+ .gray(true).divideUpstreams(Collections.singletonList(new
DivideUpstream())).build();
selectorHandle.setServiceId("serviceId1");
selectorHandle.setGray(false);
diff --git
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
index 4452512cf..1e0d6c2c4 100644
---
a/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
+++
b/shenyu-common/src/test/java/org/apache/shenyu/common/utils/ThreadUtilsTest.java
@@ -51,6 +51,6 @@ public final class ThreadUtilsTest {
doThrow(InterruptedException.class).when(timeUnit).sleep(1);
ThreadUtils.sleep(timeUnit, 1);
verify(timeUnit, times(1)).sleep(eq(1L));
- assertTrue(Thread.currentThread().interrupted());
+ assertTrue(Thread.interrupted());
}
}
diff --git
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
index ac6682d94..88c7e5554 100644
---
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
+++
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/entity/Upstream.java
@@ -102,9 +102,9 @@ public final class Upstream {
*/
private AtomicLong inflight = new AtomicLong(1);
- private AtomicLong succeeded = new AtomicLong(0);
+ private final AtomicLong succeeded = new AtomicLong(0);
- private AtomicLong succeededElapsed = new AtomicLong(0);
+ private final AtomicLong succeededElapsed = new AtomicLong(0);
private Upstream(final Builder builder) {
this.protocol = builder.protocol;
diff --git
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/spi/P2cLoadBalancer.java
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/spi/P2cLoadBalancer.java
index c3dfc1f07..684e4579d 100644
---
a/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/spi/P2cLoadBalancer.java
+++
b/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/spi/P2cLoadBalancer.java
@@ -44,7 +44,7 @@ public class P2cLoadBalancer extends AbstractLoadBalancer {
*/
private static final int PICK_TIMES = 3;
- private Random random = new Random();
+ private final Random random = new Random();
/**
* pick of 2 choices to select upstream.
diff --git
a/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/ShortestResponseLoadBalancerTest.java
b/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/ShortestResponseLoadBalancerTest.java
index f52b0608d..abd579e02 100644
---
a/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/ShortestResponseLoadBalancerTest.java
+++
b/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/ShortestResponseLoadBalancerTest.java
@@ -53,7 +53,7 @@ public class ShortestResponseLoadBalancerTest {
select2++;
}
}
- Assertions.assertEquals(true, select1 < select2);
+ Assertions.assertTrue(select1 < select2);
Assertions.assertEquals(loop, select1 + select2);
}
@@ -79,7 +79,7 @@ public class ShortestResponseLoadBalancerTest {
select2++;
}
}
- Assertions.assertEquals(true, select1 < select2);
+ Assertions.assertTrue(select1 < select2);
Assertions.assertEquals(loop, select1 + select2);
}
diff --git
a/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/test/java/org/apache/shenyu/plugin/ratelimiter/executor/RedisRateLimiterScriptsTest.java
b/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/test/java/org/apache/shenyu/plugin/ratelimiter/executor/RedisRateLimiterScriptsTest.java
index ac9e3bd7f..994964090 100644
---
a/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/test/java/org/apache/shenyu/plugin/ratelimiter/executor/RedisRateLimiterScriptsTest.java
+++
b/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/test/java/org/apache/shenyu/plugin/ratelimiter/executor/RedisRateLimiterScriptsTest.java
@@ -78,7 +78,7 @@ public class RedisRateLimiterScriptsTest {
RateLimiterAlgorithm<?> rateLimiterAlgorithm =
RateLimiterAlgorithmFactory.newInstance("leakyBucket");
RedisScript<?> script = rateLimiterAlgorithm.getScript();
List<String> keys =
Stream.of("test-leakyBucket").collect(Collectors.toList());
- List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
Instant.now().getEpochSecond() + "", "1");
+ List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
String.valueOf(Instant.now().getEpochSecond()), "1");
Flux<List<Long>> resultFlux =
Singleton.INST.get(ReactiveRedisTemplate.class).execute(script, keys,
scriptArgs);
StepVerifier
.create(resultFlux)
@@ -94,7 +94,7 @@ public class RedisRateLimiterScriptsTest {
RateLimiterAlgorithm<?> rateLimiterAlgorithm =
RateLimiterAlgorithmFactory.newInstance("concurrent");
RedisScript<?> script = rateLimiterAlgorithm.getScript();
List<String> keys = Stream.of("test-concurrent",
"cd849432").collect(Collectors.toList());
- List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
Instant.now().getEpochSecond() + "", "1");
+ List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
String.valueOf(Instant.now().getEpochSecond()), "1");
Flux<List<Long>> resultFlux =
Singleton.INST.get(ReactiveRedisTemplate.class).execute(script, keys,
scriptArgs);
StepVerifier
.create(resultFlux)
@@ -110,7 +110,7 @@ public class RedisRateLimiterScriptsTest {
RateLimiterAlgorithm<?> rateLimiterAlgorithm =
RateLimiterAlgorithmFactory.newInstance("tokenBucket");
RedisScript<?> script = rateLimiterAlgorithm.getScript();
List<String> keys =
Stream.of("test-tokenBucket").collect(Collectors.toList());
- List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
Instant.now().getEpochSecond() + "", "1");
+ List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
String.valueOf(Instant.now().getEpochSecond()), "1");
Flux<List<Long>> resultFlux =
Singleton.INST.get(ReactiveRedisTemplate.class).execute(script, keys,
scriptArgs);
StepVerifier
.create(resultFlux)
@@ -126,7 +126,7 @@ public class RedisRateLimiterScriptsTest {
RateLimiterAlgorithm<?> rateLimiterAlgorithm =
RateLimiterAlgorithmFactory.newInstance("slidingWindow");
RedisScript<?> script = rateLimiterAlgorithm.getScript();
List<String> keys =
Stream.of("test-slidingWindow").collect(Collectors.toList());
- List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
Instant.now().getEpochSecond() + "", "1");
+ List<String> scriptArgs = Arrays.asList(10 + "", 100 + "",
String.valueOf(Instant.now().getEpochSecond()), "1");
Flux<List<Long>> resultFlux =
Singleton.INST.get(ReactiveRedisTemplate.class).execute(script, keys,
scriptArgs);
StepVerifier
.create(resultFlux)
diff --git
a/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/handler/Resilience4JHandlerTest.java
b/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/handler/Resilience4JHandlerTest.java
index b1dcc5980..c5c0da086 100644
---
a/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/handler/Resilience4JHandlerTest.java
+++
b/shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-resilience4j/src/test/java/org/apache/shenyu/plugin/resilience4j/handler/Resilience4JHandlerTest.java
@@ -30,9 +30,9 @@ import java.util.function.Supplier;
*/
public final class Resilience4JHandlerTest {
- private Resilience4JHandler resilience4JHandler = new
Resilience4JHandler();
+ private final Resilience4JHandler resilience4JHandler = new
Resilience4JHandler();
- private RuleData ruleData = new RuleData();
+ private final RuleData ruleData = new RuleData();
@Test
public void testHandlerRule() {
@@ -40,7 +40,7 @@ public final class Resilience4JHandlerTest {
ruleData.setHandle("{\"urlPath\":\"test\"}");
ruleData.setId("test");
resilience4JHandler.handlerRule(ruleData);
- Supplier<CommonHandleCache<String, Resilience4JHandle>> cache =
resilience4JHandler.CACHED_HANDLE;
+ Supplier<CommonHandleCache<String, Resilience4JHandle>> cache =
Resilience4JHandler.CACHED_HANDLE;
Assertions.assertNotNull(cache.get().obtainHandle("1_test"));
}
@@ -49,7 +49,7 @@ public final class Resilience4JHandlerTest {
ruleData.setSelectorId("1");
ruleData.setHandle("{\"urlPath\":\"test\"}");
ruleData.setId("test");
- Supplier<CommonHandleCache<String, Resilience4JHandle>> cache =
resilience4JHandler.CACHED_HANDLE;
+ Supplier<CommonHandleCache<String, Resilience4JHandle>> cache =
Resilience4JHandler.CACHED_HANDLE;
cache.get().cachedHandle("1_test", new Resilience4JHandle());
Assertions.assertNotNull(cache.get().obtainHandle("1_test"));
resilience4JHandler.removeRule(ruleData);
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
index c348c0726..a292a350c 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
@@ -27,9 +27,9 @@ import org.junit.jupiter.api.Test;
*/
public class ClickHouseLogCollectConfigTest {
- private ClickHouseLogCollectConfig clickHouseLogCollectConfig = new
ClickHouseLogCollectConfig();
+ private final ClickHouseLogCollectConfig clickHouseLogCollectConfig = new
ClickHouseLogCollectConfig();
- private ClickHouseLogCollectConfig.ClickHouseLogConfig clickHouseLogConfig
= new ClickHouseLogCollectConfig.ClickHouseLogConfig();
+ private final ClickHouseLogCollectConfig.ClickHouseLogConfig
clickHouseLogConfig = new ClickHouseLogCollectConfig.ClickHouseLogConfig();
@BeforeEach
public void setUp() {
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
index 33dbb9e7d..394c701cb 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/test/java/org/apache/shenyu/plugin/divide/DividePluginTest.java
@@ -61,6 +61,7 @@ import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -184,7 +185,7 @@ public final class DividePluginTest {
*/
@Test
public void handleSelectorIfNullTest() {
-
assertTrue(dividePlugin.handleSelectorIfNull(PluginEnum.DIVIDE.getName(),
exchange, chain) != null);
+
assertNotNull(dividePlugin.handleSelectorIfNull(PluginEnum.DIVIDE.getName(),
exchange, chain));
}
/**
@@ -192,7 +193,7 @@ public final class DividePluginTest {
*/
@Test
public void handleRuleIfNullTest() {
- assertTrue(dividePlugin.handleRuleIfNull(PluginEnum.DIVIDE.getName(),
exchange, chain) != null);
+
assertNotNull(dividePlugin.handleRuleIfNull(PluginEnum.DIVIDE.getName(),
exchange, chain));
}
/**
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-mqtt/src/main/java/org/apache/shenyu/plugin/mqtt/handler/MqttPluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-mqtt/src/main/java/org/apache/shenyu/plugin/mqtt/handler/MqttPluginDataHandler.java
index 50665c285..3cafba458 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-mqtt/src/main/java/org/apache/shenyu/plugin/mqtt/handler/MqttPluginDataHandler.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-mqtt/src/main/java/org/apache/shenyu/plugin/mqtt/handler/MqttPluginDataHandler.java
@@ -62,9 +62,7 @@ public class MqttPluginDataHandler implements
PluginDataHandler {
*/
private boolean isPortUsing(final int port) {
boolean flag = false;
- try {
- InetAddress address = InetAddress.getByName("127.0.0.1");
- new Socket(address, port);
+ try (Socket socket = new Socket(InetAddress.getByName("127.0.0.1"),
port)) {
flag = true;
} catch (Exception ignored) {
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-brpc/src/main/java/org/apache/shenyu/plugin/brpc/spi/SharedThreadPoolFactory.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-brpc/src/main/java/org/apache/shenyu/plugin/brpc/spi/SharedThreadPoolFactory.java
index b7dcdf888..acbcc227f 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-brpc/src/main/java/org/apache/shenyu/plugin/brpc/spi/SharedThreadPoolFactory.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-brpc/src/main/java/org/apache/shenyu/plugin/brpc/spi/SharedThreadPoolFactory.java
@@ -57,7 +57,7 @@ public class SharedThreadPoolFactory implements
ThreadPoolFactory {
if (Objects.isNull(rpcService)) {
return this.defaultThreadPool;
} else if (Objects.nonNull(this.threadPoolMap.get(rpcService))) {
- return (ThreadPoolExecutor) this.threadPoolMap.get(rpcService);
+ return this.threadPoolMap.get(rpcService);
} else {
ServiceConfig serviceConfig = rpcService.getServiceConfig();
if (serviceConfig == null) {
@@ -72,7 +72,7 @@ public class SharedThreadPoolFactory implements
ThreadPoolFactory {
ThreadPoolExecutor threadPool;
synchronized (this) {
if (this.threadPoolMap.get(rpcService) != null) {
- return (ThreadPoolExecutor)
this.threadPoolMap.get(rpcService);
+ return this.threadPoolMap.get(rpcService);
}
threadPool = new ThreadPoolExecutor(corePoolSize,
maxThreadPoolSize, (long) keepAliveTime,
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApacheDubboConfigCacheTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApacheDubboConfigCacheTest.java
index 7848e6e38..5e6e28705 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApacheDubboConfigCacheTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-apache-dubbo/src/test/java/org/apache/shenyu/plugin/apache/dubbo/cache/ApacheDubboConfigCacheTest.java
@@ -17,7 +17,6 @@
package org.apache.shenyu.plugin.apache.dubbo.cache;
-import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.common.dto.convert.plugin.DubboRegisterConfig;
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java
index e4aed5bf6..2880df522 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-sofa/src/main/java/org/apache/shenyu/plugin/sofa/cache/ApplicationConfigCache.java
@@ -165,7 +165,6 @@ public final class ApplicationConfigCache {
queueSize > 0 ? new LinkedBlockingQueue<>(queueSize) :
new SynchronousQueue<>(), factory);
return;
default:
- return;
}
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java
index f17826aee..07b917d2b 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-tars/src/main/java/org/apache/shenyu/plugin/tars/cache/ApplicationConfigCache.java
@@ -152,7 +152,6 @@ public final class ApplicationConfigCache {
queueSize > 0 ? new LinkedBlockingQueue<>(queueSize) :
new SynchronousQueue<>(), factory);
return;
default:
- return;
}
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/context/SpringCloudShenyuContextDecoratorTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/context/SpringCloudShenyuContextDecoratorTest.java
index 5ae90f791..18cb470a6 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/context/SpringCloudShenyuContextDecoratorTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/context/SpringCloudShenyuContextDecoratorTest.java
@@ -39,8 +39,8 @@ public final class SpringCloudShenyuContextDecoratorTest {
MetaData metaData = null;
ShenyuContext shenyuContext = new ShenyuContext();
springCloudShenyuContextDecorator.decorator(shenyuContext, metaData);
- Assertions.assertEquals(shenyuContext.getMethod(), null);
- Assertions.assertEquals(shenyuContext.getRealUrl(), null);
+ Assertions.assertNull(shenyuContext.getMethod());
+ Assertions.assertNull(shenyuContext.getRealUrl());
Assertions.assertEquals(shenyuContext.getRpcType(), "springCloud");
Assertions.assertEquals(shenyuContext.getModule(),
"divide-springCloud");
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandlerTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandlerTest.java
index 7505f1e79..3056e8812 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandlerTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-springcloud/src/test/java/org/apache/shenyu/plugin/springcloud/handler/SpringCloudPluginDataHandlerTest.java
@@ -54,7 +54,7 @@ public final class SpringCloudPluginDataHandlerTest {
private SelectorData selectorData = new SelectorData();
- private RuleData ruleData = new RuleData();
+ private final RuleData ruleData = new RuleData();
@BeforeEach
public void setUp() {
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
index 5707c4420..14dc4384f 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/WebSocketPluginTest.java
@@ -161,7 +161,7 @@ public class WebSocketPluginTest {
declaredConstructor.setAccessible(true);
Object obj = declaredConstructor.newInstance(null, null, null, null);
List<String> list = (List<String>) method.invoke(obj);
- assertEquals(list.isEmpty(), true);
+ assertTrue(list.isEmpty());
}
/**
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecoratorTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecoratorTest.java
index e8e3b150a..ce823f650 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecoratorTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/context/WebSocketShenyuContextDecoratorTest.java
@@ -40,7 +40,7 @@ public final class WebSocketShenyuContextDecoratorTest {
MetaData metaData = null;
ShenyuContext shenyuContext = new ShenyuContext();
webSocketShenyuContextDecorator.decorator(shenyuContext, metaData);
- Assertions.assertEquals(shenyuContext.getMethod(), null);
+ Assertions.assertNull(shenyuContext.getMethod());
Assertions.assertEquals(shenyuContext.getRpcType(), "websocket");
Assertions.assertEquals(shenyuContext.getModule(),
"websocket-websocket");
}
diff --git
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/handler/WebSocketPluginDataHandlerTest.java
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/handler/WebSocketPluginDataHandlerTest.java
index bbedf41d6..0f7b950a1 100644
---
a/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/handler/WebSocketPluginDataHandlerTest.java
+++
b/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/test/java/org/apache/shenyu/plugin/websocket/handler/WebSocketPluginDataHandlerTest.java
@@ -41,9 +41,9 @@ public class WebSocketPluginDataHandlerTest {
private WebSocketPluginDataHandler webSocketPluginDataHandler;
- private SelectorData selectorData = new SelectorData();
+ private final SelectorData selectorData = new SelectorData();
- private RuleData ruleData = new RuleData();
+ private final RuleData ruleData = new RuleData();
private List<Upstream> upstreamList;
@@ -70,7 +70,7 @@ public class WebSocketPluginDataHandlerTest {
Map<String, List<Upstream>> map = (Map<String, List<Upstream>>)
field.get(instance);
Assertions.assertNotEquals(map.get("1"), null);
webSocketPluginDataHandler.removeSelector(selectorData);
- Assertions.assertEquals(map.get("1"), null);
+ Assertions.assertNull(map.get("1"));
}
@Test
@@ -79,7 +79,7 @@ public class WebSocketPluginDataHandlerTest {
cache.get().cachedHandle("1_test", new WebSocketRuleHandle());
Assertions.assertNotEquals(cache.get().obtainHandle("1_test"), null);
webSocketPluginDataHandler.removeRule(ruleData);
- Assertions.assertEquals(cache.get().obtainHandle("1_test"), null);
+ Assertions.assertNull(cache.get().obtainHandle("1_test"));
}
@Test
diff --git
a/shenyu-plugin/shenyu-plugin-rewrite/src/test/java/org/apache/shenyu/plugin/rewrite/handler/RewritePluginDataHandlerTest.java
b/shenyu-plugin/shenyu-plugin-rewrite/src/test/java/org/apache/shenyu/plugin/rewrite/handler/RewritePluginDataHandlerTest.java
index 14a4ca6f7..8394c326a 100644
---
a/shenyu-plugin/shenyu-plugin-rewrite/src/test/java/org/apache/shenyu/plugin/rewrite/handler/RewritePluginDataHandlerTest.java
+++
b/shenyu-plugin/shenyu-plugin-rewrite/src/test/java/org/apache/shenyu/plugin/rewrite/handler/RewritePluginDataHandlerTest.java
@@ -30,9 +30,9 @@ import java.util.function.Supplier;
*/
public final class RewritePluginDataHandlerTest {
- private RewritePluginDataHandler rewritePluginDataHandler = new
RewritePluginDataHandler();
+ private final RewritePluginDataHandler rewritePluginDataHandler = new
RewritePluginDataHandler();
- private RuleData ruleData = new RuleData();
+ private final RuleData ruleData = new RuleData();
@Test
public void testHandlerRule() {
@@ -40,7 +40,7 @@ public final class RewritePluginDataHandlerTest {
ruleData.setHandle("{\"urlPath\":\"test\"}");
ruleData.setId("test");
rewritePluginDataHandler.handlerRule(ruleData);
- Supplier<CommonHandleCache<String, RewriteHandle>> cache =
rewritePluginDataHandler.CACHED_HANDLE;
+ Supplier<CommonHandleCache<String, RewriteHandle>> cache =
RewritePluginDataHandler.CACHED_HANDLE;
Assertions.assertNotNull(cache.get().obtainHandle("1_test"));
}
@@ -49,7 +49,7 @@ public final class RewritePluginDataHandlerTest {
ruleData.setSelectorId("1");
ruleData.setHandle("{\"urlPath\":\"test\"}");
ruleData.setId("test");
- Supplier<CommonHandleCache<String, RewriteHandle>> cache =
rewritePluginDataHandler.CACHED_HANDLE;
+ Supplier<CommonHandleCache<String, RewriteHandle>> cache =
RewritePluginDataHandler.CACHED_HANDLE;
cache.get().cachedHandle("1_test", new RewriteHandle());
Assertions.assertNotNull(cache.get().obtainHandle("1_test"));
rewritePluginDataHandler.removeRule(ruleData);
diff --git
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-apollo/src/test/java/org/apache/shenyu/register/client/server/apollo/ApolloClientTest.java
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-apollo/src/test/java/org/apache/shenyu/register/client/server/apollo/ApolloClientTest.java
index a5caa79a3..b11781379 100644
---
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-apollo/src/test/java/org/apache/shenyu/register/client/server/apollo/ApolloClientTest.java
+++
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-apollo/src/test/java/org/apache/shenyu/register/client/server/apollo/ApolloClientTest.java
@@ -18,6 +18,7 @@
package org.apache.shenyu.register.client.server.apollo;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -59,9 +60,9 @@ public class ApolloClientTest {
*/
@Test
public void testGetItemValue() {
-
when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("42");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("42");
assertEquals("42", apolloClient.getItemValue("Key"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
/**
@@ -70,9 +71,9 @@ public class ApolloClientTest {
@Test
public void testCreateOrUpdateItem() {
doNothing().when(apolloClient)
- .createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ .createOrUpdateItem(Mockito.any(), Mockito.<Object>any(),
Mockito.any());
apolloClient.createOrUpdateItem("Key", (Object) "Value", "Comment");
- verify(apolloClient).createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ verify(apolloClient).createOrUpdateItem(Mockito.any(),
Mockito.<Object>any(), Mockito.any());
}
/**
@@ -84,7 +85,7 @@ public class ApolloClientTest {
apolloClient.removeItem(keyToRemove);
verify(apolloClient).removeItem(keyToRemove);
apolloClient.getItemValue(keyToRemove);
- assertEquals(apolloClient.getItemValue(keyToRemove), null);
+ assertNull(apolloClient.getItemValue(keyToRemove));
}
/**
@@ -92,9 +93,9 @@ public class ApolloClientTest {
*/
@Test
public void testPublishNamespace() {
- doNothing().when(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ doNothing().when(apolloClient).publishNamespace(Mockito.any(),
Mockito.any());
apolloClient.publishNamespace("Dr", "1.0.2");
- verify(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ verify(apolloClient).publishNamespace(Mockito.any(), Mockito.any());
}
}
diff --git
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-polaris/src/test/java/org/apache/shenyu/register/client/server/polaris/PolarisClientServerRegisterRepositoryTest.java
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-polaris/src/test/java/org/apache/shenyu/register/client/server/polaris/PolarisClientServerRegisterRepositoryTest.java
index f38b6206b..2aa429853 100644
---
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-polaris/src/test/java/org/apache/shenyu/register/client/server/polaris/PolarisClientServerRegisterRepositoryTest.java
+++
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-polaris/src/test/java/org/apache/shenyu/register/client/server/polaris/PolarisClientServerRegisterRepositoryTest.java
@@ -174,7 +174,7 @@ public class PolarisClientServerRegisterRepositoryTest {
MockedStatic<ConfigAPIFactory> configAPIFactoryMockedStatic =
mockStatic(ConfigAPIFactory.class);
MockedStatic<SDKContext> sdkContextMockedStatic =
mockStatic(SDKContext.class);
MockedStatic<DiscoveryAPIFactory>
discoveryAPIFactoryMockedStatic = mockStatic(DiscoveryAPIFactory.class);
- MockedStatic<ConfigFileServiceFactory>
configFileServiceFactoryMockedStatic =
mockStatic(ConfigFileServiceFactory.class);
+ MockedStatic<ConfigFileServiceFactory>
configFileServiceFactoryMockedStatic =
mockStatic(ConfigFileServiceFactory.class)
) {
Configuration configService = mock(Configuration.class);
SDKContext sdkContext = mock(SDKContext.class);
diff --git
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClient.java
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClient.java
index 446814b49..257242018 100644
---
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClient.java
+++
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClient.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.register.client.server.zookeeper;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -223,7 +224,7 @@ public class ZookeeperClient {
public TreeCache addCache(final String path, final TreeCacheListener...
listeners) {
TreeCache cache = TreeCache.newBuilder(client, path).build();
caches.put(path, cache);
- if (listeners != null && listeners.length > 0) {
+ if (ArrayUtils.isNotEmpty(listeners)) {
for (TreeCacheListener listener : listeners) {
cache.getListenable().addListener(listener);
}
diff --git
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClientServerRegisterRepository.java
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClientServerRegisterRepository.java
index 3cc385067..3ca1e4620 100644
---
a/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClientServerRegisterRepository.java
+++
b/shenyu-register-center/shenyu-register-client-server/shenyu-register-client-server-zookeeper/src/main/java/org/apache/shenyu/register/client/server/zookeeper/ZookeeperClientServerRegisterRepository.java
@@ -38,7 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
@@ -172,11 +172,11 @@ public class ZookeeperClientServerRegisterRepository
implements ShenyuClientServ
switch (type) {
case NODE_ADDED:
uriRegisterDTO.setEventType(EventType.REGISTER);
- publishRegisterURI(Arrays.asList(uriRegisterDTO));
+
publishRegisterURI(Collections.singletonList(uriRegisterDTO));
break;
case NODE_REMOVED:
uriRegisterDTO.setEventType(EventType.OFFLINE);
- publishRegisterURI(Arrays.asList(uriRegisterDTO));
+
publishRegisterURI(Collections.singletonList(uriRegisterDTO));
break;
default:
break;
diff --git
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/test/java/org/apache/shenyu/register/client/apollo/ApolloClientTest.java
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/test/java/org/apache/shenyu/register/client/apollo/ApolloClientTest.java
index 7c24f907a..c2cc41a6a 100644
---
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/test/java/org/apache/shenyu/register/client/apollo/ApolloClientTest.java
+++
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-apollo/src/test/java/org/apache/shenyu/register/client/apollo/ApolloClientTest.java
@@ -59,9 +59,9 @@ public class ApolloClientTest {
*/
@Test
public void testGetItemValue() {
-
when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("42");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("42");
assertEquals("42", apolloClient.getItemValue("Key"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
/**
@@ -70,9 +70,9 @@ public class ApolloClientTest {
@Test
public void testCreateOrUpdateItem() {
doNothing().when(apolloClient)
- .createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ .createOrUpdateItem(Mockito.any(), Mockito.<Object>any(),
Mockito.any());
apolloClient.createOrUpdateItem("Key", (Object) "Value", "Comment");
- verify(apolloClient).createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ verify(apolloClient).createOrUpdateItem(Mockito.any(),
Mockito.<Object>any(), Mockito.any());
}
/**
@@ -80,9 +80,9 @@ public class ApolloClientTest {
*/
@Test
public void testPublishNamespace() {
- doNothing().when(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ doNothing().when(apolloClient).publishNamespace(Mockito.any(),
Mockito.any());
apolloClient.publishNamespace("Dr", "1.0.2");
- verify(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ verify(apolloClient).publishNamespace(Mockito.any(), Mockito.any());
}
}
diff --git
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java
index af2dbf909..cfbb5029a 100644
---
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java
+++
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/OkHttpToolsTest.java
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
*/
public final class OkHttpToolsTest {
- private String url = "http://localhost:9095";
+ private final String url = "http://localhost:9095";
private String getUrl;
diff --git
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-polaris/src/test/java/org/apache/shenyu/register/client/polaris/PolarisClientRegisterRepositoryTest.java
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-polaris/src/test/java/org/apache/shenyu/register/client/polaris/PolarisClientRegisterRepositoryTest.java
index fe2f377da..1135e9da0 100644
---
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-polaris/src/test/java/org/apache/shenyu/register/client/polaris/PolarisClientRegisterRepositoryTest.java
+++
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-polaris/src/test/java/org/apache/shenyu/register/client/polaris/PolarisClientRegisterRepositoryTest.java
@@ -141,7 +141,7 @@ public class PolarisClientRegisterRepositoryTest {
assertTrue(configFileService.getConfigFile(configFileMetadata).hasContent());
String dataStr =
GsonUtils.getInstance().toJson(Lists.newArrayList(metadata));
-
assertTrue(configFileService.getConfigFile(configFileMetadata).getContent().equals(dataStr));
+
assertEquals(configFileService.getConfigFile(configFileMetadata).getContent(),
dataStr);
}
@Test
diff --git
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-zookeeper/src/main/java/org/apache/shenyu/register/client/zookeeper/ZookeeperClient.java
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-zookeeper/src/main/java/org/apache/shenyu/register/client/zookeeper/ZookeeperClient.java
index 1a5ca3048..90d28b20a 100644
---
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-zookeeper/src/main/java/org/apache/shenyu/register/client/zookeeper/ZookeeperClient.java
+++
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-zookeeper/src/main/java/org/apache/shenyu/register/client/zookeeper/ZookeeperClient.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.register.client.zookeeper;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -223,7 +224,7 @@ public class ZookeeperClient {
public TreeCache addCache(final String path, final TreeCacheListener...
listeners) {
TreeCache cache = TreeCache.newBuilder(client, path).build();
caches.put(path, cache);
- if (listeners != null && listeners.length > 0) {
+ if (ArrayUtils.isNotEmpty(listeners)) {
for (TreeCacheListener listener : listeners) {
cache.getListenable().addListener(listener);
}
diff --git
a/shenyu-registry/shenyu-registry-apollo/src/test/java/org/apache/shenyu/registry/apollo/ApolloClientTest.java
b/shenyu-registry/shenyu-registry-apollo/src/test/java/org/apache/shenyu/registry/apollo/ApolloClientTest.java
index dd61b1aba..7659847fb 100644
---
a/shenyu-registry/shenyu-registry-apollo/src/test/java/org/apache/shenyu/registry/apollo/ApolloClientTest.java
+++
b/shenyu-registry/shenyu-registry-apollo/src/test/java/org/apache/shenyu/registry/apollo/ApolloClientTest.java
@@ -59,9 +59,9 @@ public class ApolloClientTest {
*/
@Test
public void testGetItemValue() {
-
when(apolloClient.getItemValue(Mockito.<String>any())).thenReturn("42");
+ when(apolloClient.getItemValue(Mockito.any())).thenReturn("42");
assertEquals("42", apolloClient.getItemValue("Key"));
- verify(apolloClient).getItemValue(Mockito.<String>any());
+ verify(apolloClient).getItemValue(Mockito.any());
}
/**
@@ -70,9 +70,9 @@ public class ApolloClientTest {
@Test
public void testCreateOrUpdateItem() {
doNothing().when(apolloClient)
- .createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ .createOrUpdateItem(Mockito.any(), Mockito.<Object>any(),
Mockito.any());
apolloClient.createOrUpdateItem("Key", (Object) "Value", "Comment");
- verify(apolloClient).createOrUpdateItem(Mockito.<String>any(),
Mockito.<Object>any(), Mockito.<String>any());
+ verify(apolloClient).createOrUpdateItem(Mockito.any(),
Mockito.<Object>any(), Mockito.any());
}
/**
@@ -90,9 +90,9 @@ public class ApolloClientTest {
*/
@Test
public void testPublishNamespace() {
- doNothing().when(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ doNothing().when(apolloClient).publishNamespace(Mockito.any(),
Mockito.any());
apolloClient.publishNamespace("Dr", "1.0.2");
- verify(apolloClient).publishNamespace(Mockito.<String>any(),
Mockito.<String>any());
+ verify(apolloClient).publishNamespace(Mockito.any(), Mockito.any());
}
}
diff --git
a/shenyu-registry/shenyu-registry-zookeeper/src/main/java/org/apache/shenyu/registry/zookeeper/ZookeeperClient.java
b/shenyu-registry/shenyu-registry-zookeeper/src/main/java/org/apache/shenyu/registry/zookeeper/ZookeeperClient.java
index 907b37ec5..e8531b0f1 100644
---
a/shenyu-registry/shenyu-registry-zookeeper/src/main/java/org/apache/shenyu/registry/zookeeper/ZookeeperClient.java
+++
b/shenyu-registry/shenyu-registry-zookeeper/src/main/java/org/apache/shenyu/registry/zookeeper/ZookeeperClient.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.registry.zookeeper;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -224,7 +225,7 @@ public class ZookeeperClient {
public TreeCache addCache(final String path, final TreeCacheListener...
listeners) {
TreeCache cache = TreeCache.newBuilder(client, path).build();
caches.put(path, cache);
- if (listeners != null && listeners.length > 0) {
+ if (ArrayUtils.isNotEmpty(listeners)) {
for (TreeCacheListener listener : listeners) {
cache.getListenable().addListener(listener);
}
diff --git
a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientMethodHandler.java
b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientMethodHandler.java
index a3fec3c14..b0b18be6b 100644
---
a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientMethodHandler.java
+++
b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientMethodHandler.java
@@ -46,7 +46,7 @@ public class ShenyuClientMethodHandler {
private final ShenyuSdkClient shenyuHttpClient;
- private RequestTemplate requestTemplate;
+ private final RequestTemplate requestTemplate;
private final Map<Class<? extends Annotation>,
AnnotatedParameterProcessor> annotatedArgumentProcessors;
diff --git
a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java
b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java
index 1e958f87c..de29ba0b0 100644
---
a/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java
+++
b/shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/support/SpringMvcContract.java
@@ -61,7 +61,7 @@ public class SpringMvcContract extends Contract.BaseContract {
protected void processAnnotationOnMethod(final RequestTemplate
requestTemplate, final Annotation methodAnnotation,
final Method method, final
ShenyuClientFactoryBean shenyuClientFactoryBean) {
- if (!RequestMapping.class.isInstance(methodAnnotation)
+ if (!(methodAnnotation instanceof RequestMapping)
&&
!methodAnnotation.annotationType().isAnnotationPresent(RequestMapping.class)) {
return;
}
@@ -120,13 +120,11 @@ public class SpringMvcContract extends
Contract.BaseContract {
}
private void parseHeaders(final RequestTemplate requestTemplate, final
RequestMapping annotation) {
- if (annotation.headers().length > 0) {
- for (String header : annotation.headers()) {
- int index = header.indexOf('=');
- if (!header.contains("!=") && index >= 0) {
-
requestTemplate.getHeaders().put(resolve(header.substring(0, index)),
-
Collections.singleton(resolve(header.substring(index + 1).trim())));
- }
+ for (String header : annotation.headers()) {
+ int index = header.indexOf('=');
+ if (!header.contains("!=") && index >= 0) {
+ requestTemplate.getHeaders().put(resolve(header.substring(0,
index)),
+ Collections.singleton(resolve(header.substring(index +
1).trim())));
}
}
}
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosACMConfigTest.java
b/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosACMConfigTest.java
index 2c1847311..3b619720e 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosACMConfigTest.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosACMConfigTest.java
@@ -23,8 +23,7 @@ import org.junit.jupiter.api.Test;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* add test case for {@link NacosACMConfig}.
@@ -78,10 +77,10 @@ public final class NacosACMConfigTest {
@Test
public void testEquals() {
- assertTrue(nacosACMConfig.equals(nacosACMConfig));
- assertTrue(nacosACMConfig.equals(that));
- assertFalse(nacosACMConfig.equals(null));
- assertFalse(nacosACMConfig.equals(new Object()));
+ assertEquals(nacosACMConfig, nacosACMConfig);
+ assertEquals(nacosACMConfig, that);
+ assertNotEquals(null, nacosACMConfig);
+ assertNotEquals(nacosACMConfig, new Object());
}
@Test
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosConfigTest.java
b/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosConfigTest.java
index b6857c072..aaa7fa742 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosConfigTest.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-nacos/src/test/java/org/apache/shenyu/sync/data/nacos/config/NacosConfigTest.java
@@ -23,8 +23,7 @@ import org.junit.jupiter.api.Test;
import java.util.Objects;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
/**
* add test case for {@link NacosConfig}.
@@ -72,10 +71,10 @@ public final class NacosConfigTest {
@Test
public void testEquals() {
- assertTrue(nacosConfig.equals(nacosConfig));
- assertTrue(nacosConfig.equals(that));
- assertFalse(nacosConfig.equals(null));
- assertFalse(nacosConfig.equals(new Object()));
+ assertEquals(nacosConfig, nacosConfig);
+ assertEquals(nacosConfig, that);
+ assertNotEquals(null, nacosConfig);
+ assertNotEquals(nacosConfig, new Object());
}
@Test
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-polaris/src/test/java/org/apache/shenyu/sync/data/polaris/handler/PolarisMockConfigFile.java
b/shenyu-sync-data-center/shenyu-sync-data-polaris/src/test/java/org/apache/shenyu/sync/data/polaris/handler/PolarisMockConfigFile.java
index eb90e3d57..f8cec6017 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-polaris/src/test/java/org/apache/shenyu/sync/data/polaris/handler/PolarisMockConfigFile.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-polaris/src/test/java/org/apache/shenyu/sync/data/polaris/handler/PolarisMockConfigFile.java
@@ -24,7 +24,7 @@ import java.lang.reflect.Type;
public class PolarisMockConfigFile implements ConfigFile {
- private String content;
+ private final String content;
public PolarisMockConfigFile(final String content) {
this.content = content;
diff --git
a/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperClient.java
b/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperClient.java
index 678bb76ba..7fc699c80 100644
---
a/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperClient.java
+++
b/shenyu-sync-data-center/shenyu-sync-data-zookeeper/src/main/java/org/apache/shenyu/sync/data/zookeeper/ZookeeperClient.java
@@ -17,6 +17,7 @@
package org.apache.shenyu.sync.data.zookeeper;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
@@ -226,7 +227,7 @@ public class ZookeeperClient implements AutoCloseable {
public TreeCache addCache(final String path, final TreeCacheListener...
listeners) {
TreeCache cache = TreeCache.newBuilder(client, path).build();
caches.put(path, cache);
- if (listeners != null && listeners.length > 0) {
+ if (ArrayUtils.isNotEmpty(listeners)) {
for (TreeCacheListener listener : listeners) {
cache.getListenable().addListener(listener);
}
diff --git
a/shenyu-web/src/main/java/org/apache/shenyu/web/handler/ShenyuWebHandler.java
b/shenyu-web/src/main/java/org/apache/shenyu/web/handler/ShenyuWebHandler.java
index 3c874f072..a69eed2d1 100644
---
a/shenyu-web/src/main/java/org/apache/shenyu/web/handler/ShenyuWebHandler.java
+++
b/shenyu-web/src/main/java/org/apache/shenyu/web/handler/ShenyuWebHandler.java
@@ -62,7 +62,7 @@ public final class ShenyuWebHandler implements WebHandler,
ApplicationListener<P
*/
private final List<ShenyuPlugin> sourcePlugins;
- private ShenyuLoaderService shenyuLoaderService;
+ private final ShenyuLoaderService shenyuLoaderService;
private final boolean scheduled;