smengcl commented on code in PR #10772:
URL: https://github.com/apache/ozone/pull/10772#discussion_r3584861910


##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/defrag/TestSnapshotDefragService.java:
##########
@@ -224,6 +235,83 @@ private String getFromCodecBuffer(CodecBuffer buffer) {
     return StringCodec.get().fromCodecBuffer(buffer);
   }
 
+  private void putString(Table<String, CodecBuffer> table, String key,
+      String value) throws RocksDatabaseException, CodecException {
+    table.put(key, StringCodec.get().toDirectCodecBuffer(value));
+  }

Review Comment:
   No change needed. `StringCodecBase.supportCodecBuffer()` and 
`CodecBufferCodec.supportCodecBuffer()` both return `true`, so this 
`TypedTable` uses the codec-buffer path. `TypedTable.put` closes its key and 
value buffers with try-with-resources, and `CodecBufferCodec.toCodecBuffer` 
returns the same value object; the buffer passed by `putString` is therefore 
closed by `table.put`.



##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/defrag/TestSnapshotDefragService.java:
##########
@@ -224,6 +236,83 @@ private String getFromCodecBuffer(CodecBuffer buffer) {
     return StringCodec.get().fromCodecBuffer(buffer);
   }
 
+  private void putString(Table<String, CodecBuffer> table, String key,
+      String value) throws RocksDatabaseException, CodecException {
+    table.put(key, StringCodec.get().toDirectCodecBuffer(value));
+  }

Review Comment:
   The premise is incorrect: `StringCodecBase.supportCodecBuffer()` returns 
`true` (as does `CodecBufferCodec.supportCodecBuffer()`), so 
`TypedTable.supportCodecBuffer` is true for this table. `TypedTable.put` takes 
the try-with-resources path and closes the same buffer returned by 
`CodecBufferCodec.toCodecBuffer`. No leak occurs here.



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