Permalink
Browse files

fix UUID

  • Loading branch information...
1 parent 188fe8e commit 5b46514f65f5ef6343e6da7d076eb83d0544c32d @erh erh committed Jun 9, 2010
Showing with 10 additions and 9 deletions.
  1. +6 −6 src/main/org/bson/BSONDecoder.java
  2. +1 −1 src/main/org/bson/BSONEncoder.java
  3. +2 −1 src/test/com/mongodb/JavaClientTest.java
  4. +1 −1 test.sh
@@ -220,13 +220,13 @@ void _binary( String name )
_callback.gotBinaryArray( name , data );
return;
case B_UUID:
- if ( totalLen != 132 )
+ if ( totalLen != 16 )
throw new IllegalArgumentException( "bad data size subtype 3 len: " + totalLen + " != 16");
-
- long part1 = _in.readLong();
- long part2 = _in.readLong();
- _callback.gotUUID(name, part1, part2);
- return;
+
+ long part1 = _in.readLong();
+ long part2 = _in.readLong();
+ _callback.gotUUID(name, part1, part2);
+ return;
}
byte[] data = new byte[totalLen];
@@ -292,7 +292,7 @@ protected void putBinary( String name , Binary val ){
protected void putUUID( String name , UUID val ){
_put( BINARY , name );
- _buf.writeInt( 4 + 64*2);
+ _buf.writeInt( 16 );
_buf.write( B_UUID );
_buf.writeLong( val.getMostSignificantBits());
_buf.writeLong( val.getLeastSignificantBits());
@@ -188,11 +188,12 @@ public void testUUID()
throws MongoException {
DBCollection c = _db.getCollection( "testUUID" );
c.drop();
- c.save( BasicDBObjectBuilder.start().add( "a" , new UUID(1,2)).get() );
+ c.save( BasicDBObjectBuilder.start().add( "a" , new UUID(1,2)).add("x",5).get() );
DBObject out = c.findOne();
UUID b = (UUID)(out.get( "a" ) );
assertEquals( new UUID(1,2), b);
+ assertEquals( 5 , out.get("x" ) );
}
@Test
View
@@ -1,2 +1,2 @@
-ant && javac -cp build/main foo.java && java -cp build/main:build/test:. $1Test
+ant && javac -cp build/main foo.java && java -cp build/main:build/test:. -Xmx256m $1Test

0 comments on commit 5b46514

Please sign in to comment.