cryptoe commented on code in PR #14126:
URL: https://github.com/apache/druid/pull/14126#discussion_r1176028097


##########
processing/src/main/java/org/apache/druid/data/input/impl/RetryingInputStream.java:
##########
@@ -69,23 +69,62 @@ public RetryingInputStream(
       Predicate<Throwable> retryCondition,
       @Nullable Integer maxTries
   ) throws IOException
+  {
+    this(object, objectOpenFunction, retryCondition, maxTries, true);
+  }
+
+  @VisibleForTesting
+  RetryingInputStream(
+      T object,
+      ObjectOpenFunction<T> objectOpenFunction,
+      Predicate<Throwable> retryCondition,
+      @Nullable Integer maxTries,
+      boolean doWait
+  ) throws IOException
   {
     this.object = Preconditions.checkNotNull(object, "object");
     this.objectOpenFunction = Preconditions.checkNotNull(objectOpenFunction, 
"objectOpenFunction");
     this.retryCondition = Preconditions.checkNotNull(retryCondition, 
"retryCondition");
     this.maxTries = maxTries == null ? RetryUtils.DEFAULT_MAX_TRIES : maxTries;
-    this.delegate = new CountingInputStream(objectOpenFunction.open(object));
-    this.doWait = true;
+    this.doWait = doWait;
+    this.startOffset = 0;
 
     if (this.maxTries <= 1) {
       throw new IAE("maxTries must be greater than 1");
     }
+    openWithRetry();
   }
 
   private void openIfNeeded() throws IOException
   {
     if (delegate == null) {
-      delegate = new CountingInputStream(objectOpenFunction.open(object, 
startOffset));
+      openWithRetry();
+    }
+  }
+
+  private void openWithRetry() throws IOException

Review Comment:
   nit: lets pass startOffset to openWithRetry as a function parameter since 
this method never mutates the offset. 
   Then you will not need line 90: this.startOffset = 0 and the code becomes 
cleaner.



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