github-code-scanning[bot] commented on code in PR #14126:
URL: https://github.com/apache/druid/pull/14126#discussion_r1177441453


##########
processing/src/test/java/org/apache/druid/data/input/impl/RetryingInputStreamTest.java:
##########
@@ -206,16 +215,48 @@
         testFile,
         objectOpenFunction,
         t -> t instanceof IOException || t instanceof CustomException,
-        MAX_RETRY
+        MAX_RETRY,
+        false
     );
 
-    retryingInputStream.setNoWait();
     retryHelper(retryingInputStream);
 
     Assert.assertEquals(0, throwCustomExceptions);
     Assert.assertEquals(0, throwIOExceptions);
   }
 
+  @Test
+  public void testRetryOnExceptionWhenOpeningStream() throws Exception
+  {
+    throwCustomExceptions = 2;
+
+    doAnswer(new Answer<InputStream>()
+    {
+      int retryCount = 0;
+      @Override
+      public InputStream answer(InvocationOnMock invocation) throws Throwable
+      {
+        if (retryCount < 2) {
+          retryCount += 1;
+          throwCustomExceptions -= 1;
+          throw new CustomException("I am a custom retryable exception", new 
RuntimeException());
+        } else {
+          return (InputStream) invocation.callRealMethod();
+        }
+      }
+    }).when(objectOpenFunction).open(any(), anyLong());
+
+    new RetryingInputStream<>(
+        testFile,
+        objectOpenFunction,
+        t -> t instanceof CustomException,
+        MAX_RETRY,
+        false
+    );

Review Comment:
   ## Potential input resource leak
   
   This RetryingInputStream<File> is not always closed on method exit.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/4897)



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