You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/10 18:06:39 UTC

[GitHub] [ozone] szetszwo commented on a diff in pull request #3646: HDDS-6722. Ensure RocksObjects are closed.

szetszwo commented on code in PR #3646:
URL: https://github.com/apache/ozone/pull/3646#discussion_r942747901


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/managed/ManagedColumnFamilyOptions.java:
##########
@@ -36,6 +36,10 @@ public ManagedColumnFamilyOptions(ColumnFamilyOptions columnFamilyOptions) {
   @Override
   public ManagedColumnFamilyOptions setTableFormatConfig(
       TableFormatConfig tableFormatConfig) {
+    // Close the previous TableFormatConfig before overwriting.
+    if (tableFormatConfig() instanceof ManagedBlockBasedTableConfig) {
+      ((ManagedBlockBasedTableConfig) tableFormatConfig()).close();
+    }

Review Comment:
   It is better to throw an exception for overwriting.  We may throw an UnsupportedOperationException.
   ```
       final TableFormatConfig previous = tableFormatConfig();
       if (previous != null) {
         throw new UnsupportedOperationException("Overwrite is not supported");
       }
   ```
   Or we may enforce close before overwrite.
   ```
       if (previous instanceof ManagedBlockBasedTableConfig) {
         if (!previous.isClose()) { // isClose() is a new method
           throw new IllegalArgumentException("Overwriting an unclosed value");
         }
       } else if (previous != null) {
         throw new UnsupportedOperationException("Overwrite is not supported for " + previous.getClass());
       }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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