mongodbjacksonobjectmappermongojack

JacksonDBDecoder - Server errors from MongoDB - mongojack 2.3.0


I have a problem when my application receives an error from MongoDB server, for example:

Imagine that I do a find in MongoDB but the response from MongoDB Server is an error because of a timeout:

{ $err: "MongoTimeout due to...bla bla bla..." code: 50 }

JacksonDBDecoder is expecting my Java type for example my class "Stuff" (that contains several fields like "price" and "weight"), but when it receives the previous JSON, then there is not any matching fields with "price" and "weight", so the outcome is empty: { }

The empty JSON will be processed by the mongo-java-driver classes (com.mongodb.QueryResultIterator.throwOnQueryFailure exactly) and it will never log the original information "MongoTimeout due to...bla bla bla..." and 50, because the decoder could not understand the JSON from MongoDB Server.

Could you help me to configure mongojack or Jackson to handle this types of responses from MongoDB Server?

Many thanks.

Regards, Paco.


Solution

  • After talking with MongoDB support, they confirmed to me the following:

    "The driver team read our last comments and they believe this is indeed a driver bug. Basically, they think the driver should detect that this is a query failure and use the default decoder to decode the error document rather than the custom decoder registered by MongoJack.

    The most relevant part is that this bug does not exist in the 3.x driver series. So our suggestion for you is to upgrade to the 3.2.2 driver (note that MongoJack lists the 3.2 Java driver as its preferred dependency: http://mongojack.org/dependencies.html)."

    So, it is not an mongojack issue ;)

    Regards, Paco.