Steve Finkelstein created JRUBY-6272: ----------------------------------------
Summary: Encoding exception running JRuby 1.6.5 (1.8 mode) Key: JRUBY-6272 URL: https://jira.codehaus.org/browse/JRUBY-6272 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.6.5 Environment: RHEL 6.1, x86_64, Tomcat6, RVM, Mongoid Reporter: Steve Finkelstein Assignee: Thomas E Enebo I cannot create a MongoDB document (using Mongoid ~> 2.3) with UTF-8 encoding. This works if I do it directly through the Mongo shell, but not through JRuby on Rails. I cannot replicate this on my OSX environment. It is reproducible on RHEL 6.1. I've since recompiled SpiderMonkey with UTF-8 support in addition to compiling MongoDB myself and the issue still exists. I'm in Ruby 1.8 mode. Code: jruby-1.6.5 :012 > hsh = {"id"=>"4ac4efbff964a520a79f20e3", "name"=>"Delicatessen", "contact"=>{"phone"=>"2122260211", "formattedPhone"=>"(212) 226-0211", "twitter"=>"DeliNYC"}, "location"=>{"address"=>"54 Prince St", "crossStreet"=>"at Lafayette St", "lat"=>40.723691, "lng"=>-73.99641612, "distance"=>60, "postalCode"=>"10012", "city"=>"New York", "state"=>"NY", "country"=>"USA"}, "categories"=>[{"id"=>"4bf58dd8d48988d14e941735", "name"=>"American Restaurant", "pluralName"=>"American Restaurants", "shortName"=>"American", "icon"=>{"prefix"=>"https://foursquare.com/img/categories/food/default_", "sizes"=>[32, 44, 64, 88, 256], "name"=>".png"}, "primary"=>true}], "verified"=>true, "stats"=>{"checkinsCount"=>7768, "usersCount"=>5027, "tipCount"=>121}, "url"=>"http://www.delicatessennyc.com", "specials"=>[{"id"=>"4df61ab03151247c51b0e9a9", "type"=>"regular", "message"=>"One complimentary "Hostess" Dessert Plate (trio of mini desserts, house-made cupcake, twinkie, cheesecake lollipop) with purchase of entrée", "imageUrls"=>{"count"=>0}, "finePrint"=>"Excludes Weekend Brunch (Sat/Sun 10:30am-5pm) Unlocked: for checking in 3 times in 7 days", "icon"=>"frequency", "title"=>"Loyalty Special", "provider"=>"foursquare", "redemption"=>"standard"}], "hereNow"=>{"count"=>3}} jruby-1.6.5 :013 > FoursquareVenue.create(hsh) Java::JavaLang::NullPointerException: from org.jruby.exceptions.RaiseException.<init>(RaiseException.java:101) from org.jruby.Ruby.newRaiseException(Ruby.java:3348) from org.jruby.Ruby.newEncodingCompatibilityError(Ruby.java:3323) from org.jruby.RubyString.cat(RubyString.java:1285) from org.jruby.RubyString.cat19(RubyString.java:1221) from org.jruby.RubyHash$5.visit(RubyHash.java:727) from org.jruby.RubyHash.visitAll(RubyHash.java:594) from org.jruby.RubyHash.inspectHash(RubyHash.java:721) from org.jruby.RubyHash.inspect(RubyHash.java:745) from org.jruby.RubyHash$i$0$0$inspect.call(RubyHash$i$0$0$inspect.gen:65535) from org.jruby.RubyClass.finvoke(RubyClass.java:632) from org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:545) from org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:353) from org.jruby.RubyObject.inspect(RubyObject.java:408) from org.jruby.RubyArray.inspectAry(RubyArray.java:1483) from org.jruby.RubyArray.inspect(RubyArray.java:1509) ... 420 levels... from org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75) from org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190) from org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:179) from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312) from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169) from usr.local.rvm.rubies.jruby_minus_1_dot_6_dot_5.bin.jirb.__file__(/usr/local/rvm/rubies/jruby-1.6.5/bin/jirb:17) from usr.local.rvm.rubies.jruby_minus_1_dot_6_dot_5.bin.jirb.load(/usr/local/rvm/rubies/jruby-1.6.5/bin/jirb) from org.jruby.Ruby.runScript(Ruby.java:693) from org.jruby.Ruby.runScript(Ruby.java:686) from org.jruby.Ruby.runNormally(Ruby.java:593) from org.jruby.Ruby.runFromMain(Ruby.java:442) from org.jruby.Main.doRunFromMain(Main.java:321) from org.jruby.Main.internalRun(Main.java:241) from org.jruby.Main.run(Main.java:207) from org.jruby.Main.run(Main.java:191) from org.jruby.Main.main(Main.java:171)jruby-1.6.5 :014 > Here's the same instance with the culprit characters from the hash modified: jruby-1.6.5 :017 > hsh2 = {"id"=>"4ac4efbff964a520a79f20e3", "name"=>"Delicatessen", "contact"=>{"phone"=>"2122260211", "formattedPhone"=>"(212) 226-0211", "twitter"=>"DeliNYC"}, "location"=>{"address"=>"54 Prince St", "crossStreet"=>"at Lafayette St", "lat"=>40.723691, "lng"=>-73.99641612, "distance"=>60, "postalCode"=>"10012", "city"=>"New York", "state"=>"NY", "country"=>"USA"}, "categories"=>[{"id"=>"4bf58dd8d48988d14e941735", "name"=>"American Restaurant", "pluralName"=>"American Restaurants", "shortName"=>"American", "icon"=>{"prefix"=>"https://foursquare.com/img/categories/food/default_", "sizes"=>[32, 44, 64, 88, 256], "name"=>".png"}, "primary"=>true}], "verified"=>true, "stats"=>{"checkinsCount"=>7768, "usersCount"=>5027, "tipCount"=>121}, "url"=>"http://www.delicatessennyc.com", "specials"=>[{"id"=>"4df61ab03151247c51b0e9a9", "type"=>"regular", "message"=>"One complimentary Hostess Dessert Plate (trio of mini desserts, house-made cupcake, twinkie, cheesecake lollipop) with purchase of entree", "imageUrls"=>{"count"=>0}, "finePrint"=>"Excludes Weekend Brunch (Sat/Sun 10:30am-5pm) Unlocked: for checking in 3 times in 7 days", "icon"=>"frequency", "title"=>"Loyalty Special", "provider"=>"foursquare", "redemption"=>"standard"}], "hereNow"=>{"count"=>3}} Works as expected: ruby-1.6.5 :018 > FoursquareVenue.create(hsh2) => #<FoursquareVenue _id: 4ac4efbff964a520a79f20e3, _type: nil, version: 2, id: nil, name: "Delicatessen", contact: {"phone"=>"2122260211", "formattedPhone"=>"(212) 226-0211", "twitter"=>"DeliNYC"}, location: {"address"=>"54 Prince St", "crossStreet"=>"at Lafayette St", "lat"=>40.723691, "lng"=>-73.99641612, "distance"=>60, "postalCode"=>"10012", "city"=>"New York", "state"=>"NY", "country"=>"USA"}, categories: [{"id"=>"4bf58dd8d48988d14e941735", "name"=>"American Restaurant", "pluralName"=>"American Restaurants", "shortName"=>"American", "icon"=>{"prefix"=>"https://foursquare.com/img/categories/food/default_", "sizes"=>[32, 44, 64, 88, 256], "name"=>".png"}, "primary"=>true}], verified: true, stats: {"checkinsCount"=>7768, "usersCount"=>5027, "tipCount"=>121}, hereNow: {"count"=>3}, url: "http://www.delicatessennyc.com", specials: [{"id"=>"4df61ab03151247c51b0e9a9", "type"=>"regular", "message"=>"One complimentary Hostess Dessert Plate (trio of mini desserts, house-made cupcake, twinkie, cheesecake lollipop) with purchase of entree", "imageUrls"=>{"count"=>0}, "finePrint"=>"Excludes Weekend Brunch (Sat/Sun 10:30am-5pm) Unlocked: for checking in 3 times in 7 days", "icon"=>"frequency", "title"=>"Loyalty Special", "provider"=>"foursquare", "redemption"=>"standard"}]> -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email