Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022.x fix checkstyle #3362

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,29 @@
</configuration>
</plugin>

<!-- todo spring boot 3.0 upgrade: disable checkstyle temporarily -->
<!--<plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-checkstyle-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>checkstyle-validation</id>-->
<!-- <phase>validate</phase>-->
<!-- <goals>-->
<!-- <goal>check</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- &lt;!&ndash; Checkstyle rules inherited from spring-cloud-build &ndash;&gt;-->
<!-- <suppressionsLocation>${maven.multiModuleProjectDirectory}/eclipse/checkstyle-suppressions.xml</suppressionsLocation>-->
<!-- <includeTestSourceDirectory>true</includeTestSourceDirectory>-->
<!-- <consoleOutput>true</consoleOutput>-->
<!-- <failsOnError>true</failsOnError>-->
<!-- <failOnViolation>true</failOnViolation>-->
<!-- <violationSeverity>warning</violationSeverity>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle-validation</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<!-- Checkstyle rules inherited from spring-cloud-build -->
<suppressionsLocation>${maven.multiModuleProjectDirectory}/eclipse/checkstyle-suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
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 */@Componentpublic 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<FlowRule> flowRules = new ArrayList<FlowRule>(); 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<DegradeRule> degradeRules = new ArrayList<DegradeRule>(); 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!"); }}
/*
* 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<FlowRule> flowRules = new ArrayList<FlowRule>();
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<DegradeRule> degradeRules = new ArrayList<DegradeRule>();
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!");
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,77 @@
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 */@Componentpublic 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<FlowRule> flowRules = new ArrayList<FlowRule>(); 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<DegradeRule> degradeRules = new ArrayList<DegradeRule>(); 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!"); }}
/*
* 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<FlowRule> flowRules = new ArrayList<FlowRule>();
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<DegradeRule> degradeRules = new ArrayList<DegradeRule>();
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!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private Charsets() {
* <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">
* Standard charsets</a>:
* </p>
*
* @return An immutable, case-insensitive map from canonical charset names to charset
* objects.
* @see Charset#availableCharsets()
Expand All @@ -58,6 +59,7 @@ public static SortedMap<String, Charset> 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
*/
Expand All @@ -68,10 +70,10 @@ 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
* @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);
Expand All @@ -84,10 +86,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
Expand All @@ -102,10 +104,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset US_ASCII = StandardCharsets.US_ASCII;
Expand All @@ -120,10 +122,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16 = StandardCharsets.UTF_16;
Expand All @@ -137,10 +139,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
Expand All @@ -154,10 +156,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
Expand All @@ -171,10 +173,10 @@ public static Charset toCharset(final String charset) {
* encoding.
* </p>
*
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
* @see <a href=
* "https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Standard
* charsets</a>
* @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
*/
@Deprecated
public static final Charset UTF_8 = StandardCharsets.UTF_8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static void setServiceIds(List<String> 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<String> get() {
Expand Down
Loading