Skip to content

Commit

Permalink
chore: check map for nil
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Jun 26, 2024
1 parent e36e70d commit 79fb3ea
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions boltjobs/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ Requeue algorithm:
*/
func (i *Item) Requeue(headers map[string][]string, delay int) error {
const op = errors.Op("boltdb_item_requeue")

if i.headers == nil {
i.headers = make(map[string][]string)
}

if len(headers) > 0 {
maps.Copy(i.headers, headers)
}
Expand Down Expand Up @@ -274,7 +279,7 @@ func fromJob(job jobs.Message) *Item {
Job: job.Name(),
Ident: job.ID(),
Payload: job.Payload(),
headers: defaultHdr(job.Headers()),
headers: job.Headers(),
Options: &Options{
AutoAck: job.AutoAck(),
Priority: job.Priority(),
Expand All @@ -284,14 +289,6 @@ func fromJob(job jobs.Message) *Item {
}
}

func defaultHdr(headers map[string][]string) map[string][]string {
if len(headers) == 0 {
return make(map[string][]string)
}

return headers
}

func strToBytes(data string) []byte {
if data == "" {
return nil
Expand Down

0 comments on commit 79fb3ea

Please sign in to comment.