diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-24 05:43:27 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-24 05:43:27 +0000 |
commit | 52325f6bf868c5efa80fbcf06d139a31816251fb (patch) | |
tree | d38c865fe4271d8a32c71ad44034a90a97367bd7 /activesupport/lib | |
parent | 19f59b6eb1eb83fb6b903ccdd4690f925c4ee247 (diff) | |
download | rails-52325f6bf868c5efa80fbcf06d139a31816251fb.tar.gz rails-52325f6bf868c5efa80fbcf06d139a31816251fb.tar.bz2 rails-52325f6bf868c5efa80fbcf06d139a31816251fb.zip |
Sever infinite loop for mutual dependencies. Closes #2997.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3181 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index be44f61ea7..bce5855c4a 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -45,18 +45,26 @@ module Dependencies #:nodoc: # Append .rb if we have a bare file name. load_file_name = (file_name =~ /\.rb$/ ? file_name : "#{file_name}.rb") - # Enable warnings iff this file has not been loaded before. - if history.include?(file_name) - load load_file_name - else - enable_warnings { load load_file_name } + # Record that we've seen this file *before* loading it to avoid an + # infinite loop with mutual dependencies. + loaded << file_name + + begin + # Enable warnings iff this file has not been loaded before. + if history.include?(file_name) + load load_file_name + else + enable_warnings { load load_file_name } + end + rescue + loaded.delete file_name + raise end else require file_name end - # Record that we've seen this file. - loaded << file_name + # Record history *after* loading so first load gets warnings. history << file_name end |