From 136180c356471dd261b722e8b0a28e4741d3ef3d Mon Sep 17 00:00:00 2001
From: ruansheng
Date: Mon, 26 Jun 2023 10:41:47 +0800
Subject: [PATCH 1/3] Fix checkstyle (#2961)
---
pom.xml | 46 +++++++++----------
.../cloud/examples/DatabaseConfiguration.java | 4 --
.../cloud/examples/DatabaseConfiguration.java | 4 --
.../config/DatabaseConfiguration.java | 4 --
.../SentinelRulesConfiguration.java | 2 +-
.../SentinelRulesConfiguration.java | 2 +-
.../alibaba/cloud/commons/io/Charsets.java | 17 ++++---
.../NacosJsonPropertySourceLoaderTests.java | 5 +-
.../cloud/nacos/discovery/ServiceCache.java | 2 +-
.../NacosConfigServerAutoConfiguration.java | 4 +-
.../nacos/registry/NacosRegistration.java | 4 +-
.../seata/web/SeataHandlerInterceptor.java | 7 ++-
.../sentinel/SentinelFeignLazilyTests.java | 6 ---
13 files changed, 45 insertions(+), 62 deletions(-)
diff --git a/pom.xml b/pom.xml
index 27723688df..f17db869e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -205,29 +205,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ checkstyle-validation
+ validate
+
+ check
+
+
+
+ ${maven.multiModuleProjectDirectory}/eclipse/checkstyle-suppressions.xml
+ true
+ true
+ true
+ true
+ warning
+
+
+
+
+
org.apache.maven.plugins
maven-compiler-plugin
diff --git a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
index 6180c57700..a3892b8387 100644
--- a/spring-cloud-alibaba-examples/seata-example/account-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
+++ b/spring-cloud-alibaba-examples/seata-example/account-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
@@ -18,12 +18,8 @@
import javax.sql.DataSource;
-import com.alibaba.druid.pool.DruidDataSource;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
/**
diff --git a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
index 612901d6a6..d51e17825b 100644
--- a/spring-cloud-alibaba-examples/seata-example/order-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
+++ b/spring-cloud-alibaba-examples/seata-example/order-service/src/main/java/com/alibaba/cloud/examples/DatabaseConfiguration.java
@@ -18,12 +18,8 @@
import javax.sql.DataSource;
-import com.alibaba.druid.pool.DruidDataSource;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
/**
diff --git a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/java/com/alibaba/cloud/examples/config/DatabaseConfiguration.java b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/java/com/alibaba/cloud/examples/config/DatabaseConfiguration.java
index 7bd92f198d..047cd52008 100644
--- a/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/java/com/alibaba/cloud/examples/config/DatabaseConfiguration.java
+++ b/spring-cloud-alibaba-examples/seata-example/storage-service/src/main/java/com/alibaba/cloud/examples/config/DatabaseConfiguration.java
@@ -18,12 +18,8 @@
import javax.sql.DataSource;
-import com.alibaba.druid.pool.DruidDataSource;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
/**
diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
index b915eea18a..e7a999d417 100644
--- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
+++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
@@ -1 +1 @@
-package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
+/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
index f55246698d..3b18c91b96 100644
--- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
+++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
@@ -1 +1 @@
-package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
+/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
diff --git a/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
index 76c16ac655..a736247296 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
@@ -40,6 +40,7 @@ private Charsets() {
*
* Standard charsets:
*
+ *
* @return An immutable, case-insensitive map from canonical charset names to charset
* objects.
* @see Charset#availableCharsets()
@@ -58,6 +59,7 @@ public static SortedMap requiredCharsets() {
/**
* Returns the given Charset or the default Charset if the given Charset is null.
+ *
* @param charset A charset or null.
* @return the given Charset or the default Charset if the given Charset is null
*/
@@ -68,10 +70,11 @@ public static Charset toCharset(final Charset charset) {
/**
* Returns a Charset for the named charset. If the name is null, return the default
* Charset.
+ *
* @param charset The name of the requested charset, may be null.
* @return a Charset for the named charset
* @throws java.nio.charset.UnsupportedCharsetException If the named charset is
- * unavailable
+ * unavailable
*/
public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
@@ -84,10 +87,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
@@ -102,10 +105,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset US_ASCII = StandardCharsets.US_ASCII;
@@ -120,10 +123,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16 = StandardCharsets.UTF_16;
@@ -137,10 +140,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
@@ -154,10 +157,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
@@ -171,10 +174,10 @@ public static Charset toCharset(final String charset) {
* encoding.
*
*
+ * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see Standard
* charsets
- * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_8 = StandardCharsets.UTF_8;
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/parser/NacosJsonPropertySourceLoaderTests.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/parser/NacosJsonPropertySourceLoaderTests.java
index 77026d9764..e0dd5aa614 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/parser/NacosJsonPropertySourceLoaderTests.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/test/java/com/alibaba/cloud/nacos/parser/NacosJsonPropertySourceLoaderTests.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.alibaba.cloud.nacos.parser;
import java.io.IOException;
@@ -36,8 +37,8 @@ public class NacosJsonPropertySourceLoaderTests {
public void testJsonPropWithComment() throws IOException {
String propJsonStr = """
{
- // test comment
- "name": "jack"
+ // test comment
+ "name": "jack"
}
""";
ByteArrayResource resource = new ByteArrayResource(propJsonStr.getBytes());
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/ServiceCache.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/ServiceCache.java
index 3ad1e5fb6f..c3075f77a3 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/ServiceCache.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/ServiceCache.java
@@ -87,8 +87,8 @@ public static void setServiceIds(List serviceIds) {
/**
* Get all services.
- * @deprecated since 2021.0.1.1, use {@link #getServiceIds()} instead.
* @return all services
+ * @deprecated since 2021.0.1.1, use {@link #getServiceIds()} instead.
*/
@Deprecated
public static List get() {
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/configclient/NacosConfigServerAutoConfiguration.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/configclient/NacosConfigServerAutoConfiguration.java
index e8c9c76640..b4765df277 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/configclient/NacosConfigServerAutoConfiguration.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/discovery/configclient/NacosConfigServerAutoConfiguration.java
@@ -18,8 +18,8 @@
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
-
import jakarta.annotation.PostConstruct;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -34,7 +34,7 @@
*/
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties
-@ConditionalOnClass({ NacosDiscoveryProperties.class, ConfigServerProperties.class })
+@ConditionalOnClass({NacosDiscoveryProperties.class, ConfigServerProperties.class})
public class NacosConfigServerAutoConfiguration {
@Autowired(required = false)
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosRegistration.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosRegistration.java
index 135d493f53..6bc00955cd 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosRegistration.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-discovery/src/main/java/com/alibaba/cloud/nacos/registry/NacosRegistration.java
@@ -20,13 +20,11 @@
import java.util.List;
import java.util.Map;
-
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
-
import jakarta.annotation.PostConstruct;
+
import org.springframework.cloud.client.DefaultServiceInstance;
-import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.ManagementServerPortUtils;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.context.ApplicationContext;
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/web/SeataHandlerInterceptor.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/web/SeataHandlerInterceptor.java
index 774fe93bcb..10d2e25221 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/web/SeataHandlerInterceptor.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/web/SeataHandlerInterceptor.java
@@ -16,11 +16,10 @@
package com.alibaba.cloud.seata.web;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
import io.seata.common.util.StringUtils;
import io.seata.core.context.RootContext;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +30,7 @@
*
* Seata HandlerInterceptor, Convert Seata information into
* @see io.seata.core.context.RootContext from http request's header in
- * {@link org.springframework.web.servlet.HandlerInterceptor#preHandle(HttpServletRequest , HttpServletResponse , Object )},
+ * {@link org.springframework.web.servlet.HandlerInterceptor#preHandle(HttpServletRequest, HttpServletResponse, Object)},
* And clean up Seata information after servlet method invocation in
* {@link org.springframework.web.servlet.HandlerInterceptor#afterCompletion(HttpServletRequest, HttpServletResponse, Object, Exception)}
*/
diff --git a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/test/java/com/alibaba/cloud/sentinel/SentinelFeignLazilyTests.java b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/test/java/com/alibaba/cloud/sentinel/SentinelFeignLazilyTests.java
index 4a3c3997ab..6e338157bf 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/test/java/com/alibaba/cloud/sentinel/SentinelFeignLazilyTests.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/test/java/com/alibaba/cloud/sentinel/SentinelFeignLazilyTests.java
@@ -16,12 +16,6 @@
package com.alibaba.cloud.sentinel;
-import java.util.Arrays;
-
-import com.alibaba.csp.sentinel.slots.block.RuleConstant;
-import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
-import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
From 0103548f44b7fe7a366e16a3a4a06a7ce81a78df Mon Sep 17 00:00:00 2001
From: ruansheng
Date: Mon, 26 Jun 2023 10:44:06 +0800
Subject: [PATCH 2/3] reformat code file
---
.../SentinelRulesConfiguration.java | 80 ++++++++++++++++++-
.../SentinelRulesConfiguration.java | 78 +++++++++++++++++-
2 files changed, 156 insertions(+), 2 deletions(-)
diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
index e7a999d417..b011047fc8 100644
--- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
+++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-openfeign-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
@@ -1 +1,79 @@
-/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
+/*
+ * Copyright 2013-2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.alibaba.cloud.examples.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.alibaba.csp.sentinel.slots.block.RuleConstant;
+import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
+import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
+import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
+import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
+import jakarta.annotation.PostConstruct;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @description
+ * @author ChengPu raozihao
+ * @date 2023/2/11
+ */
+@Component
+public class SentinelRulesConfiguration {
+
+
+ /**
+ * You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
+ */
+ @PostConstruct
+ public void init() {
+ System.out.println("Load Sentinel Rules start!");
+ List flowRules = new ArrayList();
+ FlowRule flowRule = new FlowRule();
+ flowRule.setResource("GET:https://httpbin.org/get");
+ flowRule.setCount(1);
+ flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
+ flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
+ flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
+ flowRule.setLimitApp("default");
+ flowRules.add(flowRule);
+ FlowRuleManager.loadRules(flowRules);
+
+ List degradeRules = new ArrayList();
+ DegradeRule degradeRule1 = new DegradeRule();
+ degradeRule1.setResource("GET:https://httpbin.org/status/500");
+ degradeRule1.setCount(1);
+ degradeRule1.setMinRequestAmount(1);
+ degradeRule1.setTimeWindow(30);
+ degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
+ degradeRule1.setLimitApp("default");
+ degradeRules.add(degradeRule1);
+
+ DegradeRule degradeRule2 = new DegradeRule();
+ degradeRule2.setResource("GET:https://httpbin.org/delay/3");
+ degradeRule2.setCount(1);
+ degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
+ degradeRule2.setSlowRatioThreshold(0.1);
+ degradeRule2.setMinRequestAmount(1);
+ degradeRule2.setTimeWindow(30);
+ degradeRule2.setLimitApp("default");
+ degradeRules.add(degradeRule2);
+ DegradeRuleManager.loadRules(degradeRules);
+ System.out.println("Load Sentinel Rules end!");
+ }
+}
diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
index 3b18c91b96..b56f72f73a 100644
--- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
+++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-resttemplate-example/src/main/java/com/alibaba/cloud/examples/configuration/SentinelRulesConfiguration.java
@@ -1 +1,77 @@
-/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.examples.configuration;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Component;
/**
* @description
* @author ChengPu raozihao
* @date 2023/2/11
*/
@Component
public class SentinelRulesConfiguration {
/**
* You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
*/
@PostConstruct
public void init() {
System.out.println("Load Sentinel Rules start!");
List flowRules = new ArrayList();
FlowRule flowRule = new FlowRule();
flowRule.setResource("GET:https://httpbin.org/get");
flowRule.setCount(1);
flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRules.add(flowRule);
FlowRuleManager.loadRules(flowRules);
List degradeRules = new ArrayList();
DegradeRule degradeRule1 = new DegradeRule();
degradeRule1.setResource("GET:https://httpbin.org/status/500");
degradeRule1.setCount(1);
degradeRule1.setMinRequestAmount(1);
degradeRule1.setTimeWindow(30);
degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
degradeRule1.setLimitApp("default");
degradeRules.add(degradeRule1);
DegradeRule degradeRule2 = new DegradeRule();
degradeRule2.setResource("GET:https://httpbin.org/delay/3");
degradeRule2.setCount(1);
degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
degradeRule2.setSlowRatioThreshold(0.1);
degradeRule2.setMinRequestAmount(1);
degradeRule2.setTimeWindow(30);
degradeRule2.setLimitApp("default");
degradeRules.add(degradeRule2);
DegradeRuleManager.loadRules(degradeRules);
System.out.println("Load Sentinel Rules end!");
}
}
\ No newline at end of file
+/*
+ * Copyright 2013-2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.alibaba.cloud.examples.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.alibaba.csp.sentinel.slots.block.RuleConstant;
+import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
+import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
+import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
+import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
+import jakarta.annotation.PostConstruct;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @description
+ * @author ChengPu raozihao
+ * @date 2023/2/11
+ */
+@Component
+public class SentinelRulesConfiguration {
+ /**
+ * You can configure sentinel rules by referring https://github.com/alibaba/Sentinel/wiki/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8#%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%94%B9%E8%A7%84%E5%88%99.
+ */
+ @PostConstruct
+ public void init() {
+ System.out.println("Load Sentinel Rules start!");
+ List flowRules = new ArrayList();
+ FlowRule flowRule = new FlowRule();
+ flowRule.setResource("GET:https://httpbin.org/get");
+ flowRule.setCount(1);
+ flowRule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_DEFAULT);
+ flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
+ flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
+ flowRule.setLimitApp("default");
+ flowRules.add(flowRule);
+ FlowRuleManager.loadRules(flowRules);
+
+ List degradeRules = new ArrayList();
+ DegradeRule degradeRule1 = new DegradeRule();
+ degradeRule1.setResource("GET:https://httpbin.org/status/500");
+ degradeRule1.setCount(1);
+ degradeRule1.setMinRequestAmount(1);
+ degradeRule1.setTimeWindow(30);
+ degradeRule1.setGrade(RuleConstant.DEGRADE_GRADE_EXCEPTION_COUNT);
+ degradeRule1.setLimitApp("default");
+ degradeRules.add(degradeRule1);
+
+ DegradeRule degradeRule2 = new DegradeRule();
+ degradeRule2.setResource("GET:https://httpbin.org/delay/3");
+ degradeRule2.setCount(1);
+ degradeRule2.setGrade(RuleConstant.DEGRADE_GRADE_RT);
+ degradeRule2.setSlowRatioThreshold(0.1);
+ degradeRule2.setMinRequestAmount(1);
+ degradeRule2.setTimeWindow(30);
+ degradeRule2.setLimitApp("default");
+ degradeRules.add(degradeRule2);
+ DegradeRuleManager.loadRules(degradeRules);
+ System.out.println("Load Sentinel Rules end!");
+ }
+}
From c625810f9c97c1743016432191efa07819ac878d Mon Sep 17 00:00:00 2001
From: ruansheng
Date: Mon, 26 Jun 2023 10:45:39 +0800
Subject: [PATCH 3/3] Optimize document comments
---
.../src/main/java/com/alibaba/cloud/commons/io/Charsets.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
index a736247296..113ee78240 100644
--- a/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
+++ b/spring-cloud-alibaba-starters/spring-cloud-alibaba-commons/src/main/java/com/alibaba/cloud/commons/io/Charsets.java
@@ -73,8 +73,7 @@ public static Charset toCharset(final Charset charset) {
*
* @param charset The name of the requested charset, may be null.
* @return a Charset for the named charset
- * @throws java.nio.charset.UnsupportedCharsetException If the named charset is
- * unavailable
+ * @throws java.nio.charset.UnsupportedCharsetException If the named charset is unavailable
*/
public static Charset toCharset(final String charset) {
return charset == null ? Charset.defaultCharset() : Charset.forName(charset);