From 24f7095e282fc364b9d12ff26c268b4fd919f09c Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Sun, 5 Feb 2012 21:22:27 -0800 Subject: (#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. --- lib/facter/facter_dot_d.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb index 90586a9..2658dfe 100644 --- a/lib/facter/facter_dot_d.rb +++ b/lib/facter/facter_dot_d.rb @@ -54,8 +54,8 @@ class Facter::Util::DotD begin require 'json' rescue LoadError - require 'rubygems' - retry + retry if require 'rubygems' + raise end JSON.load(File.read(file)).each_pair do |f, v| -- cgit v1.2.3