You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "mxsm (via GitHub)" <gi...@apache.org> on 2023/03/27 16:19:22 UTC

[GitHub] [eventmesh] mxsm opened a new pull request, #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

mxsm opened a new pull request, #3531:
URL: https://github.com/apache/eventmesh/pull/3531

   <!--
   ### Contribution Checklist
   
     - Name the pull request in the form "[ISSUE #XXXX] Title of the pull request", 
       where *XXXX* should be replaced by the actual issue number.
       Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
   
     - Fill out the template below to describe the changes contributed by the pull request. 
       That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue. 
       Please do not mix up code from multiple issues.
     
     - Each commit in the pull request should have a meaningful commit message.
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, 
       leaving only the filled out template below.
   
   (The sections below can be removed for hotfixes of typos)
   -->
   
   <!--
   (If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Closes #<XXX>`.)
   -->
   
   Fixes #3530 
   
   ### Motivation
   
   *Explain the content here.*
   *Explain why you want to make the changes and what problem you're trying to solve.*
   
   
   
   ### Modifications
   
   *Optimize ProducerImpl in evetmesh-storage-kafka module.*
   
   
   
   ### Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   - If a feature is not applicable for documentation, explain why?
   - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] Alonexc commented on a diff in pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531#discussion_r1149939581


##########
eventmesh-storage/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java:
##########
@@ -90,12 +86,19 @@ public void send(CloudEvent cloudEvent) {
     }
 
     public void checkTopicExist(String topic) throws ExecutionException, InterruptedException, StorageConnectorRuntimeException {
-        Admin admin = Admin.create(properties);
-        Set<String> topicNames = admin.listTopics().names().get();
-        admin.close();
-        boolean exist = topicNames.contains(topic);
-        if (!exist) {
-            throw new StorageConnectorRuntimeException(String.format("topic:%s is not exist", topic));
+        Admin admin = null;
+        try {

Review Comment:
   It is recommended to use try-with-resources.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] mytang0 merged pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "mytang0 (via GitHub)" <gi...@apache.org>.
mytang0 merged PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] Alonexc commented on a diff in pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531#discussion_r1149940226


##########
eventmesh-storage/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java:
##########
@@ -90,12 +86,19 @@ public void send(CloudEvent cloudEvent) {
     }
 
     public void checkTopicExist(String topic) throws ExecutionException, InterruptedException, StorageConnectorRuntimeException {
-        Admin admin = Admin.create(properties);
-        Set<String> topicNames = admin.listTopics().names().get();
-        admin.close();
-        boolean exist = topicNames.contains(topic);
-        if (!exist) {
-            throw new StorageConnectorRuntimeException(String.format("topic:%s is not exist", topic));
+        Admin admin = null;
+        try {
+            admin = Admin.create(properties);
+            Set<String> topicNames = admin.listTopics().names().get();
+            admin.close();

Review Comment:
   This line of suggested code should be removed.[93]



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] mxsm commented on pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "mxsm (via GitHub)" <gi...@apache.org>.
mxsm commented on PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531#issuecomment-1486116286

   @Alonexc  Done, PTAL~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] Alonexc commented on a diff in pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531#discussion_r1149940226


##########
eventmesh-storage/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java:
##########
@@ -90,12 +86,19 @@ public void send(CloudEvent cloudEvent) {
     }
 
     public void checkTopicExist(String topic) throws ExecutionException, InterruptedException, StorageConnectorRuntimeException {
-        Admin admin = Admin.create(properties);
-        Set<String> topicNames = admin.listTopics().names().get();
-        admin.close();
-        boolean exist = topicNames.contains(topic);
-        if (!exist) {
-            throw new StorageConnectorRuntimeException(String.format("topic:%s is not exist", topic));
+        Admin admin = null;
+        try {
+            admin = Admin.create(properties);
+            Set<String> topicNames = admin.listTopics().names().get();
+            admin.close();

Review Comment:
   This line of suggested code should be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [eventmesh] Alonexc commented on a diff in pull request #3531: [ISSUE #3530]Optimize ProducerImpl in evetmesh-storage-kafka module

Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #3531:
URL: https://github.com/apache/eventmesh/pull/3531#discussion_r1149939581


##########
eventmesh-storage/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/producer/ProducerImpl.java:
##########
@@ -90,12 +86,19 @@ public void send(CloudEvent cloudEvent) {
     }
 
     public void checkTopicExist(String topic) throws ExecutionException, InterruptedException, StorageConnectorRuntimeException {
-        Admin admin = Admin.create(properties);
-        Set<String> topicNames = admin.listTopics().names().get();
-        admin.close();
-        boolean exist = topicNames.contains(topic);
-        if (!exist) {
-            throw new StorageConnectorRuntimeException(String.format("topic:%s is not exist", topic));
+        Admin admin = null;
+        try {

Review Comment:
   It is recommended to use try-with-recourse.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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