Skip to content

Commit ed2e905

Browse files
authored
Test for executable concerns with dup only for String (#219)
1 parent f16228e commit ed2e905

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/temporal/execution_options.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,21 @@ def task_list
5151
private
5252

5353
def has_executable_concern?(object)
54-
# NOTE: When object is a String .dup is needed since Object#singleton_class mutates
55-
# it and screws up C extension class detection (used by Protobufs)
56-
object.dup.singleton_class.included_modules.include?(Concerns::Executable)
54+
if object.is_a?(String)
55+
# NOTE: When object is a String, Object#singleton_class mutates it and
56+
# screws up C extension class detection used in older versions of
57+
# the protobuf library. This was fixed in protobuf 3.20.0-rc1
58+
# via https://github.com/protocolbuffers/protobuf/pull/9342.
59+
#
60+
# Creating a duplicate of this object prevents the mutation of
61+
# the original object which will be put into a protobuf payload
62+
# before being sent to Temporal server. Because duplication fails
63+
# when Sorbet final classes are used, duplication is limited only
64+
# to String classes.
65+
object = object.dup
66+
end
67+
68+
object.singleton_class.included_modules.include?(Concerns::Executable)
5769
rescue TypeError
5870
false
5971
end

0 commit comments

Comments
 (0)