Skip to content

Commit 24f7095

Browse files
Jeff McCunekbarber
authored andcommitted
(#12377) Avoid infinite loop when retrying require json
Without this patch an infinite loop will be entered if the json and rubygems libraries are not available. This patch fixes the problem by retrying the `require 'json'` only if rubygems was successfully loaded for the first time. Subsequent attempts to load rubygems will cause the LoadError exception from a missing json library to be re-raised. Thanks to Krzysztof Wilczynski for pointing out this issue.
1 parent 4c2bba8 commit 24f7095

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/facter/facter_dot_d.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def json_parser(file)
5454
begin
5555
require 'json'
5656
rescue LoadError
57-
require 'rubygems'
58-
retry
57+
retry if require 'rubygems'
58+
raise
5959
end
6060

6161
JSON.load(File.read(file)).each_pair do |f, v|

0 commit comments

Comments
 (0)