Skip to content

fix: ensure no NPE is thrown with SerializedFluxSink #1096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

imclem
Copy link
Contributor

@imclem imclem commented Mar 10, 2023

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

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.
@rozza
Copy link
Member

rozza commented Mar 17, 2023

Hi @imclem,

Apologies for the delay in response - I have opened a ticket for this and its scheduled for review: JAVA-4908

Ross

@imclem
Copy link
Contributor Author

imclem commented Mar 17, 2023

Thanks

Copy link
Member

@rozza rozza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rozza rozza merged commit 9609890 into mongodb:master Mar 30, 2023
@rozza
Copy link
Member

rozza commented Mar 30, 2023

Thanks @imclem for finding this and supplying the fix - merged :)

Will be released in the near future.

@imclem
Copy link
Contributor Author

imclem commented Mar 30, 2023

Thanks for merging

rozza pushed a commit that referenced this pull request Mar 31, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants