junrao commented on code in PR #23832:
URL: https://github.com/apache/kafka/pull/23832#discussion_r4297606061


##########
clients/src/main/java/org/apache/kafka/common/network/SslTransportLayer.java:
##########
@@ -1038,10 +1038,16 @@ public long transferFrom(FileChannel fileChannel, long 
position, long count) thr
                     int bytesRemaining = totalBytesToWrite - totalBytesWritten;
                     if (bytesRemaining < fileChannelBuffer.limit())
                         fileChannelBuffer.limit(bytesRemaining);
-                    int bytesRead = fileChannel.read(fileChannelBuffer, pos);
+                    int bytesRead;
+                    try {
+                        bytesRead = fileChannel.read(fileChannelBuffer, pos);
+                    } finally {

Review Comment:
   The following code seems to be copied from the JDK implementation. In 
Kafka's usage, we typically close a connection on IOException, it seems that we 
can just rethrow on IOException without returning totalBytesWritten.
   
   ```
           } catch (IOException e) {
               if (totalBytesWritten > 0)
                   return totalBytesWritten;
               throw e;
           }
   ```



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

Reply via email to