Skip to content

Commit a4cfe65

Browse files
committed
fix(ci): use StrictMathWrapper instead of java.lang.Math
check-math CI job flagged uses of java.lang.Math introduced in 8a76db8 (compactThreads auto-expand logic in StorageConfig.postProcess and the corresponding test assertions). Swap both to StrictMathWrapper.max, which is the project-wide convention enforced by the check-math scanner.
1 parent 8a76db8 commit a4cfe65

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

common/src/main/java/org/tron/core/config/args/StorageConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import lombok.Getter;
99
import lombok.Setter;
1010
import lombok.extern.slf4j.Slf4j;
11+
import org.tron.common.math.StrictMathWrapper;
1112

1213
/**
1314
* Storage configuration bean.
@@ -123,7 +124,7 @@ public static class DbSettingsConfig {
123124
// Expand 0 → auto-detected processor count. Mirrors develop Args.java:1609-1611.
124125
void postProcess() {
125126
if (compactThreads == 0) {
126-
compactThreads = Math.max(Runtime.getRuntime().availableProcessors(), 1);
127+
compactThreads = StrictMathWrapper.max(Runtime.getRuntime().availableProcessors(), 1);
127128
}
128129
}
129130
}

common/src/test/java/org/tron/core/config/args/StorageConfigTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.typesafe.config.Config;
88
import com.typesafe.config.ConfigFactory;
99
import org.junit.Test;
10+
import org.tron.common.math.StrictMathWrapper;
1011

1112
public class StorageConfigTest {
1213

@@ -67,7 +68,7 @@ public void testDbSettingsDefaults() {
6768
StorageConfig.DbSettingsConfig ds = sc.getDbSettings();
6869
assertEquals(7, ds.getLevelNumber());
6970
// compactThreads default is 0 in reference.conf, auto-expanded by postProcess()
70-
assertEquals(Math.max(Runtime.getRuntime().availableProcessors(), 1),
71+
assertEquals(StrictMathWrapper.max(Runtime.getRuntime().availableProcessors(), 1),
7172
ds.getCompactThreads());
7273
assertEquals(16, ds.getBlocksize());
7374
assertEquals(256, ds.getMaxBytesForLevelBase());
@@ -83,7 +84,7 @@ public void testCompactThreadsAutoExpand() {
8384
// compactThreads = 0 must be auto-expanded to availableProcessors (min 1)
8485
Config config = withRef("storage { dbSettings { compactThreads = 0 } }");
8586
StorageConfig sc = StorageConfig.fromConfig(config);
86-
assertEquals(Math.max(Runtime.getRuntime().availableProcessors(), 1),
87+
assertEquals(StrictMathWrapper.max(Runtime.getRuntime().availableProcessors(), 1),
8788
sc.getDbSettings().getCompactThreads());
8889
}
8990

0 commit comments

Comments
 (0)