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

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


The following commit(s) were added to refs/heads/master by this push:
     new cb6b1d542f [IOTDB-2978][compaction error log ] Log level and "null" 
error message handling (#6140)
cb6b1d542f is described below

commit cb6b1d542ffff0e5daf76e1a53bacc4d14e3d923
Author: 周沛辰 <[email protected]>
AuthorDate: Thu Jun 2 15:24:46 2022 +0800

    [IOTDB-2978][compaction error log ] Log level and "null" error message 
handling (#6140)
---
 .../iotdb/tsfile/read/reader/LocalTsFileInput.java | 43 +++++++++++++++-------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/LocalTsFileInput.java
 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/LocalTsFileInput.java
index 3771e86c71..cba0c326dd 100644
--- 
a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/LocalTsFileInput.java
+++ 
b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/LocalTsFileInput.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
+import java.nio.channels.ClosedByInterruptException;
 import java.nio.channels.FileChannel;
 import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
@@ -78,6 +79,10 @@ public class LocalTsFileInput implements TsFileInput {
   public int read(ByteBuffer dst) throws IOException {
     try {
       return channel.read(dst);
+    } catch (ClosedByInterruptException e) {
+      logger.warn(
+          "Current thread is interrupted by another thread when it is blocked 
in an I/O operation upon a channel.");
+      return -1;
     } catch (IOException e) {
       logger.error("Error happened while reading {} from current position", 
filePath);
       throw e;
@@ -88,6 +93,10 @@ public class LocalTsFileInput implements TsFileInput {
   public int read(ByteBuffer dst, long position) throws IOException {
     try {
       return channel.read(dst, position);
+    } catch (ClosedByInterruptException e) {
+      logger.warn(
+          "Current thread is interrupted by another thread when it is blocked 
in an I/O operation upon a channel.");
+      return -1;
     } catch (IOException e) {
       logger.error("Error happened while reading {} from position {}", 
filePath, position);
       throw e;
@@ -131,22 +140,28 @@ public class LocalTsFileInput implements TsFileInput {
 
   @Override
   public String readVarIntString(long offset) throws IOException {
-    ByteBuffer byteBuffer = ByteBuffer.allocate(5);
-    channel.read(byteBuffer, offset);
-    byteBuffer.flip();
-    int strLength = ReadWriteForEncodingUtils.readVarInt(byteBuffer);
-    if (strLength < 0) {
+    try {
+      ByteBuffer byteBuffer = ByteBuffer.allocate(5);
+      channel.read(byteBuffer, offset);
+      byteBuffer.flip();
+      int strLength = ReadWriteForEncodingUtils.readVarInt(byteBuffer);
+      if (strLength < 0) {
+        return null;
+      } else if (strLength == 0) {
+        return "";
+      }
+      ByteBuffer strBuffer = ByteBuffer.allocate(strLength);
+      int varIntLength = ReadWriteForEncodingUtils.varIntSize(strLength);
+      byte[] bytes = new byte[strLength];
+      channel.read(strBuffer, offset + varIntLength);
+      strBuffer.flip();
+      strBuffer.get(bytes, 0, strLength);
+      return new String(bytes, 0, strLength);
+    } catch (ClosedByInterruptException e) {
+      logger.warn(
+          "Current thread is interrupted by another thread when it is blocked 
in an I/O operation upon a channel.");
       return null;
-    } else if (strLength == 0) {
-      return "";
     }
-    ByteBuffer strBuffer = ByteBuffer.allocate(strLength);
-    int varIntLength = ReadWriteForEncodingUtils.varIntSize(strLength);
-    byte[] bytes = new byte[strLength];
-    channel.read(strBuffer, offset + varIntLength);
-    strBuffer.flip();
-    strBuffer.get(bytes, 0, strLength);
-    return new String(bytes, 0, strLength);
   }
 
   @Override

Reply via email to