Copilot commented on code in PR #12171:
URL: https://github.com/apache/ozone/pull/12171#discussion_r4704403304


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotLocalDataYaml.java:
##########
@@ -81,9 +92,85 @@ public final class OmSnapshotLocalDataYaml {
   // For the ASCII snapshot local data YAML this is effectively the maximum 
file size in bytes.
   public static final int SNAPSHOT_LOCAL_DATA_YAML_CODE_POINT_LIMIT = 128 * 
1024 * 1024;
 
+  // zstd frame magic number 0xFD2FB528 in the little-endian byte order it is 
written in. YAML never starts with it.
+  private static final byte[] ZSTD_MAGIC = {0x28, (byte) 0xB5, 0x2F, (byte) 
0xFD};
+  // On snapshot local data YAML files, level 1 compresses smaller and faster 
than the default level 3.
+  private static final int ZSTD_LEVEL = 1;
+
   private OmSnapshotLocalDataYaml() {
   }
 
+  /**
+   * Opens a snapshot local data YAML file for reading, decompressing it if it 
is zstd compressed.
+   */
+  public static InputStream newInputStream(File yamlFile) throws IOException {
+    InputStream in = new 
BufferedInputStream(Files.newInputStream(yamlFile.toPath()));
+    try {
+      return isZstd(in) ? new ZstdInputStream(in) : in;
+    } catch (Throwable t) {
+      in.close();
+      throw t;

Review Comment:
   This does not compile: `t` is declared as `Throwable`, but this method only 
declares `IOException`, so `throw t` is an unreported checked exception. Catch 
only the checked/unchecked throwable types this code can propagate (and 
preserve any close exception as suppressed), or otherwise avoid rethrowing an 
unconstrained `Throwable`.
   
   This issue also appears on line 170 of the same file.



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