RUBY-224 encode JRuby strings with byte[]

This commit is contained in:
Kyle Banker 2011-01-14 10:50:32 -05:00
parent 3d1934a92c
commit 016743b015
3 changed files with 9 additions and 6 deletions

View File

@ -26,7 +26,7 @@ namespace :build do
jar_dir = File.join(java_dir, 'jar')
jruby_jar = File.join(jar_dir, 'jruby.jar')
mongo_jar = File.join(jar_dir, 'mongo-2.2.jar')
mongo_jar = File.join(jar_dir, 'mongo-2.4.jar')
bson_jar = File.join(jar_dir, 'bson-2.2.jar')
src_base = File.join(java_dir, 'src')

Binary file not shown.

View File

@ -293,7 +293,7 @@ public class RubyBSONEncoder extends BSONEncoder {
else if ( val instanceof RubyObject ) {
if ( val instanceof RubyString ) {
putRubyString(name, ((RubyString)val).getUnicodeValue() );
putRubyString(name, (RubyString)val);
}
else if (val instanceof RubySymbol) {
@ -582,10 +582,13 @@ public class RubyBSONEncoder extends BSONEncoder {
_putString(name, s.getSymbol(), SYMBOL);
}
protected void putRubyString( String name , String s ) {
_put( STRING , name );
_putValueString( s );
}
protected void putRubyString( String name , RubyString s ) {
byte[] bytes = s.getBytes();
_put( STRING , name );
_buf.writeInt( bytes.length + 1);
_buf.write( bytes );
_buf.write( (byte)0 );
}
protected void putString(String name, String s) {
_putString(name, s, STRING);