-
Notifications
You must be signed in to change notification settings - Fork 419
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
Parameter specified as non-null is null #27
Comments
Thanks for testing the lib! I'll push sone updates asap. |
What result would you expect in that case? In both It's only this one case when the |
The |
From disconnect javadoc Does nothing if device was not connected. In this case, I'd expect the call to do nothing, since we are not connected. Does doing nothing also invoke fail? I'm not sure if that's what I'd expect, but I understand that you'd rather invoke one of the two, tho I find done is more appropriate in this case. First option would be to remove the @nonnull annotation from BluetoothDevice and set it to @nullable. That'd fix kotlin expectations, tho it's a breaking change that should be added to release notes. As a second, more complex approach, would you consider an approach similar to RxJava's Maybe? It either emits onSuccess, onError or onComplete From its javadoc: onSuccess, onError and onComplete are mutually exclusive events onComplete's name might be misleading and developers might think it's invoked after done, so maybe something like ignored or skipped I'd maybe go for the 1st approach. Adding a ignored callback means increasing the complexity of the library. Is there any usecase for such a callback? Regarding the BluetoothDevice as a parameter to BleManager, that'd also break the possibility connect to multiple devices with a single BleManager. I don't know how desirable that is or if people are using it that way. If it's not desirable to reuse a BleManager for multiple devices, then I'd definitely enforce it as a constructor parameter to avoid unexpected issues. Otherwise, I'd leave it as it. |
I've already started implementing RxJava approach also seems good, but that would break everything. Btw, how does the lib work with Kotlin? I tried to make it Kotlin-firendly, but actually never tried it with it. |
Thanks for the quick response! There are no differences when using it from kotlin, It's straightforward. The thing is, if a parameter is annotated as @nonnull BluetootDevice, kotlin's type is BluetoothDevice, whereas if it's @nullable the type is BluetoothDevice?, which is different from the non-question mark type. If a non-null parameter receives null, it's a runtime error because it's not of the type it expects. |
But there are those thing that make a library more Kotlin'y, like |
sorry I misunderstood your question I haven't found any issues, but I'm not that experienced with Kotlin I know of two interop guides, but I guess you already checked that https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html |
Ok, this issue should be fixed with the new PR. Would you like to have a look at it before I merge? |
I'm taking a look but I don't expect to be of help, it's a complex code |
Released in beta3. |
It's fixed, congrats and thanks!! |
The request that fails is
Scenario
The text was updated successfully, but these errors were encountered: