You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "Alonexc (via GitHub)" <gi...@apache.org> on 2023/04/14 08:22:17 UTC
[GitHub] [eventmesh] Alonexc commented on a diff in pull request #3736: [ISSUE #3728] Replace this "Map.get()" and condition with a call to "Map.computeIfAbsent()". [ConsumerManager]
Alonexc commented on code in PR #3736:
URL: https://github.com/apache/eventmesh/pull/3736#discussion_r1166476344
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/consumer/ConsumerManager.java:
##########
@@ -89,10 +89,8 @@ public void shutdown() throws Exception {
}
public EventMeshConsumer getEventMeshConsumer(final String consumerGroup) {
- EventMeshConsumer consumer = consumerTable.get(consumerGroup);
- if (consumer == null) {
- consumer = new EventMeshConsumer(eventMeshGrpcServer, consumerGroup);
- consumerTable.put(consumerGroup, consumer);
+ return consumerTable.computeIfAbsent(consumerGroup, key ->
+ consumerTable.put(consumerGroup, new EventMeshConsumer(eventMeshGrpcServer, consumerGroup)));
}
return consumer;
Review Comment:
Need to delete 93, 94 lines of code.
--
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