Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.
/ jdk22 Public archive

Commit 2110300

Browse files
committed
8322142: JFR: Periodic tasks aren't orphaned between recordings
Reviewed-by: mgronlun Backport-of: 1551928502c8ed96350e7b4f1316ea35587407fe
1 parent f27efd6 commit 2110300

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/BatchManager.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ private void groupTasksIntoBatches(List<PeriodicTask> tasks) {
6363
}
6464
for (PeriodicTask task : activeSortedTasks(tasks)) {
6565
if (task.isSchedulable()) {
66-
Batch batch = task.getBatch();
67-
// If new task, or period has changed, find new batch
68-
if (batch == null) {
69-
batch = findBatch(task.getPeriod());
70-
}
66+
Batch batch = findBatch(task.getPeriod(), task.getBatch());
7167
batch.add(task);
7268
}
7369
}
@@ -89,7 +85,7 @@ private List<PeriodicTask> activeSortedTasks(List<PeriodicTask> unsorted) {
8985
return tasks;
9086
}
9187

92-
private Batch findBatch(long period) {
88+
private Batch findBatch(long period, Batch oldBatch) {
9389
// All events with a period less than 1000 ms
9490
// get their own unique batch. The rationale for
9591
// this is to avoid a scenario where a user (mistakenly) specifies
@@ -102,7 +98,7 @@ private Batch findBatch(long period) {
10298
return batch;
10399
}
104100
}
105-
Batch batch = new Batch(period);
101+
Batch batch = oldBatch != null ? oldBatch : new Batch(period);
106102
batches.add(batch);
107103
return batch;
108104
}

0 commit comments

Comments
 (0)