Skip to content

Commit

Permalink
Fix GroupBy not rethrowing errors from the upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Oct 29, 2021
1 parent 8bd8b31 commit 844052a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Extensions to the Kotlin Flow library.

```groovy
dependencies {
implementation "com.github.akarnokd:kotlin-flow-extensions:0.0.11"
implementation "com.github.akarnokd:kotlin-flow-extensions:0.0.12"
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.github.akarnokd
VERSION_NAME=0.0.11
VERSION_NAME=0.0.12

POM_ARTIFACT_ID=kotlin-flow-extensions
POM_NAME=Kotlin Flow Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ internal class FlowGroupBy<T, K, V>(
for (group in map.values) {
group.error(ex)
}
throw ex
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/kotlin/hu/akarnokd/kotlin/flow/impl/FlowGroupByTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertThrows
import org.junit.Ignore
import org.junit.Test

Expand Down Expand Up @@ -82,4 +83,31 @@ class FlowGroupByTest {
.assertResultSet(1, 2)
}

@Test
fun mainErrorsNoItems() {
assertThrows(IllegalStateException::class.java) {
runBlocking {
(1..10)
.asFlow()
.map { if(it < 5) throw IllegalStateException("oops") else it }
.groupBy { it % 2 == 0 }
.flatMapMerge { it }
.collect()
}
}
}

@Test
fun mainErrorsSomeItems() {
assertThrows(IllegalStateException::class.java) {
runBlocking {
(1..10)
.asFlow()
.map { if(it > 5) throw IllegalStateException("oops") else it }
.groupBy { it % 2 == 0 }
.flatMapMerge { it }
.collect()
}
}
}
}

0 comments on commit 844052a

Please sign in to comment.