summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Brody <git@abrody.com>2019-07-27 04:04:04 -0400
committerAndy Brody <git@abrody.com>2019-07-27 04:04:04 -0400
commit789ced10df4e1dca44522996a379008542d8081c (patch)
treed7b948b233a7243e8b262a7375059c92ec45e67a
parent1366181002d8479d9c3105608b83ec20f1b96193 (diff)
downloadchef-789ced10df4e1dca44522996a379008542d8081c.tar.gz
Property: Reorder comparison with NOT_PASSED.
The original comparison `value == NOT_PASSED` ends up calling `.<=>` on value under the hood. This relies on the implementation of `<=>`/`cmp` not being broken in that class. Unfortunately, some classes like OpenSSL::X509::Name have broken implementations of `<=>` that raise TypeError instead of returning nil for mismatched types. https://github.com/ruby/openssl/pull/264 As a result, currently, if you attempt to set a resource property to an OpenSSL::X509::Name object, the result is a TypeError. With this change, we use the implementation of comparison from the NOT_PASSED object instead, which we know will work no matter what. Signed-off-by: Andy Brody <git@abrody.com>
-rw-r--r--lib/chef/property.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 6aa76a5236..97f7e0e7f7 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -347,7 +347,7 @@ class Chef
# `get`, the non-lazy, coerced, validated value will always be returned.
#
def call(resource, value = NOT_PASSED)
- if value == NOT_PASSED
+ if NOT_PASSED == value
get(resource)
else
set(resource, value)