nastra commented on code in PR #8221:
URL: https://github.com/apache/iceberg/pull/8221#discussion_r1284256086


##########
aws/src/main/java/org/apache/iceberg/aws/s3/S3InputStream.java:
##########
@@ -213,20 +271,63 @@ private void closeStream() throws IOException {
     }
   }
 
-  private void abortStream() {
+  private void abortStream(InputStream streamToAbort) {
     try {
-      if (stream instanceof Abortable && stream.read() != -1) {
-        ((Abortable) stream).abort();
+      if (streamToAbort instanceof Abortable && streamToAbort.read() != -1) {
+        ((Abortable) streamToAbort).abort();
       }
     } catch (Exception e) {
       LOG.warn("An error occurred while aborting the stream", e);
     }
   }
 
+  private void retryAndThrow(Tasks.Task task) throws IOException {
+    try {
+      Tasks.foreach(0)
+          .retry(s3FileIOProperties.s3ReadRetryNumRetries())
+          .exponentialBackoff(
+              s3FileIOProperties.s3ReadRetryMinWaitMs(),
+              s3FileIOProperties.s3ReadRetryMaxWaitMs(),
+              s3FileIOProperties.s3ReadRetryTotalTimeoutMs(),
+              2.0 /* exponential */)
+          .shouldRetryTest(S3InputStream::shouldRetry)
+          .throwFailureWhenFinished()
+          .run(task);
+    } catch (UncheckedIOException e) {
+      throw e.getCause();
+    }
+  }
+
   public void setSkipSize(int skipSize) {
     this.skipSize = skipSize;
   }
 
+  public static boolean shouldRetry(Exception exception) {

Review Comment:
   should this be aligned with 
https://github.com/aws/aws-sdk-java-v2/blob/2.20.18/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/retry/SdkDefaultRetrySetting.java#L72-L84?



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


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

Reply via email to