I am using an rx.lang.scala
in a for-comprehension, which i want to fail fast. I also want the resource parameters
to be closed if an exception occurs. Will the doOnTerminate execute properly if you throw the Exception / Throwable, as in the example provided below?
private def createAgreement(parameters: Params, output: ByteArrayOutputStream): Try[Unit] = Try {
output
.usedIn(AgreementCreator(parameters).createAgreement) //Observable.using(resource)(observableFactory, t => { dispose(t); IOUtils.closeQuietly(t) }, disposeEagerly)
.doOnTerminate(parameters.close()) //close resource
.toBlocking
.subscribe(_ => {},
e => throw e,
() => debug("completed"))
}