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)?

Thanks!


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:
org.jruby.RubyString
at org.jruby.RubyNilInvoker$nil_p_method_0_0.call(Unknown
Source)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:272)
at
ruby.jit.ruby.usr.local.jruby.lib.ruby.$1_dot_8.rexml.element.namespace1845016_16032211.file(/usr/local/jruby/lib/ruby/1.8/rexml/element.rb:234)

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