You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/08/15 13:28:41 UTC

[GitHub] [shardingsphere-elasticjob] CalvinKirs commented on a change in pull request #1375: [optimization][cloud]code optimization

CalvinKirs commented on a change in pull request #1375:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1375#discussion_r470979453



##########
File path: elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/producer/TransientProducerRepository.java
##########
@@ -34,16 +33,7 @@
     
     synchronized void put(final JobKey jobKey, final String jobName) {
         remove(jobName);
-        List<String> taskList = cronTasks.get(jobKey);
-        if (null == taskList) {
-            taskList = new CopyOnWriteArrayList<>();
-            taskList.add(jobName);
-            cronTasks.put(jobKey, taskList);
-            return;
-        }
-        if (!taskList.contains(jobName)) {
-            taskList.add(jobName);
-        }
+        cronTasks.computeIfAbsent(jobKey, k -> Collections.singletonList(jobName));

Review comment:
       Thank you very much for your review, so the previous code should be missing, right? On line 45, it is not updated




----------------------------------------------------------------
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.

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