Skip to content

Commit d88f901

Browse files
authored
7903504: JMH: Fix new Sonar warnings
1 parent 47f651b commit d88f901

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

jmh-core-benchmarks/src/main/java/org/openjdk/jmh/validation/AffinitySupport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public static List<String> prepare() {
8787

8888
// Need to rename the file to the proper name, otherwise JNA would not discover it
8989
File proper = new File(bootLibraryPath + '/' + System.mapLibraryName("jnidispatch"));
90-
file.renameTo(proper);
90+
if (!file.renameTo(proper)) {
91+
throw new IllegalStateException("Failed to rename " + file + " to " + proper);
92+
}
9193

9294
return Arrays.asList(
9395
"-Djna.nounpack=true", // Should not unpack itself, but use predefined path

jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfNormProfilerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public void test() throws RunnerException {
7777
double cycles = ProfilerTestUtils.checkedGet(sr, "cycles", "cycles:u").getScore();
7878
double branches = ProfilerTestUtils.checkedGet(sr, "branches", "branches:u").getScore();
7979

80-
Assert.assertNotEquals(0, instructions);
81-
Assert.assertNotEquals(0, cycles);
82-
Assert.assertNotEquals(0, branches);
80+
Assert.assertNotEquals(0D, instructions, 0D);
81+
Assert.assertNotEquals(0D, cycles, 0D);
82+
Assert.assertNotEquals(0D, branches, 0D);
8383

8484
if (branches > instructions) {
8585
throw new IllegalStateException(String.format("Branches (%.2f) larger than instructions (%.3f)", branches, instructions));
@@ -88,8 +88,8 @@ public void test() throws RunnerException {
8888
double ipc = ProfilerTestUtils.checkedGet(sr, "IPC").getScore();
8989
double cpi = ProfilerTestUtils.checkedGet(sr, "CPI").getScore();
9090

91-
Assert.assertNotEquals(0, ipc);
92-
Assert.assertNotEquals(0, cpi);
91+
Assert.assertNotEquals(0D, ipc, 0D);
92+
Assert.assertNotEquals(0D, cpi, 0D);
9393
}
9494

9595
}

jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/LinuxPerfProfilerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public void test() throws RunnerException {
7979
if (sr.containsKey("·ipc")) {
8080
double ipc = ProfilerTestUtils.checkedGet(sr, "·ipc").getScore();
8181
double cpi = ProfilerTestUtils.checkedGet(sr, "·cpi").getScore();
82-
Assert.assertNotEquals(0, ipc);
83-
Assert.assertNotEquals(0, cpi);
82+
Assert.assertNotEquals(0D, ipc, 0D);
83+
Assert.assertNotEquals(0D, cpi, 0D);
8484
}
8585

8686
Assert.assertTrue(msg.contains("cycles"));

jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/SafepointsProfilerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public void test() throws RunnerException {
6868
double pauseCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.pause.count").getScore();
6969
double ttspCount = ProfilerTestUtils.checkedGet(sr, "·safepoints.ttsp.count").getScore();
7070

71-
Assert.assertNotEquals(pauseTotal, 0);
72-
Assert.assertNotEquals(ttspTotal, 0);
71+
Assert.assertNotEquals(0D, pauseTotal, 0D);
72+
Assert.assertNotEquals(0D, ttspTotal, 0D);
7373

74-
Assert.assertNotEquals(pauseCount, 0);
75-
Assert.assertNotEquals(ttspCount, 0);
76-
Assert.assertEquals(ttspCount, pauseCount, 0);
74+
Assert.assertNotEquals(0D, pauseCount, 0D);
75+
Assert.assertNotEquals(0D, ttspCount, 0D);
76+
Assert.assertEquals(ttspCount, pauseCount, 0D);
7777

7878
if (interval < 3000) {
7979
throw new IllegalStateException("Interval time is too low. " +

0 commit comments

Comments
 (0)