You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/10/16 19:49:02 UTC

[GitHub] zentol closed pull request #4374: repalce map.put with putIfAbsent

zentol closed pull request #4374: repalce map.put with putIfAbsent
URL: https://github.com/apache/flink/pull/4374
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala b/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
index f948df4c08e..5370d0857ae 100644
--- a/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
+++ b/flink-runtime/src/main/scala/org/apache/flink/runtime/taskmanager/TaskManager.scala
@@ -1207,10 +1207,9 @@ class TaskManager(
 
       val execId = tdd.getExecutionAttemptId
       // add the task to the map
-      val prevTask = runningTasks.put(execId, task)
+      val prevTask = runningTasks.putIfAbsent(execId, task)
       if (prevTask != null) {
-        // already have a task for that ID, put if back and report an error
-        runningTasks.put(execId, prevTask)
+        // already have a task for that ID,report an error
         throw new IllegalStateException("TaskManager already contains a task for id " + execId)
       }
       


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services