[JAVA-5305] com.mongodb.MongoWriteException is not java.io.Serializable Created: 31/Jan/24  Updated: 05/Feb/24

Status: Waiting for Reporter
Project: Java Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Govind Balaji S Assignee: Jeffrey Yemin
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to JAVA-2131 Make all classes referenced by MongoE... Backlog
Assigned Teams:
Java Drivers
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

com.mongodb.MongoWriteException is not java.io.Serializable. This is because of com.mongodb.MongoWriteException#error of type `com.mongodb.WriteError` not implementing Serializable.

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

4.7.2 (Issue is present in latest master as well)

How to Reproduce

Try to serialize any exception chain containing MongoWriteException

Additional Background

-



 Comments   
Comment by Govind Balaji S [ 01/Feb/24 ]

Ah, I could not find the open ticket. The framework is internal, so I am able to workaround now by falling back to gson if java-serialization fails. I will pick this and audit soon.

Comment by Jeffrey Yemin [ 01/Feb/24 ]

Ah, interesting. Is is an open source framework or something internal? If open source, please drop a link.

An audit would be useful. Thanks.

By the way, this is already in the backlog with JAVA-2131.

Comment by Govind Balaji S [ 01/Feb/24 ]

I stumbled across this when an exception chain containing this could not make it across a grpc call. The framework I am using happens to use java-serialization for propagating exceptions. This looks fair enough since `java.lang.Exception implements Serializable` I can audit other exceptions as well and fix if that is okay.

Comment by Jeffrey Yemin [ 01/Feb/24 ]

govind.balaji@sprinklr.com why do you need this particular exception (or any exception) to be serializable? I'm not sure, but I have a feeling if we look deeper we will find many more that are not.

Comment by Govind Balaji S [ 01/Feb/24 ]

pr: https://github.com/mongodb/mongo-java-driver/pull/1302

Comment by Govind Balaji S [ 31/Jan/24 ]

This only needs a minor fix. Let me know if I can pick this, or if there is any reason for `WriteError` to remain non-Serializable

Comment by PM Bot [ 31/Jan/24 ]

Hi govind.balaji@sprinklr.com, thank you for reporting this issue! The team will look into it and get back to you soon.

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