[JAVA-2533] Add type-safe way to detect max document size exceeded Created: 09/Jun/17 Updated: 29/Oct/23 Resolved: 12/Feb/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | BSON |
| Affects Version/s: | 3.4.2 |
| Fix Version/s: | 3.7.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Luke Prochazka | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Case: | (copied to CRM) |
| Description |
|
Add a type-safe way for applications to detect that a BSON document failed to serialize due to the maximum document size supported by MongoDB being exceeded. Possibilities include:
Original Description While catching an exception for the error "MaxDocumentSize exceeded...", per this ref, the errorCode is not populated. It would appear that the BsonSerializationException constructor only accepts strings, while its superclass BSONException can accept both string and a code (among its four constructors). Looking further at the source for BsonSerializationException, all it does is call super(message) and nothing else. |
| Comments |
| Comment by Ross Lawley [ 12/Feb/18 ] |
|
3.7.0 will introduce org.bson.BsonMaximumSizeExceededException to cover size exceeded exceptions. |
| Comment by Githook User [ 12/Feb/18 ] |
|
Author: {'email': 'ross.lawley@gmail.com', 'name': 'Ross Lawley', 'username': 'rozza'}Message: Added BsonMaximumSizeExceededException
|
| Comment by Ross Lawley [ 08/Feb/18 ] |
| Comment by Gabriel Ng [ 19/Jul/17 ] |
|
The previous exception message was not from the latest 3.4.2 java driver. Here is an example from the latest if it helps you find the related code: org.bson.BsonSerializationException: Document size of 17514051 is larger than maximum of 16777216. Hope this helps. It would be very nice to have some type of enum to track this error as we have already seen that the exception message changes in different versions of the java driver. |