]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
(#12377) Avoid infinite loop when retrying require json
authorJeff McCune <jeff@puppetlabs.com>
Mon, 6 Feb 2012 05:22:27 +0000 (21:22 -0800)
committerKen Barber <ken@bob.sh>
Mon, 6 Feb 2012 17:54:41 +0000 (17:54 +0000)
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

index 90586a9dc739447c586db1db5071685466fbafd3..2658dfe10f6cdf64ee005e44f5a34e1922132b12 100644 (file)
@@ -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|