-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.13.0
-
Component/s: Command Operations
-
None
When parsing out the error message of a response to creating a unique index, the message will be "errmsg" instead of "err".
Quick reproduction test case:
@Test public void createIndexErrorMessage() throws Exception { final MongoClient client = new MongoClient(); try { final DBCollection collection = client.getDB("test").getCollection("foo"); collection.drop(); collection.insert(new BasicDBObject("a", 1)); collection.insert(new BasicDBObject("a", 1)); collection.createIndex(new BasicDBObject("a", 1), new BasicDBObject("unique", true)); fail("should throw"); } catch (WriteConcernException e) { System.out.println(e.getCommandResult()); assertNotNull("didn't find error", e.getErrorMessage()); } finally { client.close(); } } // Output: // { "serverUsed" : "127.0.0.1:27017" , "ok" : 0.0 , "errmsg" : "E11000 duplicate key error index: test.foo.$a_1 dup key: { : 1 }" , "code" : 11000} // java.lang.AssertionError: didn't find error
Note this does not appear to affect 3.x Java driver versions.