Skip to content

Commit cb4cded

Browse files
committed
Workaround struct inspect bug on JRuby 9.2.0.0
Due to a bug in JRuby 9.2.0.0, mutating the result of `Module#to_s` actually changes the result of other `Module#to_s` calls to the same module or class, rather than returning a new `String`. This broke `AbstractStruct#pr_underscore` which is used when rendering `#inspect` for structures. This was already fixed upstream, but as a workaround, let's dup the String before we mutate it, so as to not trip anyone using this JRuby version (and to restore Travis to beautiful green). Issue jruby/jruby#5229
1 parent d188f83 commit cb4cded

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/concurrent/synchronization/abstract_struct.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def ns_merge(other, &block)
117117

118118
# @!visibility private
119119
def pr_underscore(clazz)
120-
word = clazz.to_s
120+
word = clazz.to_s.dup # dup string to workaround JRuby 9.2.0.0 bug https://github.com/jruby/jruby/issues/5229
121121
word.gsub!(/::/, '/')
122122
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
123123
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')

0 commit comments

Comments
 (0)