adoroszlai commented on code in PR #3827:
URL: https://github.com/apache/ozone/pull/3827#discussion_r1001059048


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedRocksObjectUtils.java:
##########
@@ -33,20 +33,22 @@ private ManagedRocksObjectUtils() {
       LoggerFactory.getLogger(ManagedRocksObjectUtils.class);
 
   static void assertClosed(RocksObject rocksObject) {
-    ManagedRocksObjectMetrics.INSTANCE.increaseManagedObject();
-    if (rocksObject.isOwningHandle()) {
-      ManagedRocksObjectMetrics.INSTANCE.increaseLeakObject();
-      LOG.warn("{} is not closed properly",
-          rocksObject.getClass().getSimpleName());
-    }
+    assertClosed(rocksObject, null);
+  }
+
+  public static void assertClosed(ManagedObject<?> object) {
+    assertClosed(object.get(), object.getStackTrace());
   }
 
-  static void assertClosed(RocksObject rocksObject, Throwable stack) {
+  static void assertClosed(RocksObject rocksObject, String stackTrace) {
     ManagedRocksObjectMetrics.INSTANCE.increaseManagedObject();
     if (rocksObject.isOwningHandle()) {
       ManagedRocksObjectMetrics.INSTANCE.increaseLeakObject();
       LOG.warn("{} is not closed properly",
-          rocksObject.getClass().getSimpleName(), stack);
+          rocksObject.getClass().getSimpleName());
+      if (stackTrace != null && LOG.isDebugEnabled()) {
+        LOG.debug("StackTrace for unclosed instance: {}", stackTrace);
+      }

Review Comment:
   Nit: better execute as a single log statement for each case to ensure that 
the stack trace and object class are associated.
   
   In other words: drop `LOG.debug`, but change content of warning depending on 
`stackTrace != null && LOG.isDebugEnabled()`.



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