summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-09-16 18:36:23 -0700
committerGitHub <noreply@github.com>2021-09-16 18:36:23 -0700
commitb25878eb74e32b68d991ae92783301bbc43604f6 (patch)
tree5433849cab583ec5227c82dd3d63770939c977d3
parent5a0d07645b8f8de546a4bb19a6e5708f2ef73422 (diff)
parentffaad877ae98182198bea6ecc9faecfb39b327fc (diff)
downloadchef-b25878eb74e32b68d991ae92783301bbc43604f6.tar.gz
Merge pull request #12048 from chef/deprecations_16
Fix edge condition in deprecation silence checker
-rw-r--r--lib/chef/deprecated.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index 992876c17d..7f5838d273 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -79,10 +79,12 @@ class Chef
return true if location =~ /^(.*?):(\d+):in/ && begin
# Don't buffer the whole file in memory, so read it one line at a time.
line_no = $2.to_i
- location_file = ::File.open($1)
- (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
- relevant_line = location_file.readline
- relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
+ if File.exist?($1) # some stacktraces come from `eval` and not a file
+ location_file = ::File.open($1)
+ (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
+ relevant_line = location_file.readline
+ relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
+ end
end
false