mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Fix streaming subscription bug. (#2983)
This commit is contained in:
parent
ca55c80bfc
commit
1c7def8e12
@ -5,6 +5,7 @@ import net.corda.behave.file.currentDirectory
|
||||
import net.corda.behave.logging.getLogger
|
||||
import net.corda.behave.process.output.OutputListener
|
||||
import rx.Observable
|
||||
import rx.Subscriber
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
@ -143,8 +144,9 @@ open class Command(
|
||||
return exitCode
|
||||
}
|
||||
|
||||
fun use(action: (Command, Observable<String>) -> Unit = { _, _ -> }): Int {
|
||||
fun use(subscriber: Subscriber<String>, action: (Command, Observable<String>) -> Unit = { _, _ -> }): Int {
|
||||
try {
|
||||
output.subscribe(subscriber)
|
||||
start()
|
||||
action(this, output)
|
||||
} finally {
|
||||
|
@ -21,8 +21,7 @@ class CommandTests {
|
||||
@Test
|
||||
fun `output stream for command can be observed`() {
|
||||
val subscriber = TestSubscriber<String>()
|
||||
val exitCode = Command(listOf("ls", "/")).use { _, output ->
|
||||
output.subscribe(subscriber)
|
||||
val exitCode = Command(listOf("ls", "/")).use(subscriber) { _, output ->
|
||||
subscriber.awaitTerminalEvent()
|
||||
subscriber.assertCompleted()
|
||||
subscriber.assertNoErrors()
|
||||
|
Loading…
Reference in New Issue
Block a user