Skip to content

Commit ab423be

Browse files
kkewweidblock
authored andcommitted
add the comment to unit test
Signed-off-by: kkewwei <kkewwei@163.com>
1 parent eb8a39c commit ab423be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/test/java/org/opensearch/common/settings/SettingTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void testMemorySize() {
201201
assertEquals(new ByteSizeValue(12), value.get());
202202

203203
assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "20%").build(), Settings.EMPTY));
204-
assertEquals(new ByteSizeValue((int) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2)), value.get());
204+
assertEquals(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2)), value.get());
205205
}
206206

207207
public void testMemorySizeWithFallbackValue() {
@@ -219,6 +219,8 @@ public void testMemorySizeWithFallbackValue() {
219219
assertEquals(memorySizeValue.getBytes(), JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.2, 1.0);
220220

221221
assertTrue(settingUpdater.apply(Settings.builder().put("a.byte.size", "30%").build(), Settings.EMPTY));
222+
// If value=getHeapMax()*0.3 is bigger than 2gb, and is bigger than Integer.MAX_VALUE,
223+
// then (long)((int) value) will lose precision.
222224
assertEquals(new ByteSizeValue((long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.3)), value.get());
223225

224226
assertTrue(settingUpdater.apply(Settings.builder().put("b.byte.size", "40%").build(), Settings.EMPTY));

0 commit comments

Comments
 (0)