Skip to content

Commit

Permalink
fix: potential nil pointer dereference in log (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn authored Mar 1, 2024
1 parent ce9418d commit 8a940a4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions quartz/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package quartz

import (
"context"
"errors"
"fmt"
"math"
"sync"
Expand Down Expand Up @@ -410,8 +411,11 @@ func (sched *StdScheduler) calculateNextTick() time.Duration {
if sched.queue.Size() > 0 {
scheduledJob, err := sched.queue.Head()
if err != nil {
logger.Warnf("Failed to calculate next tick for %s, err: %s",
scheduledJob.JobDetail().jobKey, err)
if errors.Is(err, ErrQueueEmpty) {
logger.Debug("Queue is empty")
} else {
logger.Warnf("Failed to calculate next tick: %s", err)
}
} else {
var nextTickDuration time.Duration
nextRunTime := scheduledJob.NextRunTime()
Expand Down

0 comments on commit 8a940a4

Please sign in to comment.