JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6871

Encoding::UndefinedConversionError when dropping a mongo database with Mongoid 3

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre2
    • Fix Version/s: JRuby 1.7.0.RC1
    • Component/s: Encoding
    • Labels:
      None
    • Environment:
      Mac OS X 10.7.4 Java 1.7.0_05
    • Number of attachments :
      0

      Description

      jruby-1.7.0.preview2 :003 > ::Mongoid::Sessions.default.drop
      Encoding::UndefinedConversionError: Input length = 1
      	from org/jruby/RubyIO.java:1400:in `write'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:229:in `write'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:235:in `handle_socket_errors'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:229:in `write'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:146:in `write'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:169:in `with_connection'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/connection.rb:145:in `write'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:517:in `flush'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:123:in `ensure_connected'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:516:in `flush'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:531:in `logging'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:515:in `flush'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:504:in `process'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:70:in `command'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/node.rb:366:in `refresh'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/cluster.rb:112:in `refresh'
      ... 4 levels...
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/session/context.rb:108:in `with_node'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/session/context.rb:50:in `command'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/database.rb:89:in `drop'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/session.rb:305:in `with'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/database.rb:88:in `drop'
      	from /Users/tim/.rvm/gems/jruby-head/gems/moped-1.2.1/lib/moped/session.rb:130:in `drop'
      	from (irb):3:in `evaluate'
      	from org/jruby/RubyKernel.java:1064:in `eval'
      	from org/jruby/RubyKernel.java:1389:in `loop'
      	from org/jruby/RubyKernel.java:1172:in `catch'
      	from org/jruby/RubyKernel.java:1172:in `catch'
      	from /Users/tim/.rvm/gems/jruby-head/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
      	from /Users/tim/.rvm/gems/jruby-head/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
      	from /Users/tim/.rvm/gems/jruby-head/gems/railties-3.2.8/lib/rails/commands.rb:41:in `(root)'
      	from org/jruby/RubyKernel.java:1018:in `require'
      	from script/rails:6:in `(root)'jruby-1.7.0.preview2 :004 > 
      
      $ jruby -v
      jruby 1.7.0.preview2 (1.9.3p203) 2012-08-30 b16f8c3 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_05-b06 [darwin-x86_64]
      

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Grr...ok, I'll investigate that scenario too.

        Show
        Charles Oliver Nutter added a comment - Grr...ok, I'll investigate that scenario too.
        Hide
        Charles Oliver Nutter added a comment -

        So the rule for setting up internal/external (or read/write, in whatever parlance gets used) is that if external is set to ascii (a la set_encoding('binary') or other paths) and internal is not specified, leave internal as null. Otherwise, set internal to default internal encoding.

        That logic lives in rb_io_ext_int_to_encs, which has some MRI-specific logic, but I'm attempting to duplicate at least the internal == null && external != ascii check, which makes your latest example work too.

        Show
        Charles Oliver Nutter added a comment - So the rule for setting up internal/external (or read/write, in whatever parlance gets used) is that if external is set to ascii (a la set_encoding('binary') or other paths) and internal is not specified, leave internal as null. Otherwise, set internal to default internal encoding. That logic lives in rb_io_ext_int_to_encs, which has some MRI-specific logic, but I'm attempting to duplicate at least the internal == null && external != ascii check, which makes your latest example work too.
        Hide
        Charles Oliver Nutter added a comment -

        Try again?

        commit 290099647ac6a3ac1d7e6f50f5a820dbf2819be2
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Thu Aug 30 15:12:08 2012 -0500
        
            Reinstate ext != ascii check for IO set_encoding logic. JRUBY-6871
        
        :100644 100644 e5829cc... 7d64db1... M	src/org/jruby/RubyIO.java
        :100644 100644 5f090da... 693f902... M	src/org/jruby/util/io/EncodingOption.java
        

        At least we seem to be circling in on the right logic, and I'm not just hacking one-off fixes in.

        Show
        Charles Oliver Nutter added a comment - Try again? commit 290099647ac6a3ac1d7e6f50f5a820dbf2819be2 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Aug 30 15:12:08 2012 -0500 Reinstate ext != ascii check for IO set_encoding logic. JRUBY-6871 :100644 100644 e5829cc... 7d64db1... M src/org/jruby/RubyIO.java :100644 100644 5f090da... 693f902... M src/org/jruby/util/io/EncodingOption.java At least we seem to be circling in on the right logic, and I'm not just hacking one-off fixes in.
        Hide
        Tim Olsen added a comment -

        Fixed! Thank you for the quick turnaround!

        Show
        Tim Olsen added a comment - Fixed! Thank you for the quick turnaround!
        Hide
        Charles Oliver Nutter added a comment -

        Hooray!

        Show
        Charles Oliver Nutter added a comment - Hooray!

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Tim Olsen
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: