Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Core Classes/Modules
    • Labels:
    • Environment:
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      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

      {bundle && rake}

      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)
      

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        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]
        
        Show
        Charles Oliver Nutter added a comment - 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]

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Vincent Landgraf
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: