github-advanced-security[bot] commented on code in PR #20058:
URL: https://github.com/apache/druid/pull/20058#discussion_r3804788654


##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
   @Test
   public void testMaxPercentageThreadsRequired()
   {
-    expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("maxLowPercent must be set");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    Throwable exception = Assertions.assertThrows(NullPointerException.class, 
() -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'QueryLaningStrategy strategy' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11833)



##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
   @Test
   public void testMaxPercentageThreadsRequired()
   {
-    expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("maxLowPercent must be set");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    Throwable exception = Assertions.assertThrows(NullPointerException.class, 
() -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be set"));
   }
 
   @Test
   public void testMaxLowPercentMustBeGreaterThanZero()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'QueryLaningStrategy strategy' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11834)



##########
server/src/test/java/org/apache/druid/server/log/FileRequestLoggerTest.java:
##########
@@ -112,26 +108,27 @@
     fileRequestLogger.logNativeQuery(nativeRequestLogLine);
     File logFile = new File(logDir, dateTime.toString("yyyy-MM-dd'.log'"));
     Thread.sleep(100);
-    Assert.assertFalse(oldLogFile.exists());
-    Assert.assertTrue(logFile.exists());
+    Assertions.assertFalse(oldLogFile.exists());
+    Assertions.assertTrue(logFile.exists());
     fileRequestLogger.stop();
   }
 
   @Test
-  public void testLogRemoveWithInvalidDuration() throws Exception
+  public void testLogRemoveWithInvalidDuration()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("request logs retention period must be 
atleast as long as roll period");
-    ObjectMapper objectMapper = new ObjectMapper();
-    File logDir = temporaryFolder.newFolder();
-    FileRequestLogger fileRequestLogger = new FileRequestLogger(
-        objectMapper,
-        scheduler,
-        logDir,
-        "yyyy-MM-dd'.log'",
-        Duration.standardMinutes(30),
-        Duration.standardDays(1)
-    );
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      ObjectMapper objectMapper = new ObjectMapper();
+      File logDir = temporaryFolder.newFolder();
+      FileRequestLogger fileRequestLogger = new FileRequestLogger(
+          objectMapper,
+          scheduler,
+          logDir,
+          "yyyy-MM-dd'.log'",
+          Duration.standardMinutes(30),
+          Duration.standardDays(1)
+      );

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'FileRequestLogger fileRequestLogger' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11832)



##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
   @Test
   public void testMaxPercentageThreadsRequired()
   {
-    expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("maxLowPercent must be set");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    Throwable exception = Assertions.assertThrows(NullPointerException.class, 
() -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be set"));
   }
 
   @Test
   public void testMaxLowPercentMustBeGreaterThanZero()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be in the range 1 to 100"));
   }
 
 
   @Test
   public void testMaxLowPercentMustBeLessThanOrEqual100()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'QueryLaningStrategy strategy' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11835)



##########
server/src/test/java/org/apache/druid/server/scheduling/HiLoQueryLaningStrategyTest.java:
##########
@@ -60,44 +56,48 @@
   @Test
   public void testMaxPercentageThreadsRequired()
   {
-    expectedException.expect(NullPointerException.class);
-    expectedException.expectMessage("maxLowPercent must be set");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    Throwable exception = Assertions.assertThrows(NullPointerException.class, 
() -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(null);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be set"));
   }
 
   @Test
   public void testMaxLowPercentMustBeGreaterThanZero()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(-1);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be in the range 1 to 100"));
   }
 
 
   @Test
   public void testMaxLowPercentMustBeLessThanOrEqual100()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(9000);
+    });
+    Assertions.assertTrue(exception.getMessage().contains("maxLowPercent must 
be in the range 1 to 100"));
   }
 
   @Test
   public void testMaxLowPercentZero()
   {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("maxLowPercent must be in the range 1 to 
100");
-    QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(0);
+    Throwable exception = 
Assertions.assertThrows(IllegalArgumentException.class, () -> {
+      QueryLaningStrategy strategy = new HiLoQueryLaningStrategy(0);

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'QueryLaningStrategy strategy' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11836)



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