This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 33544def1cc HDDS-14174. RandomAccessFileChannel.close() should not 
throw RuntimeException (#9501)
33544def1cc is described below

commit 33544def1cc1fdf02d934d0e3139f6f955271482
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Mon Dec 15 05:43:54 2025 -0800

    HDDS-14174. RandomAccessFileChannel.close() should not throw 
RuntimeException (#9501)
---
 .../hadoop/hdds/utils/io/RandomAccessFileChannel.java   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/io/RandomAccessFileChannel.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/io/RandomAccessFileChannel.java
index 98299b65947..5c7fcee6afb 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/io/RandomAccessFileChannel.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/io/RandomAccessFileChannel.java
@@ -39,10 +39,12 @@ public class RandomAccessFileChannel {
   public RandomAccessFileChannel() {
   }
 
+  /** Is this file open? */
   public synchronized boolean isOpen() {
     return blockFile != null;
   }
 
+  /** Open the given file in read-only mode. */
   public synchronized void open(File file) throws FileNotFoundException {
     Preconditions.assertNull(blockFile, "blockFile");
     blockFile = Objects.requireNonNull(file, "blockFile == null");
@@ -50,6 +52,7 @@ public synchronized void open(File file) throws 
FileNotFoundException {
     channel = raf.getChannel();
   }
 
+  /** Similar to {@link FileChannel#position(long)}. */
   public synchronized void position(long newPosition) throws IOException {
     Preconditions.assertTrue(isOpen(), "Not opened");
     final long oldPosition = channel.position();
@@ -59,6 +62,14 @@ public synchronized void position(long newPosition) throws 
IOException {
     }
   }
 
+  /**
+   * Similar to {@link FileChannel#read(ByteBuffer)} except that
+   * this method tries to fill up the buffer until either
+   * (1) the buffer is full, or (2) it has reached end-of-stream.
+   *
+   * @return ture if the caller should continue to read;
+   *         otherwise, it has reached end-of-stream, return false;
+   */
   public synchronized boolean read(ByteBuffer buffer) throws IOException {
     Preconditions.assertTrue(isOpen(), "Not opened");
     while (buffer.hasRemaining()) {
@@ -70,6 +81,11 @@ public synchronized boolean read(ByteBuffer buffer) throws 
IOException {
     return true;
   }
 
+  /**
+   * Close the underlying channel and file.
+   * In case of exception, this method catches the exception, logs a warning 
message,
+   * and then continue closing the remaining resources.
+   */
   public synchronized void close() {
     if (blockFile == null) {
       return;
@@ -80,7 +96,6 @@ public synchronized void close() {
       channel = null;
     } catch (IOException e) {
       LOG.warn("Failed to close channel for {}", blockFile, e);
-      throw new RuntimeException(e);
     }
     try {
       raf.close();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to