Skip to content

Commit f8e0726

Browse files
committed
Create a mutex instance variable in URI and synchronize when freezing.
Fixes #388.
1 parent a12deb7 commit f8e0726

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/rdf/model/uri.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def self.normalize_path(path)
223223
# @param [Boolean] canonicalize (false)
224224
def initialize(*args, validate: false, canonicalize: false, **options)
225225
@value = @object = @hash = nil
226+
@mutex = Mutex.new
226227
uri = args.first
227228
if uri
228229
@value = uri.to_s
@@ -665,12 +666,14 @@ def dup
665666
# @private
666667
def freeze
667668
unless frozen?
668-
# Create derived components
669-
authority; userinfo; user; password; host; port
670-
@value = value.freeze
671-
@object = object.freeze
672-
@hash = hash.freeze
673-
super
669+
@mutex.synchronize do
670+
# Create derived components
671+
authority; userinfo; user; password; host; port
672+
@value = value.freeze
673+
@object = object.freeze
674+
@hash = hash.freeze
675+
super
676+
end
674677
end
675678
self
676679
end

0 commit comments

Comments
 (0)