You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "jdaugherty (via GitHub)" <gi...@apache.org> on 2026/10/12 10:50:49 UTC
[PR] Deprecate the RxJava 1 and RxJava 2 promise factories for removal [grails-core]
jdaugherty opened a new pull request, #16619:
URL: https://github.com/apache/grails-core/pull/16619
RxJava 1 and RxJava 2 are no longer maintained. This deprecates the `grails-async-rxjava` and `grails-async-rxjava2` modules for removal since Grails 8.1 and keeps `grails-async-rxjava3` as the supported implementation.
### Changes
- `RxPromiseFactory` and `RxPromise` in both modules are annotated `@Deprecated(since = '8.1', forRemoval = true)`, with `@deprecated` javadoc naming `grails-async-rxjava3` as the replacement.
- Both factories log a warning when they are created, so an application that still ships either module sees it at startup.
- New `RxPromiseFactoryDeprecationSpec` in each module verifies the annotation, the warning, and that the service-loaded factory still produces working promises. The test runtime switches from `slf4j-nop` to `logback-classic` so the warning can be captured.
- The promise factory table in the Promises chapter marks the RxJava 1 and 2 rows as deprecated with a warning admonition, and What's New gets an "RxJava 1 and RxJava 2 Promise Factories Deprecated" section.
No behaviour of the deprecated modules changes.
### Not included
- `grails-events-rxjava` and `grails-events-rxjava2` are left as they are; they can follow separately.
- The `rx-mongodb` profile feature still references `grails-async-rxjava`, since RxGORM for MongoDB is itself RxJava 1 based.
### Verification
- `./gradlew :grails-async-rxjava:test :grails-async-rxjava2:test :grails-async-rxjava:codeStyle :grails-async-rxjava2:codeStyle` passes locally.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6258626590
Thanks — this was a thorough review and every point was actionable. `9.0.x` is merged (all 14 conflicts resolved) and all six items plus the smaller ones are addressed. Details below, grouped as you numbered them.
## 1. The rebase
Merged `9.0.x`. The four conflicts that needed more than keeping both sides:
- **`upgrading90x.adoc`** is now one page: the skill TIP, then `1. Groovy 6`, `2. GPars Integration Deprecated in Favour of Groovy Concurrency`, `3. Groovy Code Is Compiled with invokedynamic`, `4. grails.converters.JSON ...`, `5. Domain Classes Can Render Through a Jackson Serializer`, `6. RxGORM Runs on RxJava 3`, `7. RxJava 1 and RxJava 2 ... Deprecated`. I kept your relative ordering (Groovy 6 → GPars → RxGORM → RxJava deprecation) and left the three sections `9.0.x` already had in their existing order, so the renumbering is a shift of one rather than a reshuffle. The GPars section no longer opens by re-announcing the Groovy 6 baseline, since section 1 now does that.
- **The `grails-9-upgrade` skill** gained the GPars material — a section with the one-for-one dependency replacement, the `CompletableFuture` failure contract the Groovy factory follows, the actor delivery semantics, a `GParsPool`/`GParsConfig` → `groovy.concurrent` table, checklist items (no `grails-async-gpars`/`grails-events-gpars`, no `groovyx.gpars` import, no `GParsPool.withPool` or `GParsConfig`) and a pitfall about keeping both modules. Your argument applies equally to the other two sections `9.0.x` added, so I also gave it `Groovy Code Compiles with invokedynamic` (the `grails.indy` property, `groovy-callsite` per source set, the GraalVM constraint, the `testcontainers-spock` case) and `JSON Rendering Can Use Spring Boot's JsonMapper` (the `legacy` setting, the values that change, marshaller precedence, `JSONWriter` subclassing, `DomainClassSerializer`). The `description` and the workflow steps cover all of it now.
- **`asyncServerSentEvents.adoc`** stays deleted, and `rxjava.adoc` picks up the pointer. "RxJava Results from Controllers" now leads with the fact that an RxJava 3 `Flowable` *is* a `Publisher`, shows an action returning `observable.toFlowable(BackpressureStrategy.BUFFER)` and links `<<asyncStreaming,Streaming Responses>>`, then says plainly that `Observable` and `Single` are not `Publisher`s and must be converted. The NOTE no longer claims the plugin was needed for that, and it names both `org.grails.plugins:rxjava` and `org.grails.plugins:rxjava2`.
I also corrected `asyncStreaming.adoc`. You're right that `PublisherActionResultTransformer` gates on `actionResult instanceof Publisher` (line 82) before `isSingleValue` ever consults the `ReactiveAdapterRegistry`, so the RxJava `Single` example was wrong. That line now names only `Mono` and a `CompletableFuture` adapted to one, and a following paragraph says a non-`Publisher` result is left alone, and that a `Flowable` is multi-valued whatever it emits — so a one-item `Flowable` streams as a single event rather than resolving.
- **The tables and `asyncConfigure.adoc`** now match the GPars style. The RxJava rows in `asyncPromises.adoc` read "(deprecated, see below)" like the GPars row, and the two `WARNING` blocks are gone, replaced by a prose paragraph next to the GPars paragraph in each of `asyncPromises.adoc` and `events.adoc`. The `asyncConfigure.adoc` TIP is merged: RxJava 3 first, then the Groovy actor bus through `Awaitable.setExecutor`, then the deprecated GPars bus, then the deprecated RxJava 1 and 2 buses.
The skill-registration conflicts kept both `grails-ai-developer` and `grails-9-upgrade`.
## 2. `insert()` mapping to `null`
Fixed — `insert()` uses the same `flatMap` with `Observable.empty()` that `persist()` does, so both complete empty. Three tests in `AbstractRxDatastoreClientSpec`: the empty path of each, and the non-empty path of `insert()` for symmetry with the existing `persist()` ones. The two empty-path tests fail on the old code, so they pin the fix rather than just describing it.
On the wording: you're right that the old example described a case that actually emits. `upgrading90x.adoc` now reads "`save()` and `insert()` complete empty, instead of emitting `null`, when the datastore reports no identifier for the instance", which is the condition the code actually tests.
## 3. The IO scheduler
I kept `observeOn` and fixed the docs, rather than switching to `subscribeOn`. The reason is the one your probe implies but doesn't force: `RxServiceSupport` does no session or transaction propagation. Asynchronous GORM wraps its work in a new session precisely because it moves the call to another thread; `subscribeOn` here would move a blocking GORM call to an IO thread with no bound Hibernate session and nothing the tenant resolver reads from the request, so a working-if-pointless feature would become a broken one, silently, inside a port. That's worth its own change with session propagation, a thread-asserting test and an upgrade-guide entry — I'd rather not smuggle it in here. Happy to file it.
So the docs now say what the code does, in all the places you listed and a couple more:
- `rxjava.adoc:48` — the query runs on the subscribing thread and the result is delivered on the IO scheduler.
- `rxjava.adoc:71` — `@RxSchedule` "selects the scheduler a method delivers its result on", with an explicit sentence that neither it nor the default moves the query off the subscribing thread, and a pointer to subscribing from a task.
- `rxServices.adoc:54` in both Hibernate guides, and the "run the operation on a different scheduler" line below it.
- The javadocs on `RxServiceSupport` (class and all four methods) and `RxScheduleIOTransformation`, plus the `@RxSchedule` annotation javadoc, which made the same claim.
- `asyncRxGorm.adoc`, which compared the data services to Asynchronous GORM "isolating blocking operations on a separate thread" — now says they do *not* do that, unlike Asynchronous GORM.
And the thread is now tested, both ways, with `Schedulers.from(executor)` and a named thread factory: `create` and `createSingle` each assert the callable ran on the subscriber's thread and the emission arrived on `rx-delivery` / `rx-single-delivery`. If the behaviour is ever changed to `subscribeOn`, those two tests are what fails.
## 4. The `rx-mongodb` feature
Removed in this PR — `feature.yml`, its skeleton, and the feature from the six profile pages that listed it. An application generated with it could never resolve `org.grails.plugins:rx-mongodb`, so it seemed worse to ship 9.0 with it than to take it out here, especially as this PR was editing it. `upgrading90x.adoc` and the skill now say the feature is removed and why, instead of presenting it as usable.
## 5. Doc pages contradicting the description
- `introduction.adoc:28` rewritten: no `RxEntity` datastore implementation ships, RxGORM for MongoDB was last released for GORM 6.1 on RxJava 1, Hibernate cannot provide one, use the RxJava data services.
- `agentSkills.adoc` — the heading is "Applications on the Previous Major Version" and the line below the example says "Once the application is on Grails 9".
- `rxjava.adoc:83-90` — the example is now `respond bookService.findAllByTitle(title).firstElement().blockingGet()`, which gives `null` for a missing title and so a 404; I added `findAllByTitle` to the service interface above it so the example resolves, and said in the prose why `firstElement()` rather than the `Single`.
## 6. Tests for the new behaviour
All four gaps covered; `:grails-datamapping-rx:test` is 514 (was 503) and `RxServiceImplSpec` 9 (was 7), all passing.
- `createSingle` with a `null` result → `NoSuchElementException`, both as a unit test in `RxServiceSupportSpec` and end to end in `RxServiceImplSpec` via `findOne('Missing')`, plus the `Observable` counterpart asserting an empty completion and that `firstElement().blockingGet()` is `null`.
- The empty paths of `persist()` and `insert()` (see 2).
- `ObservableSource` composition, since What's New and the guide advertise it: `Observable.wrap(criteria)` and `concatWith(criteria)` in `DetachedCriteriaSpec`, the same pair against a real proxy in `RxJavassistProxyFactorySpec`, and both operators against a lazy `RxPersistentSet` — that last one without any blocking initialization, which is the point.
- The thread the callable runs on (see 3).
## Smaller items
- **Warning logged per instance** — both promise factories and both event buses now use a `private static final AtomicBoolean DEPRECATION_LOGGED` with `compareAndSet`, matching `GparsPromiseFactory`. Each spec resets the latch in `setup()` so the existing `appender.list.size() == 1` assertions still mean something, and each gained a feature that constructs three instances and asserts exactly one warning — which is the behaviour you asked for, so it's pinned rather than implied. All four module suites pass.
- **`whereQueries.adoc:32-43`** — the example is `.findAll().subscribe { ... }`, and a NOTE explains that a closure cannot be subscribed to an `ObservableSource` because `Observer` has four methods. The paragraph above now describes the criteria as an `ObservableSource` that composes, which is the accurate claim.
- **`IdQueryObservableProxyMethodHandler.java:77`** — branch dropped, with a comment noting that RxJava 3 never emits `null` so the function isn't called at all for an empty query.
- **`SKILL.md:111`** — reworded: declare `Observable` and use `firstElement()`, which gives a `Maybe` whose `blockingGet()` returns `null` when empty; and it now says outright that `Maybe` is not yet recognised as a data service return type, so the follow-up you suggest is visible.
- **`rxjava.adoc:93`** — names both plugins.
## On #16621
The plan is both in 9.0, this PR first and the removal as a follow-up on `9.0.x` — which is what #16621 itself proposes, since the RxJava 3 port is what keeps the data services working after `RxEntity` goes.
That makes your concern a real one, so I demoted the `RxEntity`-specific advertising. What's New is now "RxJava Data Services on RxJava 3": it leads with the data services over any GORM datastore, and says in one sentence that the `RxEntity` model is ported but has no datastore behind it and is proposed for removal in 9.0. The `ObservableSource` composition is no longer sold as a 9.0 feature there. I kept it in the upgrade guide, where it's a migration note for someone porting code rather than an advertisement, and added a line there and in `asyncRxGorm.adoc` saying the removal is under discussion and that an `RxEntity` application should plan to move to `GormEntity` with the data services.
Rerun of your probes welcome — in particular the `insert()` one and the two thread assertions.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty merged PR #16619:
URL: https://github.com/apache/grails-core/pull/16619
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6346537399
## 🔎 No tests executed 🔎
🏷️ Commit: 0b45bd2b68531fa7773c6aea6f8ff2ecde74a1f6
▶️ Tests: 0 executed
⚪️ Checks: 47/47 completed
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6298034607
FYI: I opened https://github.com/apache/grails-core/pull/16693 to address the Observable return type issue.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6125948984
## ✅ All tests passed ✅
🏷️ Commit: 8af474963576322809e55688a94fa77a69eee2ab
▶️ Tests: 87030 executed
⚪️ Checks: 89/89 completed
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6124103485
## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16619?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `90.27778%` with `7 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 60.8410%. Comparing base ([`72bfff2`](https://app.codecov.io/gh/apache/grails-core/commit/72bfff21fcc5ea49f4f15c51890e9d32154c4e18?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8af4749`](https://app.codecov.io/gh/apache/grails-core/commit/8af474963576322809e55688a94fa77a69eee2ab?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/grails-core/pull/16619?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...s/gorm/rx/services/support/RxServiceSupport.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fgorm%2Frx%2Fservices%2Fsupport%2FRxServiceSupport.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2dvcm0vcngvc2VydmljZXMvc3VwcG9ydC9SeFNlcnZpY2VTdXBwb3J0Lmdyb292eQ==) | 83.3333% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ails/datastore/rx/AbstractRxDatastoreClient.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Frx%2FAbstractRxDatastoreClient.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2RhdGFzdG9yZS9yeC9BYnN0cmFjdFJ4RGF0YXN0b3JlQ2xpZW50Lmdyb292eQ==) | 66.6667% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../rx/proxy/IdQueryObservableProxyMethodHandler.java](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Frx%2Fproxy%2FIdQueryObservableProxyMethodHandler.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2RhdGFzdG9yZS9yeC9wcm94eS9JZFF1ZXJ5T2JzZXJ2YWJsZVByb3h5TWV0aG9kSGFuZGxlci5qYXZh) | 75.0000% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...grails/gorm/rx/finders/RxSingleResultFinder.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fgorm%2Frx%2Ffinders%2FRxSingleResultFinder.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2dvcm0vcngvZmluZGVycy9SeFNpbmdsZVJlc3VsdEZpbmRlci5ncm9vdnk=) | 92.8571% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../groovy/org/grails/events/rxjava/RxEventBus.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-events%2Frxjava%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fevents%2Frxjava%2FRxEventBus.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWV2ZW50cy9yeGphdmEvc3JjL21haW4vZ3Jvb3Z5L29yZy9ncmFpbHMvZXZlbnRzL3J4amF2YS9SeEV2ZW50QnVzLmdyb292eQ==) | 0.0000% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...groovy/org/grails/events/rxjava2/RxEventBus.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-events%2Frxjava2%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fevents%2Frxjava2%2FRxEventBus.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWV2ZW50cy9yeGphdmEyL3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2V2ZW50cy9yeGphdmEyL1J4RXZlbnRCdXMuZ3Jvb3Z5) | 0.0000% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## 9.0.x #16619 +/- ##
==================================================
- Coverage 60.8453% 60.8410% -0.0042%
- Complexity 26368 26373 +5
==================================================
Files 2226 2226
Lines 110970 110958 -12
Branches 20095 20096 +1
==================================================
- Hits 67520 67508 -12
+ Misses 34536 34535 -1
- Partials 8914 8915 +1
```
| [Files with missing lines](https://app.codecov.io/gh/apache/grails-core/pull/16619?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...y/org/grails/async/factory/rxjava/RxPromise.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-async%2Frxjava%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fasync%2Ffactory%2Frxjava%2FRxPromise.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWFzeW5jL3J4amF2YS9zcmMvbWFpbi9ncm9vdnkvb3JnL2dyYWlscy9hc3luYy9mYWN0b3J5L3J4amF2YS9SeFByb21pc2UuZ3Jvb3Z5) | `70.2703% <ø> (ø)` | |
| [...rails/async/factory/rxjava/RxPromiseFactory.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-async%2Frxjava%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fasync%2Ffactory%2Frxjava%2FRxPromiseFactory.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWFzeW5jL3J4amF2YS9zcmMvbWFpbi9ncm9vdnkvb3JnL2dyYWlscy9hc3luYy9mYWN0b3J5L3J4amF2YS9SeFByb21pc2VGYWN0b3J5Lmdyb292eQ==) | `76.1905% <100.0000%> (+5.6022%)` | :arrow_up: |
| [.../org/grails/async/factory/rxjava2/RxPromise.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-async%2Frxjava2%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fasync%2Ffactory%2Frxjava2%2FRxPromise.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWFzeW5jL3J4amF2YTIvc3JjL21haW4vZ3Jvb3Z5L29yZy9ncmFpbHMvYXN5bmMvZmFjdG9yeS9yeGphdmEyL1J4UHJvbWlzZS5ncm9vdnk=) | `77.0833% <ø> (ø)` | |
| [...ails/async/factory/rxjava2/RxPromiseFactory.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-async%2Frxjava2%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fasync%2Ffactory%2Frxjava2%2FRxPromiseFactory.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWFzeW5jL3J4amF2YTIvc3JjL21haW4vZ3Jvb3Z5L29yZy9ncmFpbHMvYXN5bmMvZmFjdG9yeS9yeGphdmEyL1J4UHJvbWlzZUZhY3RvcnkuZ3Jvb3Z5) | `76.1905% <100.0000%> (+5.6022%)` | :arrow_up: |
| [.../main/groovy/grails/gorm/rx/CriteriaBuilder.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fgorm%2Frx%2FCriteriaBuilder.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9ncmFpbHMvZ29ybS9yeC9Dcml0ZXJpYUJ1aWxkZXIuZ3Jvb3Z5) | `96.6667% <100.0000%> (ø)` | |
| [...main/groovy/grails/gorm/rx/DetachedCriteria.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fgorm%2Frx%2FDetachedCriteria.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9ncmFpbHMvZ29ybS9yeC9EZXRhY2hlZENyaXRlcmlhLmdyb292eQ==) | `99.3197% <100.0000%> (+0.0047%)` | :arrow_up: |
| [...-rx/src/main/groovy/grails/gorm/rx/RxEntity.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fgorm%2Frx%2FRxEntity.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9ncmFpbHMvZ29ybS9yeC9SeEVudGl0eS5ncm9vdnk=) | `0.0000% <ø> (-50.0000%)` | :arrow_down: |
| [...ls/datastore/rx/collection/RxPersistentList.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Frx%2Fcollection%2FRxPersistentList.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2RhdGFzdG9yZS9yeC9jb2xsZWN0aW9uL1J4UGVyc2lzdGVudExpc3QuZ3Jvb3Z5) | `89.1892% <100.0000%> (ø)` | |
| [...ils/datastore/rx/collection/RxPersistentSet.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Frx%2Fcollection%2FRxPersistentSet.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2RhdGFzdG9yZS9yeC9jb2xsZWN0aW9uL1J4UGVyc2lzdGVudFNldC5ncm9vdnk=) | `97.6744% <100.0000%> (ø)` | |
| [...tastore/rx/collection/RxPersistentSortedSet.groovy](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree&filepath=grails-datamapping-rx%2Fsrc%2Fmain%2Fgroovy%2Forg%2Fgrails%2Fdatastore%2Frx%2Fcollection%2FRxPersistentSortedSet.groovy&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Z3JhaWxzLWRhdGFtYXBwaW5nLXJ4L3NyYy9tYWluL2dyb292eS9vcmcvZ3JhaWxzL2RhdGFzdG9yZS9yeC9jb2xsZWN0aW9uL1J4UGVyc2lzdGVudFNvcnRlZFNldC5ncm9vdnk=) | `98.0392% <100.0000%> (+0.0392%)` | :arrow_up: |
| ... and [19 more](https://app.codecov.io/gh/apache/grails-core/pull/16619?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
... and [1 file with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16619/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6367444376
@matrei I'm going to merge this since all of the feedback is addressed. let's open a subsequent PR if you disagree with anything.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6297039681
Thanks, all seven threads and the five items outside the diff are addressed at e25fecc45e.
**`null` through `grails-async-rxjava3`.** Fixed in the module itself rather than documented as a difference, since it is the module the deprecation sends everyone to. `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`, and the factory's `createPromise()`, `createPromise(Class)` and the bound-promise branch of `onComplete` wrap too. `RxPromiseNullSpec` has one feature per row of your table plus chaining through `then { null }`, a `PromiseList` and `onError`; run against the previous code all six fail: the unbound and `onComplete` cases with `NullPointerException: item is null` from `Single.just`/`Observable.just`, the chained case with `The mapper function returned a null value`, and the task, `waitAll` and `onError` cases with the `java.lang.Void` clas
s where `null` is expected. The existing `result == Void` assertion in `RxPromiseSpec` is now `result == null`. The upgrade guide, What's New, the Promises page and the skill say what changed and that the RxJava 2 factory keeps the old behaviour.
**`findAll().toList()`.** Reworded: the methods that keep `Observable<List<T>>` are the static `list()`, `toList()` and `list()` on a `DetachedCriteria`, and `toListObservable()`; `findAll().toList()` is RxJava's own and gives a `Single<List<T>>`.
**The `Flowable` example.** Took the smaller change. The page now says Grails subscribes on the request thread, so the data service runs its query there before the action returns, and only the delivery and the writes happen on the IO scheduler; the "container thread released while the stream produces" clause is gone from the paragraph above, and a sentence says that `subscribeOn(..)` would need a session on that thread, which the data services do not set up.
**Non-`Publisher` results.** "Grails neither streams it nor renders a view for it, and the response holds only what the action rendered itself", as you traced through `UrlMappingsInfoHandlerAdapter`.
**What's New heading.** Blank line added; the section is back in the TOC in the built guide.
**Deprecation specs.** All four pin the module in parentheses, `(grails-async-rxjava)` and so on, so a copied message fails. The two promise-factory specs check `RxPromise` as well as the factory, in the `GparsPromiseSpec` style, and their service-loaded feature builds through `PromiseFactoryBuilder.build()` and asserts the single warning, as the events specs do with `EventBusBuilder`.
**Skill.** The `RxPromise.toObservable()` example is replaced by the `rx.Scheduler` given to the `RxEventBus` constructor, which an application can name, and the "no code change" bullet now states the `null` behaviour of the RxJava 3 factory and what the RxJava 2 one does instead.
Outside the diff: the RxGORM guide's installation page now names `grails-datamapping-rx` and explains that no `RxEntity` datastore ships; the two lazy-loading examples subscribe through `toObservable()` and `toListObservable()`; the events page says "for RxJava 3"; the `gradle-developer` skill table has the `grails-9-upgrade` row; the PR description is rewritten for the current content.
On the `Observable<String>` projection: `Observable` methods are adapted from the iterable implementers (`ObservableResultAdapter` wraps an `IterableServiceImplementer`), so a scalar projection is cast to an `Iterable`. Not in this PR, since it fails the same way on `9.0.x`; happy to take it as a follow-up issue.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#discussion_r4337336872
##########
grails-async/rxjava3/src/main/groovy/org/grails/async/factory/rxjava3/RxPromiseFactory.groovy:
##########
@@ -76,24 +76,27 @@ class RxPromiseFactory extends AbstractPromiseFactory {
@Override
<T> Promise<T> onComplete(List<Promise<T>> promises, Closure<T> callable) {
- new RxPromise<T>(this, Observable.concat(
- promises.collect { Promise p ->
- if (p instanceof BoundPromise) {
- return Observable.just(((BoundPromise) p).value) as Observable<T>
- }
- else {
- return ((RxPromise) p).toObservable() as Observable<T>
- }
- }
- ).toList())
- .onComplete(callable)
+ new RxPromise<T>(this, values(promises)).onComplete(callable)
}
@Override
<T> Promise<List<T>> onError(List<Promise<T>> promises, Closure<?> callable) {
- new RxPromise(this, Observable.concat(
- promises.collect { ((RxPromise<T>) it).toObservable() }
- ).toList())
- .onError(callable) as Promise<List<T>>
+ new RxPromise(this, values(promises)).onError(callable) as Promise<List<T>>
+ }
+
+ /**
+ * Concatenates the values of the given promises into one list, in order, with a {@code null} value restored
+ * from the sentinel it travels through the stream as.
+ */
+ private static <T> Single<List<T>> values(List<Promise<T>> promises) {
+ List<Observable<T>> sources = promises.collect { Promise<T> p ->
+ if (p instanceof BoundPromise) {
+ return Observable.just(RxPromise.wrap(((BoundPromise) p).value)) as Observable<T>
+ }
+ return ((RxPromise<T>) p).toObservable()
Review Comment:
Fixed in d006362dd6. Rather than reading `subject` in `values()`, `toObservable()` itself returns the subject now, so nothing but the constructor subscribes to the source; the class is package-scoped and `values()` is the method's only caller. The constructor's observer calls `subject.onComplete()` after `finished = true`.
Your four features are in: three in `RxPromiseListSpec` and the `then` one in `RxPromiseSpec`. All four failed before the change (`[2]`, `[2]`, a `TimeoutException`, and `done` still `false`), and `:grails-async-rxjava3:test` (24 tests) and `codeStyle` pass with it. The same commit is on #16690 (592e8d95fc), so the merge-up stays clean.
##########
grails-doc/src/en/guide/async/rxjava.adoc:
##########
@@ -17,23 +17,100 @@ specific language governing permissions and limitations
under the License.
////
-Since Grails 3.2, you can use https://github.com/ReactiveX/RxJava[RxJava] to write reactive logic in your Grails controllers that leverages the underlying containers asynchronous processing capabilities.
+Grails integrates https://github.com/ReactiveX/RxJava[RxJava] 3 at three points. Each is a separate module that an application adds to `build.gradle`; Grails itself does not depend on RxJava.
-To get started simply declare a dependency on the plugin in `build.gradle`:
+==== Promises on RxJava
+
+`grails-async-rxjava3` provides a `grails.async.PromiseFactory` backed by RxJava 3, so every `Promise` the application creates is an RxJava subscription:
+
+[source,groovy]
+.build.gradle
+----
+runtimeOnly 'org.apache.grails.async:grails-async-rxjava3'
+----
+
+See <<asyncPromises,Promises>>.
+
+==== Events on RxJava
+
+`grails-events-rxjava3` provides an `EventBus` that delivers events through RxJava 3 subjects and schedulers:
[source,groovy]
.build.gradle
----
-dependencies {
- //...
- implementation 'org.apache.grails:grails-rxjava3'
+runtimeOnly 'org.apache.grails.events:grails-events-rxjava3'
+----
+
+See <<events,Events>>.
+
+==== RxJava Data Services
+
+With `grails-datamapping-rx` on the classpath, a GORM data service can declare methods that return `io.reactivex.rxjava3.core.Observable` or `io.reactivex.rxjava3.core.Single`. GORM implements the method as it does any other data service method: the blocking query runs when the result is subscribed to, on the subscribing thread, and the result is delivered on RxJava's IO scheduler, so the caller consumes it reactively without the datastore itself being non-blocking:
+
+[source,groovy]
+.build.gradle
+----
+implementation 'org.apache.grails.data:grails-datamapping-rx'
+----
+
+[source,groovy]
+----
+import grails.gorm.services.Service
+import io.reactivex.rxjava3.core.Observable
+import io.reactivex.rxjava3.core.Single
+
+@Service(Book)
+interface BookService {
+
+ Single<Book> findOne(String title)
+
+ Observable<Book> findAllByTitle(String title)
+
+ Observable<Book> findAllByAuthor(String author)
+}
+----
+
+A `Single` that finds nothing signals a `java.util.NoSuchElementException`, since an RxJava 3 `Single` cannot complete without a value; an `Observable` that finds nothing completes without emitting. The `grails.gorm.rx.services.RxSchedule` annotation selects the scheduler a method delivers its result on. Neither it nor the default moves the query itself off the subscribing thread, so subscribe from a task, as <<asyncRequests,Asynchronous Request Handling>> describes, to keep a blocking query off a request thread. See the RxJava Support section of the GORM for link:{hibernate7Guide}index.html#dataServicesRxJava[Hibernate 7] or link:{hibernate5Guide}index.html#dataServicesRxJava[Hibernate 5] guide.
+
+==== RxJava Results from Controllers
+
+An RxJava 3 `Flowable` is a Reactive Streams `Publisher`, so an action can return one and Grails streams every item it emits to the client as a server-sent event, with no plugin. See <<asyncStreaming,Streaming Responses>>:
+
+[source,groovy]
+----
+import io.reactivex.rxjava3.core.BackpressureStrategy
+
+class BookController {
+
+ BookService bookService
+
+ def feed(String author) {
+ bookService.findAllByAuthor(author)
+ .toFlowable(BackpressureStrategy.BUFFER)
+ }
}
----
-You can then return `rx.Observable` as a return value from any controller and Grails will automatically apply the following steps:
+Grails subscribes to the publisher on the request thread, so in this example the data service runs its query there, before the action returns, as the previous section describes; the items are then delivered on the IO scheduler and written to the response from it, with the container thread released while they are. Running the query itself on another thread with `subscribeOn(..)` needs a session on that thread, which the data services do not set up.
Review Comment:
Agreed, and it matches the transform: the `@Transactional` body is woven inside the deferred callable, so `subscribeOn(..)` moves the transaction along with the query. Reworded close to your suggestion in d006362dd6.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6324097561
## 🚨 All tests passed but jobs failed 🚨
### Failed Jobs without Test Failures
❌ [CI / Build Grails Forge \(Java 25, indy\=false\)](https://github.com/apache/grails-core/actions/runs/39654879925/job/119417335599?pr=16619)
🏷️ Commit: ee2d525fbf1de456658fb981d718e9002cd63e0b
▶️ Tests: 2909 executed
🟡 Checks: 18/86 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#discussion_r4340586125
##########
grails-async/rxjava3/src/main/groovy/org/grails/async/factory/rxjava3/RxPromiseFactory.groovy:
##########
@@ -76,24 +76,27 @@ class RxPromiseFactory extends AbstractPromiseFactory {
@Override
<T> Promise<T> onComplete(List<Promise<T>> promises, Closure<T> callable) {
- new RxPromise<T>(this, Observable.concat(
- promises.collect { Promise p ->
- if (p instanceof BoundPromise) {
- return Observable.just(((BoundPromise) p).value) as Observable<T>
- }
- else {
- return ((RxPromise) p).toObservable() as Observable<T>
- }
- }
- ).toList())
- .onComplete(callable)
+ new RxPromise<T>(this, values(promises)).onComplete(callable)
}
@Override
<T> Promise<List<T>> onError(List<Promise<T>> promises, Closure<?> callable) {
- new RxPromise(this, Observable.concat(
- promises.collect { ((RxPromise<T>) it).toObservable() }
- ).toList())
- .onError(callable) as Promise<List<T>>
+ new RxPromise(this, values(promises)).onError(callable) as Promise<List<T>>
+ }
+
+ /**
+ * Concatenates the values of the given promises into one list, in order, with a {@code null} value restored
+ * from the sentinel it travels through the stream as.
+ */
+ private static <T> Single<List<T>> values(List<Promise<T>> promises) {
+ List<Observable<T>> sources = promises.collect { Promise<T> p ->
+ if (p instanceof BoundPromise) {
+ return Observable.just(RxPromise.wrap(((BoundPromise) p).value)) as Observable<T>
Review Comment:
Fixed in cf6726ed2b, the same change as #16690 at 2497f4de9c: the bound branch of `values()` reads the promise through `get()` (`Observable.fromCallable { RxPromise.wrap(p.get()) }`), so a failure a `then()` callback stored fails the aggregate `get()`, reaches the list `onError` callback with the original exception and skips the list `onComplete` callback, as `waitAll` already did. The two regressions are in `RxPromiseListSpec` (`onError over a list reports the failure a bound promise holds`, `onComplete over a list skips its callback when a bound promise holds a failure`); the null-value and single-execution features are unchanged. The rxjava3 sources and specs are byte-identical to #16690 again, and `:grails-async-rxjava3:test` passes 26/26.
ee2d525fbf merges `9.0.x` back in. The one conflict was `upgrading90x.adoc`, which gained sections 3-15 upstream: Groovy 6 stays section 1, the RxGORM and RxJava deprecation sections are now 17 and 18, and the page's "see section N" references are shifted to match.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6299025161
## 🚨 All tests passed but jobs failed 🚨
### Failed Jobs without Test Failures
❌ [CI / Spring Security Tests \(Java 25\)](https://github.com/apache/grails-core/actions/runs/39468740088/job/118787659802?pr=16619)
🏷️ Commit: 04941d2f097bceff1f0c585de8c9a5586bbfe1a0
▶️ Tests: 41771 executed
🟡 Checks: 73/84 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#discussion_r4329746626
##########
grails-doc/src/en/guide/async/rxjava.adoc:
##########
@@ -17,23 +17,100 @@ specific language governing permissions and limitations
under the License.
////
-Since Grails 3.2, you can use https://github.com/ReactiveX/RxJava[RxJava] to write reactive logic in your Grails controllers that leverages the underlying containers asynchronous processing capabilities.
+Grails integrates https://github.com/ReactiveX/RxJava[RxJava] 3 at three points. Each is a separate module that an application adds to `build.gradle`; Grails itself does not depend on RxJava.
-To get started simply declare a dependency on the plugin in `build.gradle`:
+==== Promises on RxJava
+
+`grails-async-rxjava3` provides a `grails.async.PromiseFactory` backed by RxJava 3, so every `Promise` the application creates is an RxJava subscription:
+
+[source,groovy]
+.build.gradle
+----
+runtimeOnly 'org.apache.grails.async:grails-async-rxjava3'
+----
+
+See <<asyncPromises,Promises>>.
+
+==== Events on RxJava
+
+`grails-events-rxjava3` provides an `EventBus` that delivers events through RxJava 3 subjects and schedulers:
[source,groovy]
.build.gradle
----
-dependencies {
- //...
- implementation 'org.apache.grails:grails-rxjava3'
+runtimeOnly 'org.apache.grails.events:grails-events-rxjava3'
+----
+
+See <<events,Events>>.
+
+==== RxJava Data Services
+
+With `grails-datamapping-rx` on the classpath, a GORM data service can declare methods that return `io.reactivex.rxjava3.core.Observable` or `io.reactivex.rxjava3.core.Single`. GORM implements the method as it does any other data service method: the blocking query runs when the result is subscribed to, on the subscribing thread, and the result is delivered on RxJava's IO scheduler, so the caller consumes it reactively without the datastore itself being non-blocking:
+
+[source,groovy]
+.build.gradle
+----
+implementation 'org.apache.grails.data:grails-datamapping-rx'
+----
+
+[source,groovy]
+----
+import grails.gorm.services.Service
+import io.reactivex.rxjava3.core.Observable
+import io.reactivex.rxjava3.core.Single
+
+@Service(Book)
+interface BookService {
+
+ Single<Book> findOne(String title)
+
+ Observable<Book> findAllByTitle(String title)
+
+ Observable<Book> findAllByAuthor(String author)
+}
+----
+
+A `Single` that finds nothing signals a `java.util.NoSuchElementException`, since an RxJava 3 `Single` cannot complete without a value; an `Observable` that finds nothing completes without emitting. The `grails.gorm.rx.services.RxSchedule` annotation selects the scheduler a method delivers its result on. Neither it nor the default moves the query itself off the subscribing thread, so subscribe from a task, as <<asyncRequests,Asynchronous Request Handling>> describes, to keep a blocking query off a request thread. See the RxJava Support section of the GORM for link:{hibernate7Guide}index.html#dataServicesRxJava[Hibernate 7] or link:{hibernate5Guide}index.html#dataServicesRxJava[Hibernate 5] guide.
+
+==== RxJava Results from Controllers
+
+An RxJava 3 `Flowable` is a Reactive Streams `Publisher`, so an action can return one and Grails streams every item it emits to the client as a server-sent event, with no plugin. See <<asyncStreaming,Streaming Responses>>:
+
+[source,groovy]
+----
+import io.reactivex.rxjava3.core.BackpressureStrategy
+
+class BookController {
+
+ BookService bookService
+
+ def feed(String author) {
+ bookService.findAllByAuthor(author)
+ .toFlowable(BackpressureStrategy.BUFFER)
+ }
}
----
-You can then return `rx.Observable` as a return value from any controller and Grails will automatically apply the following steps:
+Grails subscribes to the publisher on the request thread, so in this example the data service runs its query there, before the action returns, as the previous section describes; the items are then delivered on the IO scheduler and written to the response from it, with the container thread released while they are. Running the query itself on another thread with `subscribeOn(..)` needs a session on that thread, which the data services do not set up.
Review Comment:
The last sentence isn't quite what happens. I tried it on Hibernate 7 with an `Observable<Author> findAllByName(String)` data service.
With `.subscribeOn(Schedulers.io())`, the query runs on `RxCachedThreadScheduler-2` and succeeds. The generated method is `@ReadOnly`, and its transaction opens a session on that thread. What fails is touching a lazy association on a result afterwards: `LazyInitializationException: Cannot lazily initialize collection of role ... (no session)`.
Something like this would be accurate: "With `subscribeOn(..)` the query runs on the IO thread in the data service's own transaction, so its results have no session to load lazy associations from, and anything that reads the request, such as a tenant resolver, doesn't see it there."
##########
grails-async/rxjava3/src/main/groovy/org/grails/async/factory/rxjava3/RxPromiseFactory.groovy:
##########
@@ -76,24 +76,27 @@ class RxPromiseFactory extends AbstractPromiseFactory {
@Override
<T> Promise<T> onComplete(List<Promise<T>> promises, Closure<T> callable) {
- new RxPromise<T>(this, Observable.concat(
- promises.collect { Promise p ->
- if (p instanceof BoundPromise) {
- return Observable.just(((BoundPromise) p).value) as Observable<T>
- }
- else {
- return ((RxPromise) p).toObservable() as Observable<T>
- }
- }
- ).toList())
- .onComplete(callable)
+ new RxPromise<T>(this, values(promises)).onComplete(callable)
}
@Override
<T> Promise<List<T>> onError(List<Promise<T>> promises, Closure<?> callable) {
- new RxPromise(this, Observable.concat(
- promises.collect { ((RxPromise<T>) it).toObservable() }
- ).toList())
- .onError(callable) as Promise<List<T>>
+ new RxPromise(this, values(promises)).onError(callable) as Promise<List<T>>
+ }
+
+ /**
+ * Concatenates the values of the given promises into one list, in order, with a {@code null} value restored
+ * from the sentinel it travels through the stream as.
+ */
+ private static <T> Single<List<T>> values(List<Promise<T>> promises) {
+ List<Observable<T>> sources = promises.collect { Promise<T> p ->
+ if (p instanceof BoundPromise) {
+ return Observable.just(RxPromise.wrap(((BoundPromise) p).value)) as Observable<T>
+ }
+ return ((RxPromise<T>) p).toObservable()
Review Comment:
`toObservable()` returns the promise's source, not its result:
- **A task:** the source is the cold `Single.create(..)`, so subscribing to it here runs the task again.
- **A `then` or `onComplete` promise:** the source is `subject.map(..)` on the previous promise's `subject`. That subject never completes, because the constructor's observer sets `finished` but doesn't pass `onComplete` on. So `concat` waits forever.
I ran the same calls against both modules:
| Call | `grails-async-rxjava` | `grails-async-rxjava3` |
|---|---|---|
| `Promises.onComplete([task]) { }` | task runs once | task runs twice |
| `Promises.onError([task]) { }` | task runs once | task runs twice |
| `Promises.onComplete([task.then { }]) { }` | completes | never completes (`get(3, SECONDS)` times out), and the `then` callback runs twice |
The RxJava 1 factory reads `((RxPromise) p).subject` here, and its subject completes. Two lines bring this module in line:
- here: `return ((RxPromise<T>) p).subject as Observable<T>`
- in the `RxPromise` constructor's observer: `subject.onComplete()` after `finished = true`
With both changes, all three rows match RxJava 1, and the module's existing tests still pass. A feature with a `then`-chained promise in the list and a counter on the task would pin it.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6259528057
## ✅ All tests passed ✅
🏷️ Commit: 1bff03807ac1618eb9431ac964f4bcb145e89d8e
▶️ Tests: 99580 executed
⚪️ Checks: 91/91 completed
---
_Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole commented on code in PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#discussion_r4326946228
##########
grails-doc/src/en/guide/async/rxjava.adoc:
##########
@@ -17,23 +17,98 @@ specific language governing permissions and limitations
under the License.
////
-Since Grails 3.2, you can use https://github.com/ReactiveX/RxJava[RxJava] to write reactive logic in your Grails controllers that leverages the underlying containers asynchronous processing capabilities.
+Grails integrates https://github.com/ReactiveX/RxJava[RxJava] 3 at three points. Each is a separate module that an application adds to `build.gradle`; Grails itself does not depend on RxJava.
-To get started simply declare a dependency on the plugin in `build.gradle`:
+==== Promises on RxJava
+
+`grails-async-rxjava3` provides a `grails.async.PromiseFactory` backed by RxJava 3, so every `Promise` the application creates is an RxJava subscription:
+
+[source,groovy]
+.build.gradle
+----
+runtimeOnly 'org.apache.grails.async:grails-async-rxjava3'
+----
+
+See <<asyncPromises,Promises>>.
+
+==== Events on RxJava
+
+`grails-events-rxjava3` provides an `EventBus` that delivers events through RxJava 3 subjects and schedulers:
+
+[source,groovy]
+.build.gradle
+----
+runtimeOnly 'org.apache.grails.events:grails-events-rxjava3'
+----
+
+See <<events,Events>>.
+
+==== RxJava Data Services
+
+With `grails-datamapping-rx` on the classpath, a GORM data service can declare methods that return `io.reactivex.rxjava3.core.Observable` or `io.reactivex.rxjava3.core.Single`. GORM implements the method as it does any other data service method: the blocking query runs when the result is subscribed to, on the subscribing thread, and the result is delivered on RxJava's IO scheduler, so the caller consumes it reactively without the datastore itself being non-blocking:
[source,groovy]
.build.gradle
----
-dependencies {
- //...
- implementation 'org.apache.grails:grails-rxjava3'
+implementation 'org.apache.grails.data:grails-datamapping-rx'
+----
+
+[source,groovy]
+----
+import grails.gorm.services.Service
+import io.reactivex.rxjava3.core.Observable
+import io.reactivex.rxjava3.core.Single
+
+@Service(Book)
+interface BookService {
+
+ Single<Book> findOne(String title)
+
+ Observable<Book> findAllByTitle(String title)
+
+ Observable<Book> findAllByAuthor(String author)
+}
+----
+
+A `Single` that finds nothing signals a `java.util.NoSuchElementException`, since an RxJava 3 `Single` cannot complete without a value; an `Observable` that finds nothing completes without emitting. The `grails.gorm.rx.services.RxSchedule` annotation selects the scheduler a method delivers its result on. Neither it nor the default moves the query itself off the subscribing thread, so subscribe from a task, as <<asyncRequests,Asynchronous Request Handling>> describes, to keep a blocking query off a request thread. See the RxJava Support section of the GORM for link:{hibernate7Guide}index.html#dataServicesRxJava[Hibernate 7] or link:{hibernate5Guide}index.html#dataServicesRxJava[Hibernate 5] guide.
+
+==== RxJava Results from Controllers
+
+An RxJava 3 `Flowable` is a Reactive Streams `Publisher`, so an action can return one and Grails streams every item it emits to the client as a server-sent event, with no plugin and with the container thread released while the stream produces. See <<asyncStreaming,Streaming Responses>>:
Review Comment:
In this example, the query runs on the container thread:
- `PublisherActionResultTransformer.stream()` calls `publisher.subscribe(subscriber)` on the request thread (line 170).
- Subscribing runs the data service's `defer` supplier on that same thread, which is the behavior `RxServiceSupportSpec` now pins.
So `findAllByAuthor` has fetched every book before the action returns, and only the delivery and the writes happen on the IO scheduler. That contradicts the paragraph above, which says to subscribe from a task to keep the query off a request thread.
There are two ways to fix it:
- Say here that the query runs on the request thread.
- Add `subscribeOn(Schedulers.io())` before `toFlowable(..)`. This one also needs the data service's transaction and session to work on the IO thread.
The first is the smaller change.
##########
grails-doc/src/en/guide/upgrading/upgrading90x.adoc:
##########
@@ -305,3 +324,58 @@ It applies nothing else. Null properties are written whatever `@JsonInclude` or
`spring.jackson.default-property-inclusion` say, properties are written in the converter's order rather than by
`@JsonPropertyOrder` or sorted alphabetically, and `@JsonView`, `@JsonFilter`, `@JsonAnyGetter`, `@JsonIgnoreType`,
`@JsonFormat` and `@JsonSerialize` on a property, and mix-ins, other than the property names they give, do not apply.
+
+==== 6. RxGORM Runs on RxJava 3
+
+RxGORM, the reactive variant of GORM in `org.apache.grails.data:grails-datamapping-rx`, is built on RxJava 3 instead of RxJava 1.
+Its dependency is now `io.reactivex.rxjava3:rxjava`, and the RxJava 1 artifact `io.reactivex:rxjava` is no longer on the classpath of an application that only uses RxGORM.
+Every RxGORM API that returned `rx.Observable` returns `io.reactivex.rxjava3.core.Observable`, and an `@RxSchedule` service method that returned `rx.Single` returns `io.reactivex.rxjava3.core.Single`.
+
+Update the imports of every class that works with RxGORM results:
+
+[cols="1,1",options="header"]
+|===
+| RxJava 1 | RxJava 3
+
+| `rx.Observable` | `io.reactivex.rxjava3.core.Observable`
+| `rx.Single` | `io.reactivex.rxjava3.core.Single`
+| `rx.Subscriber` | `io.reactivex.rxjava3.core.Observer`
+| `rx.Subscription` | `io.reactivex.rxjava3.disposables.Disposable`
+| `rx.Scheduler`, `rx.schedulers.Schedulers` | `io.reactivex.rxjava3.core.Scheduler`, `io.reactivex.rxjava3.schedulers.Schedulers`
+| `rx.functions.Func1` | `io.reactivex.rxjava3.functions.Function`
+|===
+
+The blocking helpers that tests and scripts use moved onto the `Observable` and `Single` types themselves:
+
+[cols="1,1",options="header"]
+|===
+| RxJava 1 | RxJava 3
+
+| `observable.toBlocking().first()` | `observable.blockingFirst()`
+| `observable.toBlocking().single()` | `observable.blockingSingle()`
+| `observable.toList().toBlocking().single()` | `observable.toList().blockingGet()`
+| `single.toBlocking().value()` | `single.blockingGet()`
+|===
+
+`Observable.toList()` returns a `Single<List<T>>` in RxJava 3.
+The RxGORM methods that emit a list, such as `list()`, `findAll().toList()` on a criteria query and `toListObservable()` on a lazy association, still return an `Observable<List<T>>`, so code that subscribes to them is unchanged.
+
+Subscribing with a closure, for example `Book.get(id).subscribe { Book book -> ... }`, is unchanged.
+A class that subscribes with a full subscriber implements `io.reactivex.rxjava3.core.Observer` instead of `rx.Subscriber`: it gains `onSubscribe(Disposable)`, which receives the handle that cancels the subscription, and `onCompleted()` is named `onComplete()`.
+`DetachedCriteria`, `ObservableProxy` and the lazy association collections implement `io.reactivex.rxjava3.core.ObservableSource`, so their `subscribe(Observer)` method returns `void` rather than a `Subscription`; they can be passed anywhere RxJava 3 accepts an `ObservableSource`, such as `Observable.wrap(..)` or `concatWith(..)`.
+
+RxJava 3 does not allow `null` to be emitted.
+An RxGORM operation that has no result completes without emitting, as queries already did; for example `save()` and `insert()` complete empty, instead of emitting `null`, when the datastore reports no identifier for the instance.
+An `@RxSchedule` service method that returns a `Single` and produces no result now signals a `java.util.NoSuchElementException`, and one that returns an `Observable` completes empty.
+Replace a test that compares `toBlocking().first()` with `null` by one that expects `blockingFirst()` to throw `NoSuchElementException`, or use `firstElement().blockingGet()`, which returns `null` for an empty result.
+
+A datastore implementation of RxGORM built for Grails 8 or earlier, such as the RxGORM for MongoDB plugin, is compiled against RxJava 1 and must be rebuilt against this release before it can be used.
+The `RxEntity` domain model has had no datastore implementation for several releases and its removal is under discussion for Grails 9, so an application that implements `RxEntity` should plan to move to `GormEntity` with the RxJava data services, which work on every GORM datastore. The import and blocking-call changes above apply to both.
+The `rx-mongodb` profile feature is removed, because the `org.grails.plugins:rx-mongodb` plugin it added has had no release since GORM 6.1 and has never been published to Maven Central, so an application generated with it could not resolve its dependencies.
+
+==== 7. RxJava 1 and RxJava 2 Async and Events Modules Are Deprecated
+
+The RxJava 1 and RxJava 2 implementations of the Grails promise and event bus APIs, `grails-async-rxjava`, `grails-async-rxjava2`, `grails-events-rxjava` and `grails-events-rxjava2`, are deprecated for removal.
+They keep working in Grails 9 and log a warning when their promise factory or event bus is created.
+Replace either dependency with the RxJava 3 module, `grails-async-rxjava3` or `grails-events-rxjava3`; the `Promise` and `EventBus` APIs an application uses are the same.
Review Comment:
Switching from `grails-async-rxjava` to `grails-async-rxjava3` isn't a no-code-change swap once a promise holds `null`. I ran the same calls against both factories:
| Call | `grails-async-rxjava` | `grails-async-rxjava3` |
|---|---|---|
| `createPromise()` | promise of `null` | `NullPointerException: item is null` |
| `createPromise(String)` | promise of `null` | `NullPointerException: item is null` |
| `createPromise { null }.get()` | `null` | `java.lang.Void` (the class) |
| `onComplete([createBoundPromise(null)]) { .. }` | callback gets `[null]` | `NullPointerException: item is null` |
Where these come from in the rxjava3 module:
- The exceptions come from `Single.just(null)` and `Observable.just(null)` in its `RxPromiseFactory`, at lines 45, 50 and 82.
- `RxPromise.runCallable` turns `null` into `Void` as a sentinel, but nothing turns it back.
`createPromise()` is what `Promises.createPromise()` and `WebPromises.createPromise()` call. RxJava 2 users already see this behavior, so only the RxJava 1 users this section points at rxjava3 would hit it.
The same "the API is the same" claim appears in `asyncPromises.adoc:181`, `whatsNew.adoc:153` and `SKILL.md:196`.
Could the rxjava3 factory carry `null` through one sentinel on the way in and turn it back into `null` on the way out, with a spec for each row above? Otherwise these pages need to list the differences.
##########
grails-doc/src/en/guide/upgrading/upgrading90x.adoc:
##########
@@ -305,3 +324,58 @@ It applies nothing else. Null properties are written whatever `@JsonInclude` or
`spring.jackson.default-property-inclusion` say, properties are written in the converter's order rather than by
`@JsonPropertyOrder` or sorted alphabetically, and `@JsonView`, `@JsonFilter`, `@JsonAnyGetter`, `@JsonIgnoreType`,
`@JsonFormat` and `@JsonSerialize` on a property, and mix-ins, other than the property names they give, do not apply.
+
+==== 6. RxGORM Runs on RxJava 3
+
+RxGORM, the reactive variant of GORM in `org.apache.grails.data:grails-datamapping-rx`, is built on RxJava 3 instead of RxJava 1.
+Its dependency is now `io.reactivex.rxjava3:rxjava`, and the RxJava 1 artifact `io.reactivex:rxjava` is no longer on the classpath of an application that only uses RxGORM.
+Every RxGORM API that returned `rx.Observable` returns `io.reactivex.rxjava3.core.Observable`, and an `@RxSchedule` service method that returned `rx.Single` returns `io.reactivex.rxjava3.core.Single`.
+
+Update the imports of every class that works with RxGORM results:
+
+[cols="1,1",options="header"]
+|===
+| RxJava 1 | RxJava 3
+
+| `rx.Observable` | `io.reactivex.rxjava3.core.Observable`
+| `rx.Single` | `io.reactivex.rxjava3.core.Single`
+| `rx.Subscriber` | `io.reactivex.rxjava3.core.Observer`
+| `rx.Subscription` | `io.reactivex.rxjava3.disposables.Disposable`
+| `rx.Scheduler`, `rx.schedulers.Schedulers` | `io.reactivex.rxjava3.core.Scheduler`, `io.reactivex.rxjava3.schedulers.Schedulers`
+| `rx.functions.Func1` | `io.reactivex.rxjava3.functions.Function`
+|===
+
+The blocking helpers that tests and scripts use moved onto the `Observable` and `Single` types themselves:
+
+[cols="1,1",options="header"]
+|===
+| RxJava 1 | RxJava 3
+
+| `observable.toBlocking().first()` | `observable.blockingFirst()`
+| `observable.toBlocking().single()` | `observable.blockingSingle()`
+| `observable.toList().toBlocking().single()` | `observable.toList().blockingGet()`
+| `single.toBlocking().value()` | `single.blockingGet()`
+|===
+
+`Observable.toList()` returns a `Single<List<T>>` in RxJava 3.
+The RxGORM methods that emit a list, such as `list()`, `findAll().toList()` on a criteria query and `toListObservable()` on a lazy association, still return an `Observable<List<T>>`, so code that subscribes to them is unchanged.
Review Comment:
`findAll()` on an RxGORM `DetachedCriteria` returns `Observable<T>` (`DetachedCriteria.groovy:77`). So `findAll().toList()` is RxJava's own `toList()`, and it returns `Single<List<T>>`, as the sentence just before says.
The methods that keep `Observable<List<T>>` are `toList()` and `list()` on the criteria itself (lines 111 and 123). "`toList()` on a `DetachedCriteria`" would fit here.
##########
grails-async/rxjava/src/test/groovy/org/grails/async/factory/rxjava/RxPromiseFactoryDeprecationSpec.groovy:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.grails.async.factory.rxjava
+
+import java.lang.reflect.Field
+import java.util.concurrent.atomic.AtomicBoolean
+
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.classic.spi.ILoggingEvent
+import ch.qos.logback.core.read.ListAppender
+import org.slf4j.LoggerFactory
+import spock.lang.Specification
+
+import grails.async.PromiseFactory
+import grails.async.Promises
+
+class RxPromiseFactoryDeprecationSpec extends Specification {
+
+ Logger factoryLogger = LoggerFactory.getLogger(RxPromiseFactory) as Logger
+ ListAppender<ILoggingEvent> appender = new ListAppender<>()
+
+ void setup() {
+ resetDeprecationWarning()
+ appender.start()
+ factoryLogger.addAppender(appender)
+ }
+
+ void cleanup() {
+ factoryLogger.detachAppender(appender)
+ appender.stop()
+ }
+
+ void 'the RxJava 1 promise factory is deprecated for removal since Grails 9.0'() {
+ expect:
+ RxPromiseFactory.getAnnotation(Deprecated).forRemoval()
+ RxPromiseFactory.getAnnotation(Deprecated).since() == '9.0'
+ }
+
+ void 'creating the RxJava 1 promise factory warns that it is deprecated'() {
+ when: 'the factory is created'
+ PromiseFactory factory = new RxPromiseFactory()
+
+ then: 'the factory still works'
+ factory.createPromise { 1 + 1 }.get() == 2
+
+ and: 'a single warning names the module and its replacement'
+ appender.list.size() == 1
+ appender.list[0].level == Level.WARN
+ appender.list[0].formattedMessage.contains('grails-async-rxjava')
Review Comment:
`contains('grails-async-rxjava')` is also true for `grails-async-rxjava2` and `grails-async-rxjava3`. So this line can't fail while the next one passes, and a v1 message copied from the v2 one would pass all three checks. `contains('(grails-async-rxjava)')` would pin the module. The events spec has the same check at line 72.
Two more things in this spec:
- **The service-loaded feature.** It repeats `RxJavaPromiseSpec:36`. `Promises.promiseFactory` is cached, so the feature may not create anything. `new PromiseFactoryBuilder().build()` loads the factory through `ServiceLoader` every time, so the feature could assert the warning too, as the events spec does with `EventBusBuilder`.
- **The annotation feature.** It checks only `RxPromiseFactory`, so removing `@Deprecated` from `RxPromise` fails nothing. `GparsPromiseSpec` checks `GparsPromise` as well.
The rxjava2 copy has the same three gaps.
##########
grails-doc/src/en/guide/async/asyncStreaming.adoc:
##########
@@ -34,7 +34,9 @@ class ClockController {
}
----
-A publisher that emits at most one item, such as a Reactor `Mono`, is not streamed. As Spring MVC does, Grails resolves it and treats its value as the action's result, the way a returned `Promise`'s value is: a `Map` is the model of the view, anything else leaves the response to what the action rendered, and a failure fails the request. Which publishers are single-valued is what Spring's `ReactiveAdapterRegistry` knows, so a Reactor `Mono`, a `CompletableFuture` adapted to one or an RxJava `Single` all resolve rather than stream.
+A publisher that emits at most one item, such as a Reactor `Mono`, is not streamed. As Spring MVC does, Grails resolves it and treats its value as the action's result, the way a returned `Promise`'s value is: a `Map` is the model of the view, anything else leaves the response to what the action rendered, and a failure fails the request. Which publishers are single-valued is what Spring's `ReactiveAdapterRegistry` knows, so a Reactor `Mono` and a `CompletableFuture` adapted to one both resolve rather than stream.
+
+Only a result that implements `Publisher` is streamed or resolved. An RxJava 3 `Observable` or `Single` is not a `Publisher`, so it is left alone and the action renders its view as before; convert it to one with `toFlowable(..)`, as <<rxjava,RxJava Support>> shows. A `Flowable` is multi-valued whatever it emits, so a `Flowable` of one item is streamed as a single event rather than resolved.
Review Comment:
The action doesn't render its view here:
- `PublisherActionResultTransformer` returns the `Observable` unchanged.
- `UrlMappingsInfoHandlerAdapter` (lines 164-187) only builds a `ModelAndView` for four results: a `MODEL_AND_VIEW` attribute, a `Map`, a `ModelAndView`, or `null` with `renderView` set.
- Any other non-null result reaches `return null`.
So the response is empty unless the action rendered something itself. Something like "so Grails neither streams it nor renders a view" would be accurate.
##########
grails-doc/src/en/guide/introduction/whatsNew.adoc:
##########
@@ -126,6 +126,32 @@ A controller action can return a Reactive Streams `Publisher`, such as a Reactor
Items are rendered as text or JSON, or through a `StreamItemRenderer` bean for a type of its own, which is how `grails-spring-ai` streams the chat responses of a model.
Such an action streams instead of rendering its view as it did before; set `grails.async.streaming.enabled` to `false` to keep the previous behaviour. A publisher that emits at most one item, such as a Reactor `Mono`, is not streamed but resolved, its value being the action's result as a returned `Promise`'s value is. See xref:upgrading#upgrading81x[the upgrade guide].
See xref:async#asyncStreaming[Streaming Responses].
+==== RxJava Data Services on RxJava 3
Review Comment:
This heading needs a blank line before it. Without one, Asciidoctor keeps it inside the paragraph above. I rendered lines 118-135 with AsciidoctorJ 3.0.1, and it gave `…[Streaming Responses].\n==== RxJava Data Services on RxJava 3</p>`.
So the section is missing from the TOC, and its text runs on from the Streaming Responses section.
##########
grails-skills/upgrade-guide-9/skills/grails-9-upgrade/SKILL.md:
##########
@@ -0,0 +1,223 @@
+---
+name: grails-9-upgrade
+description: Guide for upgrading Grails applications from Grails 8.x to Grails 9, covering the Groovy 6 baseline, the GPars deprecation in favour of groovy.concurrent, invokedynamic compilation, the Jackson-backed JSON converter and domain class serializer, RxGORM on RxJava 3 (imports, blocking calls, subscribers, empty results), and the deprecated RxJava 1 and RxJava 2 async and events modules
+license: Apache-2.0
+---
+
+<!--
+SPDX-License-Identifier: Apache-2.0
+
+Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0.
+-->
+
+## What I Do
+
+- Guide upgrades of Grails applications from Grails 8.x to Grails 9.
+- Turn the Grails 9 upgrade guide into a practical migration checklist.
+- Identify the Groovy 6, GPars, invokedynamic, JSON rendering, RxGORM, and RxJava changes that can break an application.
+- Keep migration work focused on public application behavior, not internal Grails framework implementation details.
+
+## When to Use Me
+
+Activate this skill when:
+
+- Updating an application to Grails 9.
+- Reviewing a Grails 9 upgrade branch or pull request.
+- Fixing tests, build failures, runtime failures, or behavior changes after moving from Grails 8.x to Grails 9.
+- Porting code that uses RxGORM, `grails-async-rxjava`, `grails-async-rxjava2`, `grails-events-rxjava`, or `grails-events-rxjava2` to RxJava 3.
+- Replacing GPars (`grails-async-gpars`, `grails-events-gpars`, or direct `GParsPool` use) with Groovy's `groovy.concurrent` toolkit.
+- Checking an application's JSON output before or after setting `grails.converters.json.legacy` to `false`.
+
+For an application still on Grails 7, apply the `grails-8-upgrade` skill first and move to Grails 8 before using this one.
+
+## Primary Sources
+
+Use the published Grails documentation as the source of truth before changing an application. The URLs below use `<version>`, which stands for the Grails 9 version the application is upgrading to, such as the `grailsVersion` in its `gradle.properties`; use `snapshot` for a snapshot version.
+
+| URL | Use for |
+|-----|---------|
+| `https://grails.apache.org/docs/<version>/guide/upgrading.html#upgrading90x` | Main Grails 8 to Grails 9 upgrade guide |
+| `https://grails.apache.org/docs/<version>/guide/introduction.html#whatsNew` | Grails 9 feature and platform overview |
+| `https://grails.apache.org/docs/<version>/guide/introduction.html#dependencyUpgrades` | Platform dependency baseline |
+| `https://grails.apache.org/docs/<version>/guide/async.html` | Promises and events, including the RxJava 3 modules |
+| `https://grails.apache.org/docs/<version>/guide/theWebLayer.html` | JSON rendering and the converters |
+| `https://groovy-lang.org/releasenotes/groovy-6.0.html#concurrency-toolkit` | The `groovy.concurrent` toolkit that replaces GPars |
+| `https://grails.apache.org/docs/<version>/ref/Versions/Grails%20BOM.html` | Dependency versions of the Grails BOM |
+| `https://groovy-lang.org/releasenotes/groovy-6.0.html` | Groovy 6 language and runtime changes |
+| `https://github.com/ReactiveX/RxJava/wiki/What's-different-in-3.0` | RxJava 3 API differences, with the RxJava 1 to 2 differences it links to |
+
+## Upgrade Baseline
+
+Verify these before touching application code; `gradle.properties`, the Gradle wrapper, and the Grails BOM are the sources of truth:
+
+- Java 21 remains the minimum to build and run.
+- Groovy moves from 5.x to 6.0, and Spock to the `groovy-6.0` variant. Do not pin `groovy-all` or Spock yourself; the Grails BOM manages both.
+- Spring Boot 4.1 and Spring Framework 7 are unchanged from Grails 8; a Grails 8 application's Boot configuration carries over.
+- Gradle 9.8 or later for the wrapper.
+- RxGORM (`grails-datamapping-rx`) depends on `io.reactivex.rxjava3:rxjava`. The RxJava 1 artifact `io.reactivex:rxjava` is no longer transitively available through it.
+- Groovy source sets compile with invokedynamic by default; `grails { indy = false }` was the Grails 8 default and is now unset.
+- `grails.converters.json.legacy` defaults to `true`, so JSON renders as it did in Grails 8 until the application opts in to the Jackson-backed converter.
+
+## Migration Workflow
+
+1. Update `grailsVersion` in `gradle.properties` and refresh the Gradle wrapper; let the Grails BOM manage Groovy, Spock, and RxJava versions.
+2. Build without tests first (`./gradlew compileGroovy compileTestGroovy`) and fix compilation errors module by module.
+3. Replace GPars with `groovy.concurrent`, following the sections below.
+4. Port RxGORM and RxJava code, following the sections below.
+5. Replace the deprecated RxJava 1 and 2 async and events modules with their RxJava 3 counterparts.
+6. Check the application's JSON with `grails.converters.json.legacy` set to `false`, then set it explicitly either way.
+7. Run the full test suite, then start the application and read its log for `[DEPRECATED]` and `deprecated` warnings from Grails.
+8. Review the published upgrade guide section by section, confirming every item either does not apply or has been handled.
+
+## Groovy 6
+
+Groovy 6 is a major Groovy release. Read its release notes before assuming that a Groovy 5 construct behaves the same way. Compile the application statically where it was already static; a construct that compiles dynamically but fails under `@CompileStatic` is a sign of a Groovy change rather than a Grails one. Keep the Spock version the Grails BOM supplies, which is built for Groovy 6.
+
+## GPars Deprecated in Favour of Groovy Concurrency
+
+Groovy 6 brings the concurrency and parallel-processing patterns of GPars into the language as `groovy.concurrent`, so Grails no longer needs the separate GPars library. `grails-async-gpars` and `grails-events-gpars` still work in Grails 9, carry `@Deprecated(since = '9.0', forRemoval = true)`, log a warning when selected, and will be removed in a future release.
+
+Replace the dependency, one for one:
+
+| Grails 8 | Grails 9 |
+|----------|----------|
+| `org.apache.grails.async:grails-async-gpars` | `org.apache.grails.async:grails-async-groovy-concurrent` |
+| `org.apache.grails.events:grails-events-gpars` | `org.apache.grails.events:grails-events-groovy-concurrent` |
+
+Do not leave both on the classpath: only the first service-loaded `PromiseFactory` is used, and the event bus builder refuses to start when it finds more than one `EventBus` implementation.
+
+The Groovy promise factory follows the failure contract of the default `CompletableFuture` factory rather than the GPars one. A direct or chained `get()` throws `ExecutionException` with the original failure as its cause, a single-promise `onError` recovers with its callback result, the aggregate `onError` observes the failure and leaves the returned promise failed, and `onComplete` and `then` return a new promise instead of the receiver. A test that asserted the GPars behaviour needs updating.
+
+The Groovy actor event bus delivers each event to its subscribers in publication order on one actor. A subscriber that throws without a reply handler is logged and does not stop delivery to the remaining subscribers or to later events.
+
+Application code that uses GPars directly moves to the Groovy equivalents:
+
+| GPars | `groovy.concurrent` |
+|-------|---------------------|
+| `GParsPool.withPool { list.eachParallel { } }` | `list.eachParallel { }`, which needs no pool |
+| `GParsPool.withPool(n) { list.collectParallel { } }` | `ParallelScope.withPool(n) { scope -> list.collectParallel { } }` |
+| `GParsConfig.setPoolFactory(..)` | `Awaitable.setExecutor(..)`, which also hosts the actor event bus |
+
+Promises the Groovy factory creates are Groovy `Awaitable` instances, so they can be passed to `await` and to combinators such as `Awaitable.all` without conversion. Once the deprecated modules are removed, Grails no longer brings GPars onto the classpath, so an application that still needs it declares `org.codehaus.gpars:gpars` itself.
+
+Groovy marks the toolkit as incubating. The Grails modules on top of it expose only the Grails `Promise` and `EventBus` contracts, so later Groovy changes are absorbed by Grails rather than by application code.
+
+## Groovy Code Compiles with invokedynamic
+
+Grails 8 compiled every Groovy source set without invokedynamic, because `grails { indy = false }` was the default. Grails 9 leaves the setting unset, so the Groovy compiler's own default applies, and on Groovy 6 that is invokedynamic.
+
+- Remove `grails { indy = true }`; it is now the effective default.
+- Build logic that read the property must allow for it having no value: use `grails.indy.getOrElse(true)` or check `grails.indy.present` instead of `grails.indy.get()`.
+- An application that sets `indy = false` to keep classic call sites must also declare `implementation 'org.apache.groovy:groovy-callsite'` itself, at the BOM's version, and again for every source set that does not see implementation dependencies, such as `java-test-fixtures` test fixtures. Without it the Groovy compiler stops with a message naming the module.
+- An application that applies GraalVM's native image plugin cannot set `indy = false`; the build fails with the reason, because an image needs invokedynamic.
+- A library compiled with classic call sites needs `groovy-callsite` whatever the application's setting, or loading one of its classes fails with `NoClassDefFoundError: org/codehaus/groovy/runtime/callsite/CallSiteArray`. Spock 2.5, Geb 8 and the Asset Pipeline 5.2 are compiled with invokedynamic; `org.testcontainers:testcontainers-spock` is not, so declare `testRuntimeOnly 'org.apache.groovy:groovy-callsite'` next to it.
+
+## JSON Rendering Can Use Spring Boot's JsonMapper
+
+`grails.converters.JSON` still renders as it did in Grails 8 by default, because `grails.converters.json.legacy` defaults to `true`. Grails logs a warning once at startup while the setting is unset, because a later release makes `false` the default. Set it explicitly either way to silence the warning, and check the application's JSON with `false` before that release:
+
+```yaml
+grails:
+ converters:
+ json:
+ legacy: false
+```
+
+With `legacy: false`, the converter writes through the application's Jackson `JsonMapper`, so `spring.jackson.*` settings and registered Jackson modules apply. Check these values in the application's JSON contract and in any test that asserts JSON text, because they render differently: `OffsetTime`, `Month` (a number, not its name), `Locale` (a language tag), `char` and `Character`, `byte[]` and `char[]` (Base64 and a string), `UUID`, `URI` and other `@JsonValue` types (their value, not a bean), `Pattern`, `Charset`, `InetAddress`, `File`, `Path`, `ByteBuffer`, `JsonNode`, `Optional` (its value or `null`), a `NaN` or infinite `double` (a string), and the layout of pretty printed JSON. Enums still render by `name()`, and strings are still escaped for an HTML `<script>` element, deliberately differing from Spring Boot.
+
+Parsing does not change: `JSON.parse`, `request.JSON` and `new JSONObject(String)` accept the same syntax and return the same types.
+
+A marshaller an application registers still takes precedence over the mapper, so keeping one type's Grails 8 rendering under `legacy: false` is a matter of registering a marshaller for it, for example in `BootStrap.init`:
+
+```groovy
+JSON.registerObjectMarshaller(Month) { Month month -> month.name() }
+```
+
+Subclassing `org.grails.web.json.JSONWriter` needs review whatever the setting: it now writes through a Jackson `JsonGenerator`, its `array()`, `object()`, `key()` and `value` methods no longer call the protected `append` and `comma` methods, and its text reaches the `Writer` as the buffer fills rather than per value. `PrettyPrintJSONWriter` and the JavaCC parser in `org.grails.web.json.parser` are deprecated.
+
+With `legacy: false`, domain classes render through `DomainClassSerializer`, which honours `@JsonIgnore` and `@JsonProperty(access = WRITE_ONLY)` where the marshaller did not, so a property that was rendered before may now be absent. Set `grails.converters.json.domain.jackson.enabled` to `true` to have the application's own `JsonMapper` render domain classes the same way, for example when a Spring MVC controller returns one.
+
+## RxGORM on RxJava 3
+
+RxGORM returns RxJava 3 types. Every `rx.Observable` becomes `io.reactivex.rxjava3.core.Observable`, and an `@RxSchedule` service method that returned `rx.Single` returns `io.reactivex.rxjava3.core.Single`.
+
+### Imports
+
+| RxJava 1 | RxJava 3 |
+|----------|----------|
+| `rx.Observable` | `io.reactivex.rxjava3.core.Observable` |
+| `rx.Single` | `io.reactivex.rxjava3.core.Single` |
+| `rx.Subscriber` | `io.reactivex.rxjava3.core.Observer` |
+| `rx.Subscription` | `io.reactivex.rxjava3.disposables.Disposable` |
+| `rx.Scheduler`, `rx.schedulers.Schedulers` | `io.reactivex.rxjava3.core.Scheduler`, `io.reactivex.rxjava3.schedulers.Schedulers` |
+| `rx.functions.Func1`, `Func2`, `FuncN` | `io.reactivex.rxjava3.functions.Function`, `BiFunction`, `Function<Object[], R>` |
+| `rx.observers.TestSubscriber` | `io.reactivex.rxjava3.observers.TestObserver` |
+
+A declared return type such as `rx.Observable<Book>` in a `@Service` interface must change too, or the service implementer no longer recognises the method as reactive.
+
+### Blocking Calls
+
+| RxJava 1 | RxJava 3 |
+|----------|----------|
+| `observable.toBlocking().first()` | `observable.blockingFirst()` |
+| `observable.toBlocking().single()` | `observable.blockingSingle()` |
+| `observable.toList().toBlocking().single()` | `observable.toList().blockingGet()` |
+| `single.toBlocking().value()` | `single.blockingGet()` |
+| `observable.toBlocking().first()` compared with `null` | `observable.firstElement().blockingGet()`, which returns `null` when empty, or expect `blockingFirst()` to throw `NoSuchElementException` |
+
+`Observable.toList()` returns a `Single<List<T>>` in RxJava 3. The RxGORM methods that emit a list, such as `list()`, `DetachedCriteria.toList()`, criteria `list()` and `toListObservable()` on a lazy association, still return `Observable<List<T>>`, so subscribers to them do not change.
+
+### Subscribers
+
+- Closure subscriptions, `observable.subscribe { Book book -> ... }` and the two-closure `subscribe(onNext, onError)`, are unchanged.
+- A full subscriber implements `Observer<T>`: add `onSubscribe(Disposable d)`, rename `onCompleted()` to `onComplete()`, and keep the `Disposable` to cancel instead of calling `unsubscribe()` on a `Subscription`.
+- `DetachedCriteria`, `ObservableProxy` and the lazy association collections implement `ObservableSource<T>`. Their `subscribe(Observer)` returns `void`; code that kept the returned `Subscription` keeps the `Disposable` from `onSubscribe` instead. They can be passed to `Observable.wrap(..)`, `concatWith(..)` and any other operator that takes an `ObservableSource`.
+- `TestSubscriber` tests become `TestObserver` tests: `awaitTerminalEvent(..)` is `await(..)`, `assertCompleted()` is `assertComplete()`, and `onNextEvents` is `values()`.
+
+### Empty Results and Null
+
+RxJava 3 never emits `null`.
+
+- A query with no result completes empty, as before.
+- `save()`, `insert()` and `persist()` on an instance the datastore did not write complete empty instead of emitting `null`.
+- An `@RxSchedule` service method returning `Single` whose body returns `null` signals `java.util.NoSuchElementException`; one returning `Observable` completes empty. Where a missing result is expected, declare `Observable` and use `firstElement()`, which gives a `Maybe` whose `blockingGet()` returns `null` when empty, rather than catching the exception. RxJava 3's own zero-or-one type, `Maybe`, is not yet recognised as a data service return type.
+- A `switchMap` or `flatMap` function must return an `ObservableSource`, never `null`; use `Observable.empty()`.
+
+### Datastore Implementations
+
+A datastore implementation of RxGORM compiled for Grails 8 or earlier, such as the RxGORM for MongoDB plugin, links against RxJava 1 and fails at runtime with `NoClassDefFoundError: rx/Observable`. It must be rebuilt against this release. The `rx-mongodb` profile feature is removed, because the plugin it generated has had no release since GORM 6.1 and was never published to Maven Central. `RxEntity` has had no datastore implementation for several releases, so an application that implements it should move to `GormEntity` with the RxJava data services, which work on every GORM datastore.
+
+## Deprecated RxJava 1 and RxJava 2 Modules
+
+`grails-async-rxjava`, `grails-async-rxjava2`, `grails-events-rxjava` and `grails-events-rxjava2` are deprecated for removal. They still work and log a warning such as `The RxJava 1 promise factory (grails-async-rxjava) is deprecated` when the promise factory or event bus is created.
+
+- Replace `org.apache.grails.async:grails-async-rxjava` or `grails-async-rxjava2` with `grails-async-rxjava3`.
+- Replace `org.apache.grails.events:grails-events-rxjava` or `grails-events-rxjava2` with `grails-events-rxjava3`.
+- The `Promise` and `EventBus` APIs are the same for every implementation, so an application that only uses the Grails APIs needs no code change. Code that reaches into the RxJava types behind them, such as `RxPromise.toObservable()`, moves to the RxJava 3 types as described above.
Review Comment:
`RxPromise` is `@PackageScope` in all three modules (`rxjava3/RxPromise.groovy:52`), so an application can't name it. Also, as the comment on `upgrading90x.adoc` shows, "needs no code change" doesn't hold for a promise of `null`.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#discussion_r4339239111
##########
grails-async/rxjava3/src/main/groovy/org/grails/async/factory/rxjava3/RxPromiseFactory.groovy:
##########
@@ -76,24 +76,27 @@ class RxPromiseFactory extends AbstractPromiseFactory {
@Override
<T> Promise<T> onComplete(List<Promise<T>> promises, Closure<T> callable) {
- new RxPromise<T>(this, Observable.concat(
- promises.collect { Promise p ->
- if (p instanceof BoundPromise) {
- return Observable.just(((BoundPromise) p).value) as Observable<T>
- }
- else {
- return ((RxPromise) p).toObservable() as Observable<T>
- }
- }
- ).toList())
- .onComplete(callable)
+ new RxPromise<T>(this, values(promises)).onComplete(callable)
}
@Override
<T> Promise<List<T>> onError(List<Promise<T>> promises, Closure<?> callable) {
- new RxPromise(this, Observable.concat(
- promises.collect { ((RxPromise<T>) it).toObservable() }
- ).toList())
- .onError(callable) as Promise<List<T>>
+ new RxPromise(this, values(promises)).onError(callable) as Promise<List<T>>
+ }
+
+ /**
+ * Concatenates the values of the given promises into one list, in order, with a {@code null} value restored
+ * from the sentinel it travels through the stream as.
+ */
+ private static <T> Single<List<T>> values(List<Promise<T>> promises) {
+ List<Observable<T>> sources = promises.collect { Promise<T> p ->
+ if (p instanceof BoundPromise) {
+ return Observable.just(RxPromise.wrap(((BoundPromise) p).value)) as Observable<T>
Review Comment:
`BoundPromise.then()` stores a thrown exception in `value` (`BoundPromise.groovy` around lines 88-94). `get()` treats that value as failure. This branch emits it through `Observable.just`, so a `Throwable` is a successful list element.
```groovy
def failure = new IllegalStateException('boom')
def failed = Promises.createBoundPromise(1).then { throw failure }
Throwable seen = null
def result = Promises.onError([failed]) { seen = it }.get()
// result == [failure], seen == null
```
List `onComplete` has the same hole. `waitAll` does not, because it calls `p.get()`.
Emit `Observable.error((Throwable) value)` when the stored value is a `Throwable`, and emit the wrapped value otherwise. Please add a public-API regression: a bound promise whose `then` throws must invoke list `onError` with the original exception, fail aggregate `get()`, and must not invoke list `onComplete`. Keep the null-value and single-execution tests.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Port RxGORM to RxJava 3 and deprecate the RxJava 1 and 2 async and events modules [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on PR #16619:
URL: https://github.com/apache/grails-core/pull/16619#issuecomment-6348343489
I updated the skill for missing notes that are in the upgrade guide as part of this PR. @matrei I'd like to merge, but want to know you're ok with the change before proceeding. Everyone else has approved.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org