3
votes

The Net::HTTP that ships with JRuby appears to be the same/similar to the one that ships with MRI Ruby.

Does anyone know if this implementation is, or is not, thread-safe (and, how you know).

My only evidence is the existence of the net-http-persistent library, which claims to be a thread-safe library that uses Net::HTTP.

Examining the source for Net::HTTP doesn't reveal any obvious shared state.

Anyone have any more info?

2
You should just ask @headius on Twitter. He's pretty fast answering JRuby questions. - Chris Ledet

2 Answers

1
votes

Depends on what you mean by thread safe. Net::HTTP uses TimeOut which is generally considered broken because of it's use of Thread#raise and thread#kill. Look here... http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html

0
votes

I can't speak for Net::HTTP, but not all of JRuby's code is thread-safe. For example, Data safety and GIL removal shows that Array isn't thread safe. This is also stated on the JRuby wiki.