Skip to content

Commit

Permalink
Use OpenSSL::Digest to create unique digest because the simple Digest…
Browse files Browse the repository at this point in the history
… module is not thread-safe (#483)
  • Loading branch information
zormandi authored Mar 30, 2020
1 parent 899db04 commit b345e35
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sidekiq_unique_jobs/lock_digest.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'openssl'

module SidekiqUniqueJobs
# Handles uniqueness of sidekiq arguments
#
Expand Down Expand Up @@ -49,7 +51,7 @@ def lock_digest
# Creates a namespaced unique digest based on the {#digestable_hash} and the {#lock_prefix}
# @return [String] a unique digest
def create_digest
digest = ::Digest::MD5.hexdigest(dump_json(digestable_hash))
digest = OpenSSL::Digest::MD5.hexdigest(dump_json(digestable_hash))
"#{lock_prefix}:#{digest}"
end

Expand Down

0 comments on commit b345e35

Please sign in to comment.