findingrish commented on code in PR #17025:
URL: https://github.com/apache/druid/pull/17025#discussion_r1753167609


##########
server/src/main/java/org/apache/druid/segment/metadata/AbstractSegmentMetadataCache.java:
##########
@@ -431,10 +431,7 @@ public Map<SegmentId, AvailableSegmentMetadata> 
getSegmentMetadataSnapshot()
   @Nullable
   public AvailableSegmentMetadata getAvailableSegmentMetadata(String 
datasource, SegmentId segmentId)
   {
-    if (!segmentMetadataInfo.containsKey(datasource)) {
-      return null;
-    }
-    return segmentMetadataInfo.get(datasource).get(segmentId);
+    return segmentMetadataInfo.getOrDefault(datasource, new 
ConcurrentSkipListMap<>()).get(segmentId);

Review Comment:
   Removed creating a new object. 
   In older there is a possibility of race since the datasource missing check 
is a separate statement. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to