Skip to content

Commit 04db895

Browse files
committed
Add developer-friendly error when monitor not initialized
As I'm fixing monitor initialization issues, it seems to me that the current approach is a bit whack-a-mole so let's at least prepare a nice error message for users to get in case we're still missing a few corner cases.
1 parent e8ee0d2 commit 04db895

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/concurrent/thread_safe/util/array_hash_rbx.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ def #{method}(*args)
4141
else
4242
klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
4343
def #{method}(*args)
44-
@_monitor.synchronize { super }
44+
monitor = @_monitor
45+
46+
unless monitor
47+
raise("BUG: Internal monitor was not properly initialized. Please report this to the "\
48+
"concurrent-ruby developers.")
49+
end
50+
51+
monitor.synchronize { super }
4552
end
4653
RUBY
4754
end

0 commit comments

Comments
 (0)