diff --git a/src/main/java/com/alipay/remoting/ProtocolCode.java b/src/main/java/com/alipay/remoting/ProtocolCode.java index 8f27438b..b41c7653 100644 --- a/src/main/java/com/alipay/remoting/ProtocolCode.java +++ b/src/main/java/com/alipay/remoting/ProtocolCode.java @@ -70,4 +70,4 @@ public int hashCode() { public String toString() { return "ProtocolVersion{" + "version=" + Arrays.toString(version) + '}'; } -} \ No newline at end of file +} diff --git a/src/main/java/com/alipay/remoting/Url.java b/src/main/java/com/alipay/remoting/Url.java index 732dc6ae..6bdd1380 100644 --- a/src/main/java/com/alipay/remoting/Url.java +++ b/src/main/java/com/alipay/remoting/Url.java @@ -28,7 +28,7 @@ /** * URL definition. - * + * * @author xiaomin.cxm * @version $Id: Url.java, v 0.1 Mar 11, 2016 6:01:59 PM xiaomin.cxm Exp $ */ @@ -65,7 +65,7 @@ public class Url { /** * Constructor with originUrl - * + * * @param originUrl */ protected Url(String originUrl) { @@ -77,8 +77,8 @@ protected Url(String originUrl) { * - * + * + * * @param ip * @param port */ @@ -91,12 +91,12 @@ public Url(String ip, int port) { /** * Constructor with originUrl, ip and port - * + * * - * + * + * * @param originUrl * @param ip * @param port @@ -110,13 +110,13 @@ public Url(String originUrl, String ip, int port) { /** * Constructor with originUrl, ip, port and properties - * + * * - * + * + * * @param originUrl * @param ip * @param port @@ -129,13 +129,13 @@ public Url(String originUrl, String ip, int port, Properties properties) { /** * Constructor with originUrl, ip, port, uniqueKey and properties - * + * * - * + * * @param originUrl * @param ip * @param port @@ -150,7 +150,7 @@ public Url(String originUrl, String ip, int port, String uniqueKey, Properties p /** * Get property value according to property key - * + * * @param key property key * @return property value */ @@ -253,7 +253,7 @@ public int hashCode() { @Override public String toString() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(32); sb.append("Origin url [").append(this.originUrl).append("], Unique key [") .append(this.uniqueKey).append("]."); return sb.toString(); diff --git a/src/main/java/com/alipay/remoting/rpc/RpcInvokeCallbackListener.java b/src/main/java/com/alipay/remoting/rpc/RpcInvokeCallbackListener.java index 8020e0d4..f36663a7 100644 --- a/src/main/java/com/alipay/remoting/rpc/RpcInvokeCallbackListener.java +++ b/src/main/java/com/alipay/remoting/rpc/RpcInvokeCallbackListener.java @@ -35,7 +35,7 @@ /** * Listener which listens the Rpc invoke result, and then invokes the call back. - * + * * @author jiangping * @version $Id: RpcInvokeCallbackListener.java, v 0.1 2015-9-30 AM10:36:34 tao Exp $ */ @@ -53,7 +53,7 @@ public RpcInvokeCallbackListener(String address) { this.address = address; } - /** + /** * @see com.alipay.remoting.InvokeCallbackListener#onResponse(com.alipay.remoting.InvokeFuture) */ @Override @@ -80,14 +80,14 @@ class CallbackTask implements Runnable { String remoteAddress; /** - * + * */ public CallbackTask(String remoteAddress, InvokeFuture future) { this.remoteAddress = remoteAddress; this.future = future; } - /** + /** * @see java.lang.Runnable#run() */ @Override @@ -134,7 +134,7 @@ public void run() { RpcResponseCommand resp = (RpcResponseCommand) response; resp.deserialize(); Object ex = resp.getResponseObject(); - if (ex != null && ex instanceof Throwable) { + if (ex instanceof Throwable) { e = new InvokeServerException(msg, (Throwable) ex); } else { e = new InvokeServerException(msg); @@ -191,7 +191,7 @@ public void run() { } // end of run } - /** + /** * @see com.alipay.remoting.InvokeCallbackListener#getRemoteAddress() */ @Override diff --git a/src/main/java/com/alipay/remoting/rpc/RpcResponseResolver.java b/src/main/java/com/alipay/remoting/rpc/RpcResponseResolver.java index 77bf02e0..59c3a638 100644 --- a/src/main/java/com/alipay/remoting/rpc/RpcResponseResolver.java +++ b/src/main/java/com/alipay/remoting/rpc/RpcResponseResolver.java @@ -35,7 +35,7 @@ /** * Resolve response object from response command. - * + * * @author jiangping * @version $Id: RpcResponseResolver.java, v 0.1 2015-10-8 PM2:47:29 tao Exp $ */ @@ -151,7 +151,7 @@ private static Throwable toThrowable(ResponseCommand responseCommand) throws Cod RpcResponseCommand resp = (RpcResponseCommand) responseCommand; resp.deserialize(); Object ex = resp.getResponseObject(); - if (ex != null && ex instanceof Throwable) { + if (ex instanceof Throwable) { return (Throwable) ex; } return null; diff --git a/src/main/java/com/alipay/remoting/rpc/protocol/AsynMultiInterestUserProcessor.java b/src/main/java/com/alipay/remoting/rpc/protocol/AsyncMultiInterestUserProcessor.java similarity index 84% rename from src/main/java/com/alipay/remoting/rpc/protocol/AsynMultiInterestUserProcessor.java rename to src/main/java/com/alipay/remoting/rpc/protocol/AsyncMultiInterestUserProcessor.java index fc7e679a..fabde7c8 100644 --- a/src/main/java/com/alipay/remoting/rpc/protocol/AsynMultiInterestUserProcessor.java +++ b/src/main/java/com/alipay/remoting/rpc/protocol/AsyncMultiInterestUserProcessor.java @@ -23,11 +23,11 @@ /** * Extends this to process user defined request in ASYNC way.
- * If you want process reqeuest in SYNC way, please extends {@link SyncMutiInterestUserProcessor}. + * If you want process request in SYNC way, please extends {@link SyncMultiInterestUserProcessor}. * @author muyun.cyt (muyun.cyt@antfin.com) 2018/7/5 11:19 AM */ -public abstract class AsynMultiInterestUserProcessor extends - AbstractMultiInterestUserProcessor { +public abstract class AsyncMultiInterestUserProcessor extends + AbstractMultiInterestUserProcessor { /** * unsupported here! * @@ -36,7 +36,7 @@ public abstract class AsynMultiInterestUserProcessor extends @Override public Object handleRequest(BizContext bizCtx, T request) throws Exception { throw new UnsupportedOperationException( - "SYNC handle request is unsupported in AsynMultiInterestUserProcessor!"); + "SYNC handle request is unsupported in AsyncMultiInterestUserProcessor!"); } /** diff --git a/src/main/java/com/alipay/remoting/rpc/protocol/AsyncUserProcessor.java b/src/main/java/com/alipay/remoting/rpc/protocol/AsyncUserProcessor.java index 383a5e54..578c24fc 100644 --- a/src/main/java/com/alipay/remoting/rpc/protocol/AsyncUserProcessor.java +++ b/src/main/java/com/alipay/remoting/rpc/protocol/AsyncUserProcessor.java @@ -21,15 +21,15 @@ /** * Extends this to process user defined request in ASYNC way.
- * If you want process reqeuest in SYNC way, please extends {@link SyncUserProcessor}. - * + * If you want process request in SYNC way, please extends {@link SyncUserProcessor}. + * * @author xiaomin.cxm * @version $Id: AsyncUserProcessor.java, v 0.1 May 16, 2016 8:18:03 PM xiaomin.cxm Exp $ */ public abstract class AsyncUserProcessor extends AbstractUserProcessor { /** * unsupported here! - * + * * @see com.alipay.remoting.rpc.protocol.UserProcessor#handleRequest(com.alipay.remoting.BizContext, java.lang.Object) */ @Override @@ -49,4 +49,4 @@ public Object handleRequest(BizContext bizCtx, T request) throws Exception { */ @Override public abstract String interest(); -} \ No newline at end of file +} diff --git a/src/main/java/com/alipay/remoting/rpc/protocol/SyncMutiInterestUserProcessor.java b/src/main/java/com/alipay/remoting/rpc/protocol/SyncMultiInterestUserProcessor.java similarity index 84% rename from src/main/java/com/alipay/remoting/rpc/protocol/SyncMutiInterestUserProcessor.java rename to src/main/java/com/alipay/remoting/rpc/protocol/SyncMultiInterestUserProcessor.java index 75153046..2c0fda2a 100644 --- a/src/main/java/com/alipay/remoting/rpc/protocol/SyncMutiInterestUserProcessor.java +++ b/src/main/java/com/alipay/remoting/rpc/protocol/SyncMultiInterestUserProcessor.java @@ -23,12 +23,12 @@ /** * Extends this to process user defined request in SYNC way.
- * If you want process reqeuest in ASYNC way, please extends {@link AsynMultiInterestUserProcessor}. + * If you want process request in ASYNC way, please extends {@link AsyncMultiInterestUserProcessor}. * * @author muyun.cyt (muyun.cyt@antfin.com) 2018/7/5 11:19 AM */ -public abstract class SyncMutiInterestUserProcessor extends - AbstractMultiInterestUserProcessor { +public abstract class SyncMultiInterestUserProcessor extends + AbstractMultiInterestUserProcessor { /** * @see com.alipay.remoting.rpc.protocol.UserProcessor#handleRequest(com.alipay.remoting.BizContext, java.lang.Object) @@ -44,7 +44,7 @@ public abstract class SyncMutiInterestUserProcessor extends @Override public void handleRequest(BizContext bizCtx, AsyncContext asyncCtx, T request) { throw new UnsupportedOperationException( - "ASYNC handle request is unsupported in SyncMutiInterestUserProcessor!"); + "ASYNC handle request is unsupported in SyncMultiInterestUserProcessor!"); } /** diff --git a/src/main/java/com/alipay/remoting/rpc/protocol/SyncUserProcessor.java b/src/main/java/com/alipay/remoting/rpc/protocol/SyncUserProcessor.java index b32acc93..3c6800c0 100644 --- a/src/main/java/com/alipay/remoting/rpc/protocol/SyncUserProcessor.java +++ b/src/main/java/com/alipay/remoting/rpc/protocol/SyncUserProcessor.java @@ -21,8 +21,8 @@ /** * Extends this to process user defined request in SYNC way.
- * If you want process reqeuest in ASYNC way, please extends {@link AsyncUserProcessor}. - * + * If you want process request in ASYNC way, please extends {@link AsyncUserProcessor}. + * * @author xiaomin.cxm * @version $Id: SyncUserProcessor.java, v 0.1 May 19, 2016 2:47:21 PM xiaomin.cxm Exp $ */ @@ -35,7 +35,7 @@ public abstract class SyncUserProcessor extends AbstractUserProcessor { /** * unsupported here! - * + * * @see com.alipay.remoting.rpc.protocol.UserProcessor#handleRequest(com.alipay.remoting.BizContext, com.alipay.remoting.AsyncContext, java.lang.Object) */ @Override diff --git a/src/test/java/com/alipay/remoting/rpc/common/PortScan.java b/src/test/java/com/alipay/remoting/rpc/common/PortScan.java index bcc93b88..c77d829e 100644 --- a/src/test/java/com/alipay/remoting/rpc/common/PortScan.java +++ b/src/test/java/com/alipay/remoting/rpc/common/PortScan.java @@ -38,8 +38,10 @@ static public int select() { ioe.printStackTrace(); } finally { try { - ss.close(); - logger.warn("Server socket close status: {}", ss.isClosed()); + if (ss != null) { + ss.close(); + logger.warn("Server socket close status: {}", ss.isClosed()); + } } catch (IOException e) { } } diff --git a/src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java b/src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java index 27477b2f..c95cf7ca 100644 --- a/src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java +++ b/src/test/java/com/alipay/remoting/rpc/exception/ExceptionTest.java @@ -44,7 +44,7 @@ /** * exception test - * + * * @author xiaomin.cxm * @version $Id: ExceptionTest.java, v 0.1 Apr 6, 2016 9:41:53 PM xiaomin.cxm Exp $ */ @@ -82,7 +82,7 @@ public void stop() { public void testSyncNoProcessor() { server.registerUserProcessor(new SimpleServerUserProcessor()); try { - client.invokeSync(addr, new String("No processor for String now!"), 3000); + client.invokeSync(addr, "No processor for String now!", 3000); } catch (Exception e) { Assert.assertEquals(InvokeServerException.class, e.getClass()); } diff --git a/src/test/java/com/alipay/remoting/rpc/userprocessor/UserProcessorRegisterHelperTest.java b/src/test/java/com/alipay/remoting/rpc/userprocessor/UserProcessorRegisterHelperTest.java index 34ea5efc..f719f3b2 100644 --- a/src/test/java/com/alipay/remoting/rpc/userprocessor/UserProcessorRegisterHelperTest.java +++ b/src/test/java/com/alipay/remoting/rpc/userprocessor/UserProcessorRegisterHelperTest.java @@ -20,17 +20,14 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import com.alipay.remoting.rpc.protocol.*; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.alipay.remoting.BizContext; import com.alipay.remoting.rpc.common.SimpleServerUserProcessor; -import com.alipay.remoting.rpc.protocol.MultiInterestUserProcessor; -import com.alipay.remoting.rpc.protocol.SyncMutiInterestUserProcessor; -import com.alipay.remoting.rpc.protocol.SyncUserProcessor; -import com.alipay.remoting.rpc.protocol.UserProcessor; -import com.alipay.remoting.rpc.protocol.UserProcessorRegisterHelper; +import com.alipay.remoting.rpc.protocol.SyncMultiInterestUserProcessor; import com.alipay.remoting.rpc.userprocessor.multiinterestprocessor.SimpleServerMultiInterestUserProcessor; /** @@ -85,7 +82,7 @@ public String interest() { @Test public void testInterestEmptyException() { - MultiInterestUserProcessor userProcessor = new SyncMutiInterestUserProcessor() { + MultiInterestUserProcessor userProcessor = new SyncMultiInterestUserProcessor() { @Override public Object handleRequest(BizContext bizCtx, Object request) throws Exception { return request; diff --git a/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleClientMultiInterestUserProcessor.java b/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleClientMultiInterestUserProcessor.java index a65cace6..443567a8 100644 --- a/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleClientMultiInterestUserProcessor.java +++ b/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleClientMultiInterestUserProcessor.java @@ -32,14 +32,14 @@ import com.alipay.remoting.InvokeContext; import com.alipay.remoting.NamedThreadFactory; import com.alipay.remoting.rpc.common.RequestBody; -import com.alipay.remoting.rpc.protocol.SyncMutiInterestUserProcessor; +import com.alipay.remoting.rpc.protocol.SyncMultiInterestUserProcessor; /** * @antuor muyun.cyt (muyun.cyt@antfin.com) 2018/7/5 11:20 AM */ public class SimpleClientMultiInterestUserProcessor extends - SyncMutiInterestUserProcessor { + SyncMultiInterestUserProcessor { /** logger */ private static final Logger logger = LoggerFactory .getLogger(SimpleClientMultiInterestUserProcessor.class); @@ -237,4 +237,4 @@ public List multiInterest() { list.add(RequestBodyC2.class.getName()); return list; } -} \ No newline at end of file +} diff --git a/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleServerMultiInterestUserProcessor.java b/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleServerMultiInterestUserProcessor.java index 43fd3706..b9c6b838 100644 --- a/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleServerMultiInterestUserProcessor.java +++ b/src/test/java/com/alipay/remoting/rpc/userprocessor/multiinterestprocessor/SimpleServerMultiInterestUserProcessor.java @@ -33,14 +33,14 @@ import com.alipay.remoting.InvokeContext; import com.alipay.remoting.NamedThreadFactory; import com.alipay.remoting.rpc.common.RequestBody; -import com.alipay.remoting.rpc.protocol.SyncMutiInterestUserProcessor; +import com.alipay.remoting.rpc.protocol.SyncMultiInterestUserProcessor; /** * @antuor muyun.cyt (muyun.cyt@antfin.com) 2018/7/5 11:20 AM */ public class SimpleServerMultiInterestUserProcessor extends - SyncMutiInterestUserProcessor { + SyncMultiInterestUserProcessor { /** logger */ private static final Logger logger = LoggerFactory