linyiqun commented on a change in pull request #938:
URL: https://github.com/apache/hadoop-ozone/pull/938#discussion_r427317205



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
##########
@@ -374,7 +374,12 @@ Pipeline updatePipelineState(PipelineID pipelineID, 
PipelineState state)
     PipelineQuery query = new PipelineQuery(pipeline);
     if (updatedPipeline.getPipelineState() == PipelineState.OPEN) {
       // for transition to OPEN state add pipeline to query2OpenPipelines
-      query2OpenPipelines.get(query).add(updatedPipeline);
+      List<Pipeline> pipelineList = query2OpenPipelines.get(query);
+      if (pipelineList == null) {
+        pipelineList = new CopyOnWriteArrayList<>();
+        query2OpenPipelines.put(query, pipelineList);
+      }
+      pipelineList.add(updatedPipeline);

Review comment:
       Besides above change, Can you also do the empty check for another 
condition branch?
       } else {
         // for transition from OPEN to CLOSED state remove pipeline from
         // query2OpenPipelines
         query2OpenPipelines.get(query).remove(pipeline);   <---
       }
   There is also a chance that remove operation can throw NPE.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to