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 2023/04/17 08:42:20 UTC

[eventmesh] branch master updated: [ISSUE #2979] replaced 'get + null check + creating empty list'

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 7a5746e34 [ISSUE #2979] replaced 'get + null check + creating empty list'
7a5746e34 is described below

commit 7a5746e34c403ff60e2f0c2a5c207c798de1c45b
Author: dipanker <42...@users.noreply.github.com>
AuthorDate: Mon Apr 17 14:12:13 2023 +0530

    [ISSUE #2979] replaced 'get + null check + creating empty list'
---
 .../http/processor/LocalUnSubscribeEventProcessor.java     | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/LocalUnSubscribeEventProcessor.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/LocalUnSubscribeEventProcessor.java
index b71c23e5a..881b34185 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/LocalUnSubscribeEventProcessor.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/LocalUnSubscribeEventProcessor.java
@@ -155,12 +155,7 @@ public class LocalUnSubscribeEventProcessor extends AbstractEventProcessor {
                         if (!StringUtils.equals(unSubscribeUrl, client.getUrl())) {
                             clientUrls.add(client.getUrl());
 
-                            List<String> urls = idcUrls.get(client.getIdc());
-                            if (urls == null) {
-                                urls = new ArrayList<>();
-                                idcUrls.put(client.getIdc(), urls);
-
-                            }
+                            List<String> urls = idcUrls.computeIfAbsent(client.getIdc(), list -> new ArrayList<>());
                             urls.add(StringUtils.deleteWhitespace(client.getUrl()));
                         }
 
@@ -271,12 +266,7 @@ public class LocalUnSubscribeEventProcessor extends AbstractEventProcessor {
             final String groupTopicKey = client.getConsumerGroup() + "@" + client.getTopic();
 
             List<Client> localClients =
-                eventMeshHTTPServer.getSubscriptionManager().getLocalClientInfoMapping().get(groupTopicKey);
-
-            if (localClients == null) {
-                localClients = new ArrayList<>();
-                eventMeshHTTPServer.getSubscriptionManager().getLocalClientInfoMapping().put(groupTopicKey, localClients);
-            }
+                eventMeshHTTPServer.getSubscriptionManager().getLocalClientInfoMapping().computeIfAbsent(groupTopicKey, list -> new ArrayList<>());
 
             boolean isContains = false;
             for (final Client localClient : localClients) {


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