Reactor-core: Flux.map() and null-handling when wrapping existing blocking API's

Created on 12 May 2016  Â·  3Comments  Â·  Source: reactor/reactor-core

The only way to do this currently is via the use of flatMap and Mono.justOrEmpty() which isn't as efficient and causes more allocations/stack.

One option is to introduce something in Flux e.g. Flux.mapOrEmpty() that behaves the same as map but drops message and does request(1) when null is returned, but I understand this clutters the primary API where nulls simply are not allowed. So maybe an alternative is to implement something outside of Flux in something like LegacyUtils that can then somehow be pulled into and used in a Flux stream just in the cases where you need to deal with legacy API's that throw exceptions/return null.

This is somewhat related to: https://github.com/reactor/reactor-core/issues/80

typenhancement

Most helpful comment

Hello, will mapOrFilter be also available for Mono ?
The base issue is the same, if you want to map on a nullable property, you have to do a filter() and map() or a flatMap(Mono.justOrEmpty())

Thank you

All 3 comments

Hello, will mapOrFilter be also available for Mono ?
The base issue is the same, if you want to map on a nullable property, you have to do a filter() and map() or a flatMap(Mono.justOrEmpty())

Thank you

@lcor1979 mapOrFilter has been replaced by handle back in 3.0.0.RELEASE, so use handle instead.

Ok perfect, thank you.

Le mer. 9 mai 2018 à 14:40, Simon Baslé notifications@github.com a écrit :

@lcor1979 https://github.com/lcor1979 mapOrFilter has been replaced by
handle back in 3.0.0.RELEASE, so use handle instead.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/reactor/reactor-core/issues/86#issuecomment-387725227,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AS2zo1FBwrHeuS624xD6VNh4cRA_qoqiks5twuPZgaJpZM4IdKpX
.

Was this page helpful?
0 / 5 - 0 ratings