Closed Mikey-Burns closed 6 years ago
Thanks for the report. The Rxified API is generated from the standard API. I guess the problem is that getRecord
result should be annotated with Nullable
. Then Vert.x Codegen would generate a Maybe
return instead of Single
. Can you confirm @cescoffier ?
@tsegismont Returning Maybe instead of Single would be even better. I was assuming that switching from Single to Maybe was unlikely, so this would be an improvement over the current state.
I think the issue exists in vertx-mongo-client as well, like:
MongoClient findOne(String collection, JsonObject query, @Nullable JsonObject fields, Handler<AsyncResult
> resultHandler);
The generated rx version is: Single<JsonObject> rxFindOne(String collection, JsonObject query, JsonObject fields)
, return as Maybe<JsonObject>
should be more appropriate because of same reason as above. :)
Can you file an issue on this project?
Thank you
One of the requirements in RxJava 2 is that you cannot emit
null
as a value anymore. However, methods such asio.vertx.reactivex.servicediscovery.ServiceDiscovery#rxGetRecord(Function)
emit null if they don't find a matching record, becauseAsyncResultSingle
directly returns the resulting value from the AsyncResult. This leads to weird behavior where the following test would failbecause the Single will emit null. However, if you uncomment the
.map(record -> record)
, it will throw an NPE because you cannot map anull
item in RxJava 2.I believe the solution is to modify AsyncResultSingle from this
to check for null
I can put up a PR for this if you agree that it's a valid fix.