amaliujia commented on code in PR #10521:
URL: https://github.com/apache/ozone/pull/10521#discussion_r3417739487


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/metrics/S3GatewayMetrics.java:
##########
@@ -303,14 +303,20 @@ public void close() {
    *
    * @return S3GatewayMetrics
    */
-  public static synchronized S3GatewayMetrics create(OzoneConfiguration conf) {
-    if (instance != null) {
-      return instance;
+  public static S3GatewayMetrics create(OzoneConfiguration conf) {
+    S3GatewayMetrics local = instance;
+    if (local == null) {
+      synchronized (S3GatewayMetrics.class) {
+        local = instance;
+        if (local == null) {
+          MetricsSystem ms = DefaultMetricsSystem.instance();
+          local = ms.register(SOURCE_NAME, "S3 Gateway Metrics",
+              new S3GatewayMetrics(conf));
+          instance = local;
+        }

Review Comment:
   ```suggestion
         synchronized (S3GatewayMetrics.class) {
           if (instance == null) {
             MetricsSystem ms = DefaultMetricsSystem.instance();
             instance = ms.register(SOURCE_NAME, "S3 Gateway Metrics",
                 new S3GatewayMetrics(conf));
           }
         }
         return instance
   ```
   
   This seems to be simpler?



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