This is an automated email from the ASF dual-hosted git repository.

DomGarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 37dbcee3d6 Rework server percentage check in 
ConfigurableScanServerSelector  (#6475)
37dbcee3d6 is described below

commit 37dbcee3d676adcfa28570925fb9dede757ff6dc
Author: Amanda Villarreal <[email protected]>
AuthorDate: Mon Jul 20 09:54:16 2026 -0500

    Rework server percentage check in ConfigurableScanServerSelector  (#6475)
    
    * improve server percentage check in ConfigurableScanServerSelector
    * add new unit test for added logic
---
 .../core/spi/scan/ConfigurableScanServerSelector.java    |  6 +++---
 .../spi/scan/ConfigurableScanServerSelectorTest.java     | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
 
b/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
index 20ca80aa30..a6f46c65a2 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelector.java
@@ -231,11 +231,11 @@ public class ConfigurableScanServerSelector implements 
ScanServerSelector {
       }
 
       if (servers.endsWith("%")) {
-        // TODO check < 100
-        serversRatio = Double.parseDouble(servers.substring(0, 
servers.length() - 1)) / 100.0;
-        if (serversRatio < 0 || serversRatio > 1) {
+        double percent = Double.parseDouble(servers.substring(0, 
servers.length() - 1));
+        if (percent <= 0 || percent > 100 || !Double.isFinite(percent)) {
           throw new IllegalArgumentException("Bad servers percentage : " + 
servers);
         }
+        serversRatio = percent / 100.0;
         isServersPercent = true;
       } else {
         parsedServers = Integer.parseInt(servers);
diff --git 
a/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
 
b/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
index f55226977f..92a6efae0d 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/spi/scan/ConfigurableScanServerSelectorTest.java
@@ -741,4 +741,20 @@ public class ConfigurableScanServerSelectorTest {
       assertEquals(Duration.ofMillis(expected), selections.getDelay());
     }
   }
+
+  /**
+   * Test that a NaN server percentage value throws the expected exception
+   */
+  @Test
+  public void testInfiniteServerPercentage() {
+    String defaultProfile =
+        "{'isDefault':true,'maxBusyTimeout':'5m','busyTimeoutMultiplier':4, 
'attemptPlans':"
+            + "[{'servers':'NaN%', 'busyTimeout':'60s'}]}";
+
+    var opts = Map.of("profiles", ("[" + defaultProfile + "]").replace('\'', 
'"'));
+
+    var exception =
+        assertThrows(IllegalArgumentException.class, () -> runBusyTest(100, 1, 
5, 66, opts));
+    assertTrue(exception.getMessage().contains("Bad servers percentage"));
+  }
 }

Reply via email to