-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 9.1.1
-
Component/s: Mission Control Core
-
None
There is a bug in the way the default values are handled for the built-in types. Default values are used when there is no explicit call to set that fields value.
This limitation is not documented and it makes it very easy to create invalid recordings.
Therefore, this should be fixed such that the correct default values are written for fields of built-in types if there is none explicitly set.
Example 1:
Type eventType = recording.registerEventType("test.MinimalEvent", builder -> {
builder.addField("customField", Types.Builtin.LONG);
});
try (Recording recording = Recordings.newRecording(jfrPath)) {
recording.writeEvent(eventType.asValue(builder -> {
builder.putField("customField", 12345L);
}));
}
This will fail with 'customField' containing a garbage value because the implicit 'startTime' field will not be written to the event, corrupting the expected layout.
Example 2:
Type eventType = recording.registerEventType("test.Event", builder -> {
builder.addField("emptyField", Types.Builtin.BOOLEAN);
builder.addField("customField", Types.Builtin.LONG);
});
try (Recording recording = Recordings.newRecording(jfrPath)) {
recording.writeEvent(eventType.asValue(builder -> {
builder.putField("startTime", System.nanoTime()); // fill the implicit field
// skip the 'emptyField'
builder.putField("customField", 12345L);
}));
}
This will again fail with 'customField' containing a garbage value because not writing out the 'emptyField' will corrupt the expected layout
- links to
-
Review(master)
openjdk/jmc/690