File tree 1 file changed +3
-1
lines changed
server/src/test/java/org/opensearch/common/settings
1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ public void testMemorySize() {
201
201
assertEquals (new ByteSizeValue (12 ), value .get ());
202
202
203
203
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 ());
205
205
}
206
206
207
207
public void testMemorySizeWithFallbackValue () {
@@ -219,6 +219,8 @@ public void testMemorySizeWithFallbackValue() {
219
219
assertEquals (memorySizeValue .getBytes (), JvmInfo .jvmInfo ().getMem ().getHeapMax ().getBytes () * 0.2 , 1.0 );
220
220
221
221
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.
222
224
assertEquals (new ByteSizeValue ((long ) (JvmInfo .jvmInfo ().getMem ().getHeapMax ().getBytes () * 0.3 )), value .get ());
223
225
224
226
assertTrue (settingUpdater .apply (Settings .builder ().put ("b.byte.size" , "40%" ).build (), Settings .EMPTY ));
You can’t perform that action at this time.
0 commit comments