-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
None
MemoryNotificationInfo instantiation usually(always?) include instantiation of MemoryUsage. MemoryNotificationInfo::from method however allows to accept data that is not correct for MemoryUsage creation.
MemoryUsage constructor asserts "IllegalArgumentException - if used is greater than the value of committed".
https://download.java.net/java/early_access/jdk18/docs/api/java.management/java/lang/management/MemoryUsage.html#%3Cinit%3E(long,long,long,long)
Also this expectation is mentioned at the top level
https://download.java.net/java/early_access/jdk18/docs/api/java.management/java/lang/management/MemoryUsage.html
"'committed' will always be greater than or equal to 'used'"
Specification and OpenJDK implementation of MemoryNotificationInfo::from should follow MemoryUsage specification and reject incorrect data.
At the moment the following is possible with OpenJDK.
=========
CompositeType usage = new CompositeType("usage", "descr",
new String[]{"committed", "init", "max", "used"},
new String[]{"description", "description", "description", "description"},
new OpenType[]{SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG});
CompositeType compositeType =
new CompositeType("typeName", "description",
new String[]{"poolName", "usage", "count"},
new String[]{"descr 1", "descr 2", "descr 3"},
new OpenType[]{SimpleType.STRING, usage, SimpleType.LONG});
String poolName = "The pool name";
long committed = 123L;
long init = 546L;
long max = 999999L;
long used = 5555L;
long count = 123456789L;
MemoryNotificationInfo createdMNI = MemoryNotificationInfo.from(
new CompositeDataSupport(compositeType,
Map.of(
"poolName", poolName,
"usage", new CompositeDataSupport(usage, Map.of(
"committed", committed,
"init", init,
"max", max,
"used", used)),
"count", count
)
));
=========
Here above " 'used' is greater than the value of 'committed' " which potentially leads to creation of an incorrect MemoryUsage instance
MemoryUsage constructor asserts "IllegalArgumentException - if used is greater than the value of committed".
https://download.java.net/java/early_access/jdk18/docs/api/java.management/java/lang/management/MemoryUsage.html#%3Cinit%3E(long,long,long,long)
Also this expectation is mentioned at the top level
https://download.java.net/java/early_access/jdk18/docs/api/java.management/java/lang/management/MemoryUsage.html
"'committed' will always be greater than or equal to 'used'"
Specification and OpenJDK implementation of MemoryNotificationInfo::from should follow MemoryUsage specification and reject incorrect data.
At the moment the following is possible with OpenJDK.
=========
CompositeType usage = new CompositeType("usage", "descr",
new String[]{"committed", "init", "max", "used"},
new String[]{"description", "description", "description", "description"},
new OpenType[]{SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG});
CompositeType compositeType =
new CompositeType("typeName", "description",
new String[]{"poolName", "usage", "count"},
new String[]{"descr 1", "descr 2", "descr 3"},
new OpenType[]{SimpleType.STRING, usage, SimpleType.LONG});
String poolName = "The pool name";
long committed = 123L;
long init = 546L;
long max = 999999L;
long used = 5555L;
long count = 123456789L;
MemoryNotificationInfo createdMNI = MemoryNotificationInfo.from(
new CompositeDataSupport(compositeType,
Map.of(
"poolName", poolName,
"usage", new CompositeDataSupport(usage, Map.of(
"committed", committed,
"init", init,
"max", max,
"used", used)),
"count", count
)
));
=========
Here above " 'used' is greater than the value of 'committed' " which potentially leads to creation of an incorrect MemoryUsage instance