Skip to content

Commit cd76804

Browse files
authored
Merge pull request #129 from JasonFengJ9/npetimer
Add NULL check for CRIU field retrieval
2 parents 6969fb4 + 4e55e18 commit cd76804

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/java.base/share/classes/java/util/Timer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ public void schedule(TimerTask task, long delay) {
214214
throw new IllegalArgumentException("Negative delay.");
215215
/*[IF CRIU_SUPPORT]*/
216216
// only tasks scheduled before Checkpoint to be adjusted
217-
if (InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0) {
217+
if ((InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0)
218+
&& (task != null)
219+
) {
218220
task.criuAdjustRequired = true;
219221
}
220222
/*[ENDIF] CRIU_SUPPORT*/
@@ -275,7 +277,9 @@ public void schedule(TimerTask task, long delay, long period) {
275277
throw new IllegalArgumentException("Non-positive period.");
276278
/*[IF CRIU_SUPPORT]*/
277279
// only tasks scheduled before Checkpoint to be adjusted
278-
if (InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0) {
280+
if ((InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0)
281+
&& (task != null)
282+
) {
279283
task.criuAdjustRequired = true;
280284
}
281285
/*[ENDIF] CRIU_SUPPORT*/
@@ -361,7 +365,9 @@ public void scheduleAtFixedRate(TimerTask task, long delay, long period) {
361365
throw new IllegalArgumentException("Non-positive period.");
362366
/*[IF CRIU_SUPPORT]*/
363367
// only tasks scheduled before Checkpoint to be adjusted
364-
if (InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0) {
368+
if ((InternalCRIUSupport.getCheckpointRestoreNanoTimeDelta() == 0)
369+
&& (task != null)
370+
) {
365371
task.criuAdjustRequired = true;
366372
}
367373
/*[ENDIF] CRIU_SUPPORT*/

0 commit comments

Comments
 (0)