[JAVA-4922] Error Code from WriteError not propagated to MongoServerException (3.12.x line) Created: 04/Apr/23  Updated: 06/Apr/23  Resolved: 05/Apr/23

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.12.9
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Gavin Line Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates JAVA-4219 Error Code from WriteError not propag... Closed
Problem/Incident
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

The MongoWriteException doesn't propagate down the error code to the MongoServerException which causes it to use the default value. This is a regression as it looks like version 3.12.8 does not have the same problem.

How to Reproduce

Any operation that throws a MongoWriteException (duplicate key for one) will throw an exception that does not contain the error code for the exception.

Additional Background

It looks like this was introduced on the 4.x line and was closed as part of JAVA-4219. Through the following PR.



 Comments   
Comment by Jeffrey Yemin [ 05/Apr/23 ]

Closing as a duplicate of JAVA-4219, and I'll re-open JAVA-4219 to consider whether to release a 3.12.x patch build that contains that fix.  

Normally we would not release a patch for the 3.12 driver three years after 4.0 was released, but we will consider an exception to that practice for this issue, as we kind of messed up by not backporting JAVA-4219 immediately.

Comment by Jeffrey Yemin [ 05/Apr/23 ]

This seems to have been caused by the backport of JAVA-3993 to the 3.12.x branch, and released in 3.12.9. But the subsequent change of JAVA-4219, which fixed a regression introduced by JAVA-3993, was not backported.

Generated at Thu Feb 08 09:03:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.