jdaugherty opened a new pull request, #16690:
URL: https://github.com/apache/grails-core/pull/16690

   `grails-async-rxjava3` did not behave like the other promise factories for a 
promise of `null`. RxJava 3 forbids `null` in a stream, and the factory passed 
it straight in:
   
   | Call | Other factories | `grails-async-rxjava3` before |
   |---|---|---|
   | `createPromise()` | promise of `null` | `NullPointerException: item is 
null` |
   | `createPromise(String)` | promise of `null` | `NullPointerException: item 
is null` |
   | `createPromise { null }.get()` | `null` | the `java.lang.Void` class |
   | `onComplete([createBoundPromise(null)]) { .. }` | callback gets `[null]` | 
`NullPointerException: item is null` |
   
   `createPromise()` is what `Promises.createPromise()` and 
`WebPromises.createPromise()` call. The exceptions came from 
`Single.just(null)` and `Observable.just(null)` in `RxPromiseFactory`; 
`RxPromise.runCallable` turned `null` into the `Void` class as a sentinel, and 
nothing turned it back.
   
   ### Fix
   
   `RxPromise` carries `null` through the stream as a private sentinel and 
restores it wherever a value leaves the stream: `get()`, the value an 
`onComplete` callback receives, and the lists `onComplete`, `onError` and 
`waitAll` deliver. `runCallable` wraps instead of returning `Void`; the 
factory's `createPromise()`, `createPromise(Class)` and the bound-promise 
branch of `onComplete` wrap too; and `onComplete` and `onError` over a list 
share one helper, so `onError` accepts a `BoundPromise` as well.
   
   ### Tests
   
   `RxPromiseNullSpec` has one feature per row above plus chaining through 
`then { null }`, a `PromiseList` and `onError`. Against the previous code all 
six fail: the unbound and `onComplete` cases with `NullPointerException: item 
is null`, the chained case with `The mapper function returned a null value`, 
and the task, `waitAll` and `onError` cases with the `Void` class where `null` 
is expected. The existing `result == Void` assertion in `RxPromiseSpec` is now 
`result == null`.
   
   Found by @codeconsole while reviewing #16619, which deprecates the RxJava 1 
and 2 modules in favour of this one on `9.0.x` and carries this same change, so 
the merge-up is clean. `grails-async-rxjava2` has the same behaviour and is 
left alone.
   
   `:grails-async-rxjava3:test` and `:grails-async-rxjava3:codeStyle` pass on 
`7.0.x`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to