diff --git a/core/src/main/java/org/jruby/RubyHash.java b/core/src/main/java/org/jruby/RubyHash.java index 0dde045bfff..f3dc3cd8c4a 100644 --- a/core/src/main/java/org/jruby/RubyHash.java +++ b/core/src/main/java/org/jruby/RubyHash.java @@ -1356,11 +1356,18 @@ public RubyFixnum hash() { @JRubyMethod(name = "hash") public RubyFixnum hash(ThreadContext context) { final int size = size(); - long[] hval = { Helpers.hashStart(context.runtime, size) }; - if (size > 0) { + + long hash = Helpers.hashStart(context.runtime, size); + + if (size != 0) { + long[] hval = {hash}; + iteratorVisitAll(context, CalculateHashVisitor, hval); + + hash = hval[0]; } - return context.runtime.newFixnum(hval[0]); + + return context.runtime.newFixnum(hash); } private static final ThreadLocal HASH_16_BYTE = ThreadLocal.withInitial(() -> ByteBuffer.allocate(16));