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

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


The following commit(s) were added to refs/heads/master by this push:
     new 59f1922d8 fix issue3065
     new fb20b5e66 Merge pull request #3067 from jonyangx/issue3065
59f1922d8 is described below

commit 59f1922d8d0d204d14afacb6fec20631523d4513
Author: jonyangx <[email protected]>
AuthorDate: Wed Feb 8 09:15:29 2023 +0800

    fix issue3065
---
 .../webhook/receive/WebHookMQProducer.java         | 36 ++++++++++------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git 
a/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookMQProducer.java
 
b/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookMQProducer.java
index 45f3f2844..c91b40b8d 100644
--- 
a/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookMQProducer.java
+++ 
b/eventmesh-webhook/eventmesh-webhook-receive/src/main/java/org/apache/eventmesh/webhook/receive/WebHookMQProducer.java
@@ -22,42 +22,38 @@ import org.apache.eventmesh.api.SendCallback;
 import org.apache.eventmesh.api.factory.ConnectorPluginFactory;
 import org.apache.eventmesh.api.producer.Producer;
 
+import java.util.Objects;
 import java.util.Properties;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import io.cloudevents.CloudEvent;
 
 public class WebHookMQProducer {
 
-    public Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    protected Producer hookMQProducer;
+    private transient Producer hookMQProducer;
 
-    public WebHookMQProducer(Properties properties, String 
connectorPluginType) {
+    public WebHookMQProducer(final Properties properties, String 
connectorPluginType) throws Exception {
         this.hookMQProducer = 
ConnectorPluginFactory.getMeshMQProducer(connectorPluginType);
-        if (hookMQProducer == null) {
-            logger.error("can't load the hookMQProducer plugin, please 
check.");
-            throw new RuntimeException("doesn't load the hookMQProducer 
plugin, please check.");
-        }
-        try {
-            this.hookMQProducer.init(properties);
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
+        Objects.requireNonNull(hookMQProducer, "doesn't load the 
hookMQProducer plugin, please check.");
+
+        this.hookMQProducer.init(properties);
     }
 
-    public void send(CloudEvent cloudEvent, SendCallback sendCallback) throws 
Exception {
+    public void send(final CloudEvent cloudEvent, final SendCallback 
sendCallback) throws Exception {
+        Objects.requireNonNull(cloudEvent, "cloudEvent can not be null");
+
         hookMQProducer.publish(cloudEvent, sendCallback);
     }
 
-    public void request(CloudEvent cloudEvent, RequestReplyCallback 
rrCallback, long timeout)
-        throws Exception {
+    public void request(final CloudEvent cloudEvent, final 
RequestReplyCallback rrCallback, final long timeout)
+            throws Exception {
+        Objects.requireNonNull(cloudEvent, "cloudEvent can not be null");
+
         hookMQProducer.request(cloudEvent, rrCallback, timeout);
     }
 
     public boolean reply(final CloudEvent cloudEvent, final SendCallback 
sendCallback) throws Exception {
+        Objects.requireNonNull(cloudEvent, "cloudEvent can not be null");
+
         return hookMQProducer.reply(cloudEvent, sendCallback);
     }
 
@@ -65,4 +61,4 @@ public class WebHookMQProducer {
         return hookMQProducer;
     }
 
-}
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to