8322142: JFR: Periodic tasks aren't orphaned between recordings

Reviewed-by: egahlin
This commit is contained in:
Carter Kozak 2024-01-03 15:09:06 +00:00 committed by Erik Gahlin
parent b67b71cd87
commit 1551928502

View File

@ -63,11 +63,7 @@ final class BatchManager {
}
for (PeriodicTask task : activeSortedTasks(tasks)) {
if (task.isSchedulable()) {
Batch batch = task.getBatch();
// If new task, or period has changed, find new batch
if (batch == null) {
batch = findBatch(task.getPeriod());
}
Batch batch = findBatch(task.getPeriod(), task.getBatch());
batch.add(task);
}
}
@ -89,7 +85,7 @@ final class BatchManager {
return tasks;
}
private Batch findBatch(long period) {
private Batch findBatch(long period, Batch oldBatch) {
// All events with a period less than 1000 ms
// get their own unique batch. The rationale for
// this is to avoid a scenario where a user (mistakenly) specifies
@ -102,7 +98,7 @@ final class BatchManager {
return batch;
}
}
Batch batch = new Batch(period);
Batch batch = oldBatch != null ? oldBatch : new Batch(period);
batches.add(batch);
return batch;
}