Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Environment:Hidejruby-1.6.7:
system:
uname: "Darwin cool-macbook.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.13.0 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "17 days 1 hour 34 minutes 1 second ago"
ruby:
interpreter: "jruby"
version: "1.6.7"
date: "2012-02-22"
platform: "darwin-x86_64-java"
patchlevel: "TM"
full_version: "jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]"
homes:
gem: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7"
ruby: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7"
binaries:
ruby: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/ruby"
irb: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/irb"
gem: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/gem"
rake: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global/bin/rake"
environment:
PATH: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7/bin:/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global/bin:/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin:/Users/vincentlandgraf/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Applications/Wireshark.app/Contents/Resources/bin:/usr/local/sbin"
GEM_HOME: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7"
GEM_PATH: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7:/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global"
MY_RUBY_HOME: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7"
IRBRC: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/.irbrc"
RUBYOPT: ""
gemset: ""
Showjruby-1.6.7: system: uname: "Darwin cool-macbook.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64" bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)" zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)" rvm: version: "rvm 1.13.0 (latest) by Wayne E. Seguin < wayneeseguin@gmail.com >, Michal Papis < mpapis@gmail.com > [ https://rvm.io/ ]" updated: "17 days 1 hour 34 minutes 1 second ago" ruby: interpreter: "jruby" version: "1.6.7" date: "2012-02-22" platform: "darwin-x86_64-java" patchlevel: "TM" full_version: "jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]" homes: gem: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7" ruby: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7" binaries: ruby: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/ruby" irb: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/irb" gem: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/gem" rake: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global/bin/rake" environment: PATH: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7/bin:/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global/bin:/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin:/Users/vincentlandgraf/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Applications/Wireshark.app/Contents/Resources/bin:/usr/local/sbin" GEM_HOME: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7" GEM_PATH: "/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7:/Users/vincentlandgraf/.rvm/gems/jruby-1.6.7@global" MY_RUBY_HOME: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7" IRBRC: "/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/.irbrc" RUBYOPT: "" gemset: ""
-
Patch Submitted:Yes
-
Number of attachments :
Description
There is a bug in the handling of XMLRPC::XMLWriter::Simple#element(name, attrs, *children)
If happens that the passed children is an Array<Array<String>> instead of Array<String>. The children.join("") in line 49 fails because of this. But it should be avoided, that the children contain two arrays.
The Problem ist only in 1.9 Mode and only in jruby.
I use the following monkey patch as a temporary fix:
Patch.rb
class XMLRPC::XMLWriter::Simple
alias_method :unsave_element, :element
def element(name, attrs, *children)
unsave_element(name, attrs, *children.flatten)
end
end
To repoduce the problem do this:
1. Clone the project from
{https://github.com/threez/rack-rpc}2. Remove the Patch at the top of
{rack-rpc/lib/rack/rpc/endpoint/xmlrpc.rb}. It looks like in the sample above.
3. Run the tests with
The Result will look like this:
/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/jruby -S rspec ./spec/endpoint_spec.rb ./spec/jsonrpc_spec.rb ./spec/server_spec.rb ./spec/version_spec.rb ./spec/xmlrpc_spec.rb
.....FF...............................F
Failures:
1) Rack::RPC::Endpoint handles XML requests (application/xml)
Failure/Error: post "/rpc", {}, Factory.valid_xml_request('CONTENT_TYPE'=> 'application/xml')
TypeError:
can't convert Array into String
# ./lib/rack/rpc/endpoint/xmlrpc.rb:54:in `process'
# ./lib/rack/rpc/endpoint/xmlrpc.rb:43:in `execute'
# ./lib/rack/rpc/endpoint.rb:40:in `call'
# ./spec/endpoint_spec.rb:34:in `(root)'
2) Rack::RPC::Endpoint handles XML requests (text/xml)
Failure/Error: post "/rpc", {}, Factory.valid_xml_request('CONTENT_TYPE'=> 'text/xml')
TypeError:
can't convert Array into String
# ./lib/rack/rpc/endpoint/xmlrpc.rb:54:in `process'
# ./lib/rack/rpc/endpoint/xmlrpc.rb:43:in `execute'
# ./lib/rack/rpc/endpoint.rb:40:in `call'
# ./spec/endpoint_spec.rb:39:in `(root)'
3) Rack::RPC::Endpoint::XMLRPC returns valid response when request is valid
Failure/Error: post "/rpc", {}, Factory.valid_xml_request
TypeError:
can't convert Array into String
# ./lib/rack/rpc/endpoint/xmlrpc.rb:54:in `process'
# ./lib/rack/rpc/endpoint/xmlrpc.rb:43:in `execute'
# ./lib/rack/rpc/endpoint.rb:40:in `call'
# ./spec/xmlrpc_spec.rb:42:in `(root)'
Finished in 2.62 seconds
39 examples, 3 failures
Failed examples:
rspec ./spec/endpoint_spec.rb:33 # Rack::RPC::Endpoint handles XML requests (application/xml)
rspec ./spec/endpoint_spec.rb:38 # Rack::RPC::Endpoint handles XML requests (text/xml)
rspec ./spec/xmlrpc_spec.rb:41 # Rack::RPC::Endpoint::XMLRPC returns valid response when request is valid
org.jruby.exceptions.RaiseException: (SystemExit) exit
rake aborted!
/Users/vincentlandgraf/.rvm/rubies/jruby-1.6.7/bin/jruby -S rspec ./spec/endpoint_spec.rb ./spec/jsonrpc_spec.rb ./spec/server_spec.rb ./spec/version_spec.rb ./spec/xmlrpc_spec.rb failed
Tasks: TOP => default => spec
(See full trace by running task with --trace)
Appears to be working on JRuby master. We'll have a 1.7 preview release within the next week.
diff --git a/lib/rack/rpc/endpoint/xmlrpc.rb b/lib/rack/rpc/endpoint/xmlrpc.rb index f6e7156..104faaa 100644 --- a/lib/rack/rpc/endpoint/xmlrpc.rb +++ b/lib/rack/rpc/endpoint/xmlrpc.rb @@ -1,6 +1,7 @@ require 'xmlrpc/server' unless defined?(XMLRPC::BasicServer) require 'builder' # @see http://rubygems.org/gems/builder +=begin # Monkey patch the xml writer for problems with double arrays # Problem is filed as: http://jira.codehaus.org/browse/JRUBY-6670 class XMLRPC::XMLWriter::Simple @@ -9,6 +10,7 @@ class XMLRPC::XMLWriter::Simple unsave_element(name, attrs, *children.flatten) end end +=end class Rack::RPC::Endpoint ## system ~/projects/rack-rpc $ rake /Users/headius/projects/jruby/bin/jruby -S rspec ./spec/endpoint_spec.rb ./spec/jsonrpc_spec.rb ./spec/server_spec.rb ./spec/version_spec.rb ./spec/xmlrpc_spec.rb ....................................... Finished in 0.817 seconds 39 examples, 0 failures system ~/projects/rack-rpc $ jruby -v jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-16 a3763d8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]