REXML thread-safe?

I am processing a lot of RSS using REXML and am hitting exceptions when
running multiple threads (using JRuby). The exception always occurs when
trying to access attributes on the same line of my code but at random
times when I am running more than 1 thread. It does not happen when I
run regular ruby, but green threads are probably less likely to switch
context at the wrong time.

I noticed that in element.rb REXML has a class variable @@namespaces
declared, however I could not find where it was used. The exception is
always thrown in a section of code that deals with namespaces so I’m
wondering if it is related.

I was hoping someone could let me know if REXML is supposed to be thread
safe (one instance per thread)?


More details…

The exception is thrown on line 234 of rexml/element.rb in JRuby 1.1.1 :

Exception in thread “Ruby Thread16250988” java.lang.ClassCastException:
at org.jruby.RubyNilInvoker$

This was a bug with JRuby that is fixed in trunk.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs