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/eventmesh.git


The following commit(s) were added to refs/heads/master by this push:
     new 307a2d206 [ISSUE #3832]Do some code optimization.[storage 
ProducerImpl] (#3857)
307a2d206 is described below

commit 307a2d20620b041bdc767073fa6448c547940d6d
Author: Harshitha Sudhakar 
<[email protected]>
AuthorDate: Tue May 9 08:27:15 2023 +0530

    [ISSUE #3832]Do some code optimization.[storage ProducerImpl] (#3857)
    
    * Update ProducerImpl.java
    
    Added `final` to line 47.
    Added use `Objects.requireNonNull()` to avoid NPE at line 110
    
    * Update ProducerImpl.java
---
 .../org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java
 
b/eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java
index 57d2553cc..0a41a42f2 100644
--- 
a/eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java
+++ 
b/eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java
@@ -44,7 +44,7 @@ import lombok.extern.slf4j.Slf4j;
 @SuppressWarnings("deprecation")
 public class ProducerImpl {
 
-    private KafkaProducer<String, CloudEvent> producer;
+    private final KafkaProducer<String, CloudEvent> producer;
     private final Properties properties = new Properties();
     private final AtomicBoolean isStarted = new AtomicBoolean(false);
 
@@ -107,7 +107,7 @@ public class ProducerImpl {
 
     public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) {
         try {
-            this.producer.send(new ProducerRecord<>(cloudEvent.getSubject(), 
cloudEvent), (metadata, exception) -> {
+            this.producer.send(new 
ProducerRecord<>(Objects.requireNonNull(cloudEvent.getSubject()), cloudEvent), 
(metadata, exception) -> {
                 if (exception != null) {
                     StorageRuntimeException onsEx = new 
StorageRuntimeException(exception.getMessage(), exception);
                     OnExceptionContext context = new OnExceptionContext();


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

Reply via email to