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