summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-04-18 12:53:20 -0700
committerdanielsdeleo <dan@opscode.com>2013-04-18 12:53:20 -0700
commit2cc7d616caccc2fd0cb0e0b851e05ba33b95af80 (patch)
tree8841fbbffb77417e980bc062f4cae59be105b8f0 /lib
parent20e2b37faf73a41b80b47d9f0e3172f5c97723d4 (diff)
downloadchef-2cc7d616caccc2fd0cb0e0b851e05ba33b95af80.tar.gz
[CHEF-3432] fix leak of LWRP resource classes
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource/lwrp_base.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb
index 8a714e75b7..370ccd8c10 100644
--- a/lib/chef/resource/lwrp_base.rb
+++ b/lib/chef/resource/lwrp_base.rb
@@ -39,8 +39,13 @@ class Chef
# Add log entry if we override an existing light-weight resource.
class_name = convert_to_class_name(rname)
- overriding = Chef::Resource.const_defined?(class_name)
- Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!") if overriding
+ if Resource.const_defined?(class_name)
+ old_class = Resource.send(:remove_const, class_name)
+ # CHEF-3432 -- Chef::Resource keeps a list of subclasses; need to
+ # remove old ones from the list when replacing.
+ resource_classes.delete(old_class)
+ Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!")
+ end
resource_class = Class.new(self)