Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 74 forks source link

Fix CoroutineCollection.createIndexes #329

Closed skkap closed 2 years ago

skkap commented 2 years ago

With the current implementation calling CoroutineCollection.createIndexes throws:

Caused by: java.lang.IllegalArgumentException: More than one onNext value for awaitSingle
    (Coroutine boundary)
    at org.litote.kmongo.coroutine.CoroutineCollection.createIndexes(CoroutineCollection.kt:823)
    at com.skkap.lookback.server.job.EnsureMongodbIndexesJob$ensureIndexes$2.invokeSuspend(EnsureMongodbIndexesJob.kt:18)
Caused by: java.lang.IllegalArgumentException: More than one onNext value for awaitSingle
    at kotlinx.coroutines.reactive.AwaitKt$awaitOne$2$1.onNext(Await.kt:240)
    at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89)
    at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onNext(FluxConcatArray.java:201)
    at reactor.core.publisher.FluxIterable$IterableSubscription.fastPath(FluxIterable.java:340)
    at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:227)
...

I am not confident about the fix, but I believe createIndexes() returns more than one element from a publisher.

Please let me know if you have some suggestions.

codecov[bot] commented 2 years ago

Codecov Report

Merging #329 (d9bc2ae) into master (d0133a9) will decrease coverage by 0.01%. The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #329      +/-   ##
============================================
- Coverage     57.17%   57.15%   -0.02%     
  Complexity      742      742              
============================================
  Files           131      131              
  Lines          5445     5445              
  Branches        508      508              
============================================
- Hits           3113     3112       -1     
- Misses         2103     2104       +1     
  Partials        229      229              
Impacted Files Coverage Δ
...org/litote/kmongo/coroutine/CoroutineCollection.kt 49.39% <0.00%> (ø)
...litote/kmongo/coroutine/CoroutineClientSessions.kt 75.00% <0.00%> (-25.00%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d0133a9...d9bc2ae. Read the comment docs.

zigzago commented 2 years ago

Thank you for the PR