You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2023/10/11 21:15:53 UTC

Re: [PR] HDFS-17196. Overflow during getDatanodeReadTimeout [hadoop]

ayushtkn commented on code in PR #6091:
URL: https://github.com/apache/hadoop/pull/6091#discussion_r1355790939


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

Review Comment:
   should be something like?
   ```
     int getDatanodeReadTimeout(int numNodes) {
       final int t = dfsClientConf.getSocketTimeout();
       if (t > 0) {
         int readTimeout = HdfsConstants.READ_TIMEOUT_EXTENSION * numNodes + t;
         Preconditions.checkArgument(readTimeout >= 0, "Read timeout should be non-negative.");
         return readTimeout;
       }
       return 0;
     }
   ```



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org