From 853cabcfbe4fd4241e12b16bd38232856595e1d9 Mon Sep 17 00:00:00 2001 From: confx Date: Sat, 16 Sep 2023 11:37:33 -0400 Subject: [PATCH] checking the read timeout calculation for getDatanodeReadTimeout --- .../src/main/java/org/apache/hadoop/hdfs/DFSClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 116ed41703858..c1db0f3825c31 100755 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -477,7 +477,10 @@ int getDatanodeWriteTimeout(int numNodes) { int getDatanodeReadTimeout(int numNodes) { final int t = dfsClientConf.getSocketTimeout(); - return t > 0? HdfsConstants.READ_TIMEOUT_EXTENSION*numNodes + t: 0; + int readTimeout = HdfsConstants.READ_TIMEOUT_EXTENSION*numNodes + t; + Preconditions.checkArgument(readTimeout >= 0, + "Read timeout should be non-negative."); + return t > 0? readTimeout: 0; } @VisibleForTesting