Skip to content

Commit 4b68038

Browse files
committed
Do not replace the cache entry if there is already one
* That way, multiple lookups for the same file always return the same object.
1 parent 0363dda commit 4b68038

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/mri/rubygems/specification.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,12 @@ def self.load(file)
11731173
if Gem::Specification === _spec
11741174
_spec.loaded_from = File.expand_path file.to_s
11751175
LOAD_CACHE_MUTEX.synchronize do
1176-
LOAD_CACHE[file] = _spec
1176+
prev = LOAD_CACHE[file]
1177+
if prev
1178+
_spec = prev
1179+
else
1180+
LOAD_CACHE[file] = _spec
1181+
end
11771182
end
11781183
return _spec
11791184
end

0 commit comments

Comments
 (0)