fmorg-git commented on PR #10521:
URL: https://github.com/apache/ozone/pull/10521#issuecomment-4721755713

   > Thanks @fmorg-git for working on this.
   > 
   > `S3GatewayMetrics` is created only once, during S3G startup:
   > 
   > 
https://github.com/apache/ozone/blob/15216f2c7d578ceb69a55e8071e0f3925d0c38e0/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/Gateway.java#L86
   > 
   > I don't think we need synchronization or `volatile` at all.
   
   in the case of concurrent access, `volatile` read helps threads see the new 
value as soon as possible (i.e. memory visibility).  Also, synchronizing the 
create is a defensive mechanism in case in the future there are multiple calls 
to create, so the instance is only created once.  Today, if there is only one 
call to create, synchronized won't cause any issue because there is nothing to 
contend with.


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