[JAVA-4908] Ensure no NPE is thrown with SerializedFluxSink Created: 13/Mar/23  Updated: 28/Oct/23  Resolved: 30/Mar/23

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

Type: Bug Priority: Major - P3
Reporter: Ross Lawley Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed
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   

From PR: https://github.com/mongodb/mongo-java-driver/pull/1096

Hi there,

We use Mongodb reactive stream driver with akka-stream and had an issue when trying to upgrade our mongodb driver from 4.1.x to 4.9.0. The same code which was working with 4.1.x does not work anymore with 4.9.0.
We tracked downed the issue and it's happening since the addition of reactor to this project.

The issue is that when performing a find/distinct which returns null values, when the results are used in a SerializedFluxSink a NullPointerException is thrown and everything stops. This is because SerializedFluxSink.next performs a call to Object.requireNonNull().

To fix this NPE we filter out null values from the results.

I'm not sure this is the appropriate way to test/fix, suggestions are welcome.
In the meantime we workaround this on our side by filtering out null values in the query.

Thanks



 Comments   
Comment by Githook User [ 31/Mar/23 ]

Author:

{'name': 'Clem', 'email': '716892+imclem@users.noreply.github.com', 'username': 'imclem'}

Message: Ensure no NPE is thrown with SerializedFluxSink (#1096)

When the FluxSink is an instance of SerializedFluxSink and the results
contains a null value, a NullPointerException is thrown and the whole process
stops. This is because SerializedFluxSink.next performs a call to
Object.requireNonNull().

To fix this issue we filter out null values from the results.

JAVA-4908
Branch: 4.9.x
https://github.com/mongodb/mongo-java-driver/commit/eff01da179401245c42ea9674fc0a1309994e93e

Comment by Ross Lawley [ 30/Mar/23 ]

This is a regression we previously did the same filtering in the AbstractSubscription.

Comment by Githook User [ 30/Mar/23 ]

Author:

{'name': 'Clem', 'email': '716892+imclem@users.noreply.github.com', 'username': 'imclem'}

Message: Ensure no NPE is thrown with SerializedFluxSink (#1096)

When the FluxSink is an instance of SerializedFluxSink and the results
contains a null value, a NullPointerException is thrown and the whole process
stops. This is because SerializedFluxSink.next performs a call to
Object.requireNonNull().

To fix this issue we filter out null values from the results.

JAVA-4908
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/960989021730cd97aa3c6aa6d3a45d05020fc858

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