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:07:42 UTC

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

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



##########
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:
       This change maybe incorrect because the `cronTasks` may include multiple job names, not for singletonList only




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