Details
-
Bug
-
Resolution: Done
-
Minor - P4
-
2.5.2
-
None
-
None
-
any
-
Fully Compatible
Description
toString() on a DBObject with a UUID property fails since JSON.serialize(..) cannot handle UUID. This stacktrace is the result
java.lang.RuntimeException: json can't serialize type : class java.util.UUID
|
at com.mongodb.util.JSON.serialize(JSON.java:202)
|
at com.mongodb.util.JSON.serialize(JSON.java:109)
|
at com.mongodb.util.JSON.serialize(JSON.java:28)
|
at com.mongodb.BasicDBObject.toString(BasicDBObject.java:75)
|
Fix is pretty simple. We just have to add
if ( o instanceof UUID ){
|
UUID c = (UUID)o;
|
BasicDBObject temp = new BasicDBObject();
|
temp.put( "$uuid" , c.toString() );
|
serialize( temp, buf );
|
return;
|
}
|
to public static void serialize( Object o , StringBuilder buf ) in JSON and everything is fine. Please find attached fix and testcase.
Attachments
Issue Links
- is duplicated by
-
JAVA-321 Exception on calling "toString()" on query containing UUID
-
- Closed
-