diff --git a/src/main/java/org/redkale/cluster/spi/ClusterAgent.java b/src/main/java/org/redkale/cluster/spi/ClusterAgent.java index 341a9554e..18f3c5168 100644 --- a/src/main/java/org/redkale/cluster/spi/ClusterAgent.java +++ b/src/main/java/org/redkale/cluster/spi/ClusterAgent.java @@ -54,6 +54,7 @@ public abstract class ClusterAgent { protected boolean waits; + @Nullable protected String[] protocols; //必须全大写 protected int[] ports; @@ -70,13 +71,9 @@ public abstract class ClusterAgent { this.config = config; this.name = config.getValue("name", ""); this.waits = config.getBoolValue("waits", false); - { - String ps = config.getValue("protocols", "").toUpperCase(); - if (ps == null || ps.isEmpty()) { - ps = "SNCP;HTTP"; - } - this.protocols = ps.split(";"); - } + String ps = config.getValue("protocols", "").toUpperCase(); + this.protocols = Utility.isEmpty(ps) ? null : ps.split(";"); + String ts = config.getValue("ports", ""); if (ts != null && !ts.isEmpty()) { String[] its = ts.split(";"); @@ -118,7 +115,7 @@ public abstract class ClusterAgent { public abstract boolean acceptsConf(AnyValue config); public boolean containsProtocol(String protocol) { - if (protocol == null || protocol.isEmpty()) { + if (Utility.isEmpty(protocol)) { return false; } return protocols == null || Utility.contains(protocols, protocol.toUpperCase()); @@ -336,6 +333,7 @@ public abstract class ClusterAgent { this.name = name; } + @Nullable public String[] getProtocols() { return protocols; } diff --git a/src/main/java/org/redkale/cluster/spi/HttpLocalRpcClient.java b/src/main/java/org/redkale/cluster/spi/HttpLocalRpcClient.java index 46117ae1c..70daad119 100644 --- a/src/main/java/org/redkale/cluster/spi/HttpLocalRpcClient.java +++ b/src/main/java/org/redkale/cluster/spi/HttpLocalRpcClient.java @@ -202,7 +202,7 @@ public class HttpLocalRpcClient extends HttpRpcClient { public static class HttpMessageLocalResponse extends HttpResponse { - private CompletableFuture future; + private final CompletableFuture future; public HttpMessageLocalResponse(HttpRequest req, CompletableFuture future) { super(req.getContext(), req, null); diff --git a/src/main/java/org/redkale/convert/DeMember.java b/src/main/java/org/redkale/convert/DeMember.java index 59dc06dd0..25e35f708 100644 --- a/src/main/java/org/redkale/convert/DeMember.java +++ b/src/main/java/org/redkale/convert/DeMember.java @@ -89,7 +89,7 @@ public final class DeMember { this.decoder = decoder; } - public static DeMember create(final ConvertFactory factory, final Class clazz, final String fieldName) { + public static DeMember create(ConvertFactory factory, Class clazz, String fieldName) { try { Field field = clazz.getDeclaredField(fieldName); return new DeMember<>(Attribute.create(field), factory.loadDecoder(field.getGenericType()), field, null); @@ -98,7 +98,7 @@ public final class DeMember { } } - public static DeMember create(final ConvertFactory factory, final Class clazz, final String fieldName, final Class fieldType) { + public static DeMember create(ConvertFactory factory, Class clazz, String fieldName, Class fieldType) { try { Field field = clazz.getDeclaredField(fieldName); return new DeMember<>(Attribute.create(clazz, fieldName, fieldType), factory.loadDecoder(fieldType), field, null); @@ -107,7 +107,7 @@ public final class DeMember { } } - public static DeMember create(final Attribute attribute, final ConvertFactory factory, final Class fieldType) { + public static DeMember create(Attribute attribute, ConvertFactory factory, Class fieldType) { return new DeMember<>(attribute, factory.loadDecoder(fieldType), null, null); } @@ -166,7 +166,8 @@ public final class DeMember { return (this.index == 0 ? Integer.MAX_VALUE : this.index) - (o.index == 0 ? Integer.MAX_VALUE : o.index); } if (this.index != 0) { - throw new ConvertException("fields (" + attribute.field() + ", " + o.attribute.field() + ") have same ConvertColumn.index(" + this.index + ") in " + attribute.declaringClass()); + throw new ConvertException("fields (" + attribute.field() + ", " + o.attribute.field() + + ") have same ConvertColumn.index(" + this.index + ") in " + attribute.declaringClass()); } return fieldSort ? this.attribute.field().compareTo(o.attribute.field()) : 0; } @@ -190,6 +191,7 @@ public final class DeMember { @Override public String toString() { - return "DeMember{" + "attribute=" + attribute.field() + ", position=" + position + ", tag=" + tag + ", decoder=" + (decoder == null ? null : decoder.getClass().getName()) + '}'; + return "DeMember{" + "attribute=" + attribute.field() + ", position=" + position + + ", tag=" + tag + ", decoder=" + (decoder == null ? null : decoder.getClass().getName()) + '}'; } }