From eaa3e913f8ed71516d92316748f07bc33b9a50a7 Mon Sep 17 00:00:00 2001 From: lxy <237809796@qq.com> Date: Sun, 11 Apr 2021 22:09:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9Arpc=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E7=AB=AF=E5=B8=A6=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=8F=8D=E5=BA=8F=E5=8C=96bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/zdemo/zhub/ZHubClient.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/zdemo/zhub/ZHubClient.java b/src/com/zdemo/zhub/ZHubClient.java index 5170e9f..875e209 100644 --- a/src/com/zdemo/zhub/ZHubClient.java +++ b/src/com/zdemo/zhub/ZHubClient.java @@ -289,6 +289,8 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer private String toStr(Object v) { if (v instanceof String) { return (String) v; + } else if (v == null) { + return null; } return convert.convertTo(v); } @@ -481,7 +483,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer try { publish(topic, rpc); synchronized (rpc) { - rpc.wait(); + rpc.wait(); //todo: 调用超时处理 rpcMap.remove(ruk); } } catch (InterruptedException e) { @@ -531,7 +533,8 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer // 参数转换 T paras = convert.convertFrom(typeToken.getType(), (String) rpc.getValue()); rpc.setValue(paras); - RpcResult result = fun.apply(rpc); + RpcResult result = fun.apply(rpc); + result.setResult(toStr(result.getResult())); publish(rpc.getBackTopic(), result); } catch (Exception e) { logger.log(Level.WARNING, "rpc call consumer error: " + v, e);