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


##########
server/src/test/java/org/apache/druid/guice/BrokerProcessingModuleTest.java:
##########
@@ -86,27 +93,29 @@
   public void testCachePopulatorAsSingleton()
   {
     CachePopulator cachePopulator = injector.getInstance(CachePopulator.class);
-    Assert.assertNotNull(cachePopulator);
+    Assertions.assertNotNull(cachePopulator);
   }
 
-  @Test(expected = ProvisionException.class)
+  @Test
   public void testMemoryCheckThrowsException()
   {
-    // JDK 9 and above do not support checking for direct memory size
-    // so this test only validates functionality for Java 8.
-    try {
-      JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
-    }
-    catch (UnsupportedOperationException e) {
-      Assume.assumeNoException(e);
-    }
-    Properties props = new Properties();
-    props.setProperty("druid.processing.buffer.sizeBytes", "3GiB");
-    Injector injector1 = makeInjector(props);
-
-    DruidProcessingConfig processingBufferConfig = 
injector1.getInstance(DruidProcessingConfig.class);
-    BrokerProcessingModule module = new BrokerProcessingModule();
-    module.getMergeBufferPool(processingBufferConfig, 
JvmUtils.getRuntimeInfo());
+    Assertions.assertThrows(ProvisionException.class, () -> {
+      // JDK 9 and above do not support checking for direct memory size
+      // so this test only validates functionality for Java 8.
+      try {
+        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
+      }
+      catch (UnsupportedOperationException e) {
+        Assumptions.assumeTrue(false, e::getMessage);
+      }
+      Properties props = new Properties();
+      props.setProperty("druid.processing.buffer.sizeBytes", "3GiB");
+      Injector injector1 = makeInjector(props);
+
+      DruidProcessingConfig processingBufferConfig = 
injector1.getInstance(DruidProcessingConfig.class);
+      BrokerProcessingModule module = new BrokerProcessingModule();
+      module.getMergeBufferPool(processingBufferConfig, 
JvmUtils.getRuntimeInfo());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [JvmUtils.getRuntimeInfo](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11868)



##########
server/src/test/java/org/apache/druid/guice/DruidProcessingModuleTest.java:
##########
@@ -22,42 +22,46 @@
 import com.google.inject.ProvisionException;
 import org.apache.druid.query.DruidProcessingConfig;
 import org.apache.druid.utils.JvmUtils;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Test;
+
 
 public class DruidProcessingModuleTest
 {
 
-  @Test(expected = ProvisionException.class)
+  @Test
   public void testMemoryCheckThrowsException()
   {
-    // JDK 9 and above do not support checking for direct memory size
-    // so this test only validates functionality for Java 8.
-    try {
-      JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
-    }
-    catch (UnsupportedOperationException e) {
-      Assume.assumeNoException(e);
-    }
+    Assertions.assertThrows(ProvisionException.class, () -> {
+      // JDK 9 and above do not support checking for direct memory size
+      // so this test only validates functionality for Java 8.
+      try {
+        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [JvmUtils.getRuntimeInfo](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11869)



##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataConnectorTest.java:
##########
@@ -265,8 +265,8 @@
         CentralizedDatasourceSchemaConfig.create()
     );
     BasicDataSource dataSource = testSQLMetadataConnector.getDatasource();
-    Assert.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
-    Assert.assertEquals(dataSource.getDefaultQueryTimeout().intValue(), 30000);
+    Assertions.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [BasicDataSource.getMaxConnLifetimeMillis](1) should be avoided 
because it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11871)



##########
server/src/test/java/org/apache/druid/guice/DruidProcessingModuleTest.java:
##########
@@ -22,42 +22,46 @@
 import com.google.inject.ProvisionException;
 import org.apache.druid.query.DruidProcessingConfig;
 import org.apache.druid.utils.JvmUtils;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Test;
+
 
 public class DruidProcessingModuleTest
 {
 
-  @Test(expected = ProvisionException.class)
+  @Test
   public void testMemoryCheckThrowsException()
   {
-    // JDK 9 and above do not support checking for direct memory size
-    // so this test only validates functionality for Java 8.
-    try {
-      JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
-    }
-    catch (UnsupportedOperationException e) {
-      Assume.assumeNoException(e);
-    }
+    Assertions.assertThrows(ProvisionException.class, () -> {
+      // JDK 9 and above do not support checking for direct memory size
+      // so this test only validates functionality for Java 8.
+      try {
+        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
+      }
+      catch (UnsupportedOperationException e) {
+        Assumptions.assumeTrue(false, e::getMessage);
+      }
 
-    DruidProcessingModule module = new DruidProcessingModule();
-    module.getIntermediateResultsPool(
-        new DruidProcessingConfig()
-        {
-          @Override
-          public String getFormatString()
+      DruidProcessingModule module = new DruidProcessingModule();
+      module.getIntermediateResultsPool(
+          new DruidProcessingConfig()
           {
-            return "test";
-          }
+            @Override
+            public String getFormatString()
+            {
+              return "test";
+            }
 
-          @Override
-          public int intermediateComputeSizeBytes()
-          {
-            return Integer.MAX_VALUE;
-          }
-        },
-        JvmUtils.getRuntimeInfo()
-    );
+            @Override
+            public int intermediateComputeSizeBytes()
+            {
+              return Integer.MAX_VALUE;
+            }
+          },
+          JvmUtils.getRuntimeInfo()

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [JvmUtils.getRuntimeInfo](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11870)



##########
server/src/test/java/org/apache/druid/metadata/SQLMetadataConnectorTest.java:
##########
@@ -265,8 +265,8 @@
         CentralizedDatasourceSchemaConfig.create()
     );
     BasicDataSource dataSource = testSQLMetadataConnector.getDatasource();
-    Assert.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
-    Assert.assertEquals(dataSource.getDefaultQueryTimeout().intValue(), 30000);
+    Assertions.assertEquals(dataSource.getMaxConnLifetimeMillis(), 1200000);
+    Assertions.assertEquals(dataSource.getDefaultQueryTimeout().intValue(), 
30000);

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [BasicDataSource.getDefaultQueryTimeout](1) should be avoided 
because it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11872)



##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -677,21 +677,21 @@
     };
 
     serverView.addSegment(newSegment(datasource, 1), 
ServerType.INDEXER_EXECUTOR);
-    Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+    Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
 
-    Assert.assertEquals(7, schema.getTotalSegments());
+    Assertions.assertEquals(7, schema.getTotalSegments());
     List<AvailableSegmentMetadata> metadatas = schema
         .getSegmentMetadataSnapshot()
         .values()
         .stream()
         .filter(metadata -> 
datasource.equals(metadata.getSegment().getDataSource()))
         .collect(Collectors.toList());
-    Assert.assertEquals(1, metadatas.size());
+    Assertions.assertEquals(1, metadatas.size());
     AvailableSegmentMetadata metadata = metadatas.get(0);
-    Assert.assertEquals(1, metadata.isRealtime());
-    Assert.assertEquals(0, metadata.getNumRows());
-    
Assert.assertTrue(schema.getSegmentsNeedingRefresh().contains(metadata.getSegment().getId()));
-    
Assert.assertTrue(schema.getMutableSegments().contains(metadata.getSegment().getId()));
+    Assertions.assertEquals(1, metadata.isRealtime());
+    Assertions.assertEquals(0, metadata.getNumRows());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11875)



##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -1832,10 +1832,10 @@
                                                .findFirst()
                                                .orElse(null);
     final AvailableSegmentMetadata currentMetadata = 
segmentsMetadata.get(currentSegment.getId());
-    Assert.assertEquals(currentSegment.getId(), 
currentMetadata.getSegment().getId());
-    Assert.assertEquals(5L, currentMetadata.getNumRows());
+    Assertions.assertEquals(currentSegment.getId(), 
currentMetadata.getSegment().getId());
+    Assertions.assertEquals(5L, currentMetadata.getNumRows());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11877)



##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -624,22 +624,22 @@
     DataSegment segment = newSegment(datasource, 1);
     serverView.addSegment(segment, ServerType.INDEXER_EXECUTOR);
     serverView.addSegment(segment, ServerType.HISTORICAL);
-    Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+    Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
 
-    Assert.assertEquals(7, schema.getTotalSegments());
+    Assertions.assertEquals(7, schema.getTotalSegments());
     List<AvailableSegmentMetadata> metadatas = schema
         .getSegmentMetadataSnapshot()
         .values()
         .stream()
         .filter(metadata -> 
datasource.equals(metadata.getSegment().getDataSource()))
         .collect(Collectors.toList());
-    Assert.assertEquals(1, metadatas.size());
+    Assertions.assertEquals(1, metadatas.size());
     AvailableSegmentMetadata metadata = metadatas.get(0);
-    Assert.assertEquals(0, metadata.isRealtime()); // realtime flag is unset 
when there is any historical
-    Assert.assertEquals(0, metadata.getNumRows());
-    Assert.assertEquals(2, metadata.getNumReplicas());
-    
Assert.assertTrue(schema.getSegmentsNeedingRefresh().contains(metadata.getSegment().getId()));
-    
Assert.assertFalse(schema.getMutableSegments().contains(metadata.getSegment().getId()));
+    Assertions.assertEquals(0, metadata.isRealtime()); // realtime flag is 
unset when there is any historical
+    Assertions.assertEquals(0, metadata.getNumRows());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11874)



##########
server/src/test/java/org/apache/druid/guice/BrokerProcessingModuleTest.java:
##########
@@ -86,27 +93,29 @@
   public void testCachePopulatorAsSingleton()
   {
     CachePopulator cachePopulator = injector.getInstance(CachePopulator.class);
-    Assert.assertNotNull(cachePopulator);
+    Assertions.assertNotNull(cachePopulator);
   }
 
-  @Test(expected = ProvisionException.class)
+  @Test
   public void testMemoryCheckThrowsException()
   {
-    // JDK 9 and above do not support checking for direct memory size
-    // so this test only validates functionality for Java 8.
-    try {
-      JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
-    }
-    catch (UnsupportedOperationException e) {
-      Assume.assumeNoException(e);
-    }
-    Properties props = new Properties();
-    props.setProperty("druid.processing.buffer.sizeBytes", "3GiB");
-    Injector injector1 = makeInjector(props);
-
-    DruidProcessingConfig processingBufferConfig = 
injector1.getInstance(DruidProcessingConfig.class);
-    BrokerProcessingModule module = new BrokerProcessingModule();
-    module.getMergeBufferPool(processingBufferConfig, 
JvmUtils.getRuntimeInfo());
+    Assertions.assertThrows(ProvisionException.class, () -> {
+      // JDK 9 and above do not support checking for direct memory size
+      // so this test only validates functionality for Java 8.
+      try {
+        JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [JvmUtils.getRuntimeInfo](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11867)



##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -993,23 +993,23 @@
     DataSegment segment = newSegment(datasource, 1);
     serverView.addSegment(segment, ServerType.HISTORICAL);
     serverView.addSegment(segment, ServerType.BROKER);
-    Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+    Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
 
     serverView.removeSegment(segment, ServerType.HISTORICAL);
-    Assert.assertTrue(removeServerSegmentLatch.await(1, TimeUnit.SECONDS));
+    Assertions.assertTrue(removeServerSegmentLatch.await(1, TimeUnit.SECONDS));
 
-    Assert.assertEquals(7, schema.getTotalSegments());
+    Assertions.assertEquals(7, schema.getTotalSegments());
     List<AvailableSegmentMetadata> metadatas = schema
         .getSegmentMetadataSnapshot()
         .values()
         .stream()
         .filter(metadata -> 
datasource.equals(metadata.getSegment().getDataSource()))
         .collect(Collectors.toList());
-    Assert.assertEquals(1, metadatas.size());
+    Assertions.assertEquals(1, metadatas.size());
     AvailableSegmentMetadata metadata = metadatas.get(0);
-    Assert.assertEquals(0, metadata.isRealtime());
-    Assert.assertEquals(0, metadata.getNumRows());
-    Assert.assertEquals(0, metadata.getNumReplicas()); // brokers are not 
counted as replicas yet
+    Assertions.assertEquals(0, metadata.isRealtime());
+    Assertions.assertEquals(0, metadata.getNumRows());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11876)



##########
server/src/test/java/org/apache/druid/segment/metadata/CoordinatorSegmentMetadataCacheTest.java:
##########
@@ -571,20 +571,20 @@
     };
 
     serverView.addSegment(newSegment(datasource, 1), ServerType.HISTORICAL);
-    Assert.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
+    Assertions.assertTrue(addSegmentLatch.await(1, TimeUnit.SECONDS));
 
-    Assert.assertEquals(7, schema.getTotalSegments());
+    Assertions.assertEquals(7, schema.getTotalSegments());
     List<AvailableSegmentMetadata> metadatas = schema
         .getSegmentMetadataSnapshot()
         .values()
         .stream()
         .filter(metadata -> 
datasource.equals(metadata.getSegment().getDataSource()))
         .collect(Collectors.toList());
-    Assert.assertEquals(1, metadatas.size());
+    Assertions.assertEquals(1, metadatas.size());
     AvailableSegmentMetadata metadata = metadatas.get(0);
-    Assert.assertEquals(0, metadata.isRealtime());
-    Assert.assertEquals(0, metadata.getNumRows());
-    
Assert.assertTrue(schema.getSegmentsNeedingRefresh().contains(metadata.getSegment().getId()));
+    Assertions.assertEquals(0, metadata.isRealtime());
+    Assertions.assertEquals(0, metadata.getNumRows());

Review Comment:
   ## CodeQL / Deprecated method or constructor invocation
   
   Invoking [AvailableSegmentMetadata.getNumRows](1) should be avoided because 
it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11873)



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