-
Notifications
You must be signed in to change notification settings - Fork 1.2k
HashOperations MultiGet Probably shouldn't return null elements in the collection #2309
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
Comments
Consider the following Redis key arrangement:
If you issue a command
If we would filter out absent elements, the resulting collection would look like: Does that make sense to you? In contrast to |
Yes that makes sense, however it feels clunky for two reasons. As mentioned calling I think one of the solutions is to add Another possible solution is to make |
Indeed, that isn't going to work. We could improve our documentation to mention that you should expect absent object markers in the form of |
Hi,
There was an issue raised a while ago which supported null values in the collection that is returned from the
ReactiveHashOperations multiGet
method. Whilst this fixes the original NPE, it creates other NPEs for clients using this code. For example, if the client code translates the returned collection to a Flux using Flux.fromIterable this will throw an NPE. When this happens the NPE that is throw is quite tricky to isolate as the stack trace that comes out often has no reference to the client code for example:There is a test which covers the returning of null values in the collection, which was created from the referenced issue. So I'm not sure if this behaviour is intentional.
I can't think of any good reason why we would want to return null in the collection (very happy to hear arguments in favour though). This behaviour is, I think, inconsistent with
get()
which would just return an empty publisher if a value wasn't found.If there is a reason for keeping null, then I think it might be worthwhile adding a method like
multiGetNotNull
which could return either a Flux or Mono<Collection so clients can avoid this behaviour.Happy to put in a PR if the general consensus is to do this.
Thanks
Shane
The text was updated successfully, but these errors were encountered: