1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

optimize code to match p3c check rules

Signed-off-by: jimin.jm <jimin.jm@alibaba-inc.com>
This commit is contained in:
jimin.jm
2019-05-08 20:27:23 +08:00
parent f7047f8be6
commit 4dcd68f6e1
21 changed files with 74 additions and 40 deletions

View File

@@ -60,6 +60,7 @@ public class DefaultHttpRequest implements HttpRequest {
return HttpMethod.resolve(getMethodValue());
}
@Override
public String getMethodValue() {
return method;
}

View File

@@ -73,6 +73,7 @@ public class MutableHttpServerRequest implements HttpServerRequest {
}
// Override method since Spring Framework 5.0
@Override
public String getMethodValue() {
return httpMethod.name();
}

View File

@@ -44,8 +44,12 @@ public class DubboRestServiceMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DubboRestServiceMetadata)) return false;
if (this == o) {
return true;
}
if (!(o instanceof DubboRestServiceMetadata)) {
return false;
}
DubboRestServiceMetadata that = (DubboRestServiceMetadata) o;
return Objects.equals(serviceRestMetadata, that.serviceRestMetadata) &&
Objects.equals(restMethodMetadata, that.restMethodMetadata);

View File

@@ -77,8 +77,12 @@ public class DubboTransportedMethodMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DubboTransportedMethodMetadata)) return false;
if (this == o) {
return true;
}
if (!(o instanceof DubboTransportedMethodMetadata)) {
return false;
}
DubboTransportedMethodMetadata that = (DubboTransportedMethodMetadata) o;
return Objects.equals(methodMetadata, that.methodMetadata) &&
Objects.equals(attributes, that.attributes);

View File

@@ -110,8 +110,12 @@ public class MethodMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MethodMetadata that = (MethodMetadata) o;
return Objects.equals(name, that.name) &&
Objects.equals(returnType, that.returnType) &&

View File

@@ -61,8 +61,12 @@ public class MethodParameterMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MethodParameterMetadata that = (MethodParameterMetadata) o;
return index == that.index &&
Objects.equals(name, that.name) &&

View File

@@ -235,8 +235,12 @@ public class RequestMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RequestMetadata)) return false;
if (this == o) {
return true;
}
if (!(o instanceof RequestMetadata)) {
return false;
}
RequestMetadata that = (RequestMetadata) o;
return Objects.equals(method, that.method) &&
Objects.equals(path, that.path) &&

View File

@@ -183,8 +183,12 @@ public class RestMethodMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RestMethodMetadata)) return false;
if (this == o) {
return true;
}
if (!(o instanceof RestMethodMetadata)) {
return false;
}
RestMethodMetadata that = (RestMethodMetadata) o;
return queryMapEncoded == that.queryMapEncoded &&
Objects.equals(method, that.method) &&

View File

@@ -52,8 +52,12 @@ public class ServiceRestMetadata {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ServiceRestMetadata)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ServiceRestMetadata)) {
return false;
}
ServiceRestMetadata that = (ServiceRestMetadata) o;
return Objects.equals(url, that.url) &&
Objects.equals(meta, that.meta);

View File

@@ -64,7 +64,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
protected static final String DUBBO_METADATA_SERVICE_CLASS_NAME = DubboMetadataService.class.getName();
private static final Set<String> schedulerTasks = new HashSet<>();
private static final Set<String> SCHEDULER_TASKS = new HashSet<>();
protected final Logger logger = LoggerFactory.getLogger(getClass());
@@ -164,7 +164,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
private void submitSchedulerTaskIfAbsent(URL url, NotifyListener listener) {
String taskId = url.toIdentityString();
if (schedulerTasks.add(taskId)) {
if (SCHEDULER_TASKS.add(taskId)) {
schedule(() -> doSubscribeDubboServiceURLs(url, listener));
}
}

View File

@@ -110,6 +110,7 @@ public class DubboGenericServiceFactory {
dataBinder.registerCustomEditor(String.class, "listener", new StringTrimmerEditor(true));
dataBinder.registerCustomEditor(Map.class, "parameters", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws java.lang.IllegalArgumentException {
// Trim all whitespace
String content = StringUtils.trimAllWhitespace(text);