You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2021/07/01 12:17:33 UTC

[incubator-eventmesh] branch 1.3.0 updated: [Issues #405]code polish and fix typo (#404)

This is an automated email from the ASF dual-hosted git repository.

mikexue pushed a commit to branch 1.3.0
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git


The following commit(s) were added to refs/heads/1.3.0 by this push:
     new 7fe243e  [Issues #405]code polish and fix typo (#404)
7fe243e is described below

commit 7fe243e6637a407e797f2dba128728a45a87eb55
Author: YuDong Tang <58...@qq.com>
AuthorDate: Thu Jul 1 20:17:25 2021 +0800

    [Issues #405]code polish and fix typo (#404)
    
    * code polish and fix typo
    
    * merge remote 1.3.0
---
 .github/workflows/greetings.yml                               |  2 +-
 .../apache/eventmesh/client/http/consumer/LiteConsumer.java   |  7 +++----
 .../apache/eventmesh/client/tcp/common/EventMeshCommon.java   |  2 +-
 .../org/apache/eventmesh/client/tcp/common/TcpClient.java     |  6 ++----
 .../apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java | 11 ++++-------
 .../apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java |  8 +++-----
 6 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml
index 8883906..ccb8df0 100644
--- a/.github/workflows/greetings.yml
+++ b/.github/workflows/greetings.yml
@@ -19,7 +19,7 @@
 
 name: Greetings
 
-on: [pull_request, issues]
+on: [pull_request_target, issues]
 
 jobs:
   greeting:
diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java
index 7841a67..61d3c48 100644
--- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java
+++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/http/consumer/LiteConsumer.java
@@ -96,7 +96,7 @@ public class LiteConsumer extends AbstractLiteClient {
 //        this.remotingServer = new RemotingServer(this.consumeExecutor);
     }
 
-    private AtomicBoolean started = new AtomicBoolean(Boolean.FALSE);
+    private final AtomicBoolean started = new AtomicBoolean(Boolean.FALSE);
 
     @Override
     public void start() throws Exception {
@@ -226,15 +226,14 @@ public class LiteConsumer extends AbstractLiteClient {
 
                     EventMeshRetObj ret = JSON.parseObject(res, EventMeshRetObj.class);
 
-                    if (ret.getRetCode() == EventMeshRetCode.SUCCESS.getRetCode()) {
-                    } else {
+                    if (ret.getRetCode() != EventMeshRetCode.SUCCESS.getRetCode()) {
                         throw new EventMeshException(ret.getRetCode(), ret.getRetMsg());
                     }
                 } catch (Exception e) {
                     logger.error("send heartBeat error", e);
                 }
             }
-        }, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
+        }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
     }
 
     public boolean unsubscribe(List<String> topicList, String url) throws Exception {
diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java
index 65aa40e..04c275d 100644
--- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java
+++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/EventMeshCommon.java
@@ -31,7 +31,7 @@ public class EventMeshCommon {
     /**
      * CLIENT端心跳间隔时间
      */
-    public static int HEATBEAT = 30 * 1000;
+    public static int HEARTBEAT = 30 * 1000;
 
     /**
      * RR 废弃清理的时间间隔
diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java
index 7df1e29..5513e13 100644
--- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java
+++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/common/TcpClient.java
@@ -50,7 +50,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class TcpClient implements Closeable {
-    private Logger logger = LoggerFactory.getLogger(this.getClass());
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     public int clientNo = (new Random()).nextInt(1000);
 
@@ -67,8 +67,6 @@ public abstract class TcpClient implements Closeable {
 
     protected static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(4, new EventMeshThreadFactoryImpl("TCPClientScheduler", true));
 
-    private ScheduledFuture<?> task;
-
     public TcpClient(String host, int port) {
         this.host = host;
         this.port = port;
@@ -119,7 +117,7 @@ public abstract class TcpClient implements Closeable {
         if (channel.isWritable()) {
             channel.writeAndFlush(msg).addListener((ChannelFutureListener) future -> {
                 if (!future.isSuccess()) {
-                    logger.warn("send msg failed", future.isSuccess(), future.cause());
+                    logger.warn("send msg failed", future.cause());
                 }
             });
         } else {
diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java
index da5691a..df05f4b 100644
--- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java
+++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimplePubClientImpl.java
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
 
 public class SimplePubClientImpl extends TcpClient implements SimplePubClient {
 
-    private Logger logger = LoggerFactory.getLogger(this.getClass());
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     private UserAgent userAgent;
 
@@ -90,10 +90,10 @@ public class SimplePubClientImpl extends TcpClient implements SimplePubClient {
                     }
                     Package msg = MessageUtils.heartBeat();
                     io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
-                } catch (Exception e) {
+                } catch (Exception ignore) {
                 }
             }
-        }, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
+        }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
     }
 
     private void goodbye() throws Exception {
@@ -176,16 +176,13 @@ public class SimplePubClientImpl extends TcpClient implements SimplePubClient {
                 Package pkg = MessageUtils.responseToClientAck(msg);
                 send(pkg);
             } else if (cmd == Command.SERVER_GOODBYE_REQUEST) {
-
+                //TODO
             }
 
             RequestContext context = contexts.get(RequestContext._key(msg));
             if (context != null) {
                 contexts.remove(context.getKey());
                 context.finish(msg);
-                return;
-            } else {
-                return;
             }
         }
     }
diff --git a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java
index 38d52f6..7e341ca 100644
--- a/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java
+++ b/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/tcp/impl/SimpleSubClientImpl.java
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
 
 public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient {
 
-    private Logger logger = LoggerFactory.getLogger(this.getClass());
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     private UserAgent userAgent;
 
@@ -101,10 +101,10 @@ public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient {
                     }
                     Package msg = MessageUtils.heartBeat();
                     SimpleSubClientImpl.this.io(msg, EventMeshCommon.DEFAULT_TIME_OUT_MILLS);
-                } catch (Exception e) {
+                } catch (Exception ignore) {
                 }
             }
-        }, EventMeshCommon.HEATBEAT, EventMeshCommon.HEATBEAT, TimeUnit.MILLISECONDS);
+        }, EventMeshCommon.HEARTBEAT, EventMeshCommon.HEARTBEAT, TimeUnit.MILLISECONDS);
     }
 
     private void goodbye() throws Exception {
@@ -172,10 +172,8 @@ public class SimpleSubClientImpl extends TcpClient implements SimpleSubClient {
             if (context != null) {
                 contexts.remove(context.getKey());
                 context.finish(msg);
-                return;
             } else {
                 logger.error("msg ignored,context not found.|{}|{}", cmd, msg);
-                return;
             }
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org