You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some code that after upgrading to v1.1.1 started to have some weird behaviors. I tracked it town to what I believe to be some assumptions made in the tryCopyException method in ExceptionsConstructor.kt
To explain more what exactly I'm seeing, I have an exception:
classIndexException(valname:String, t:Throwable? = null) :
RuntimeException("Index $name does not exist", t)
If that exception happens to be thrown from inside of an rxJava Single, with an await() inside of a coroutineContext (we're migrating some code away from rxJava to coroutines), the exception will end up not being the same when thrown from the await()
For example:
importio.reactivex.Singleimportkotlinx.coroutines.runBlockingimportkotlinx.coroutines.rx2.awaitimportorg.assertj.core.api.Assertions.assertThatimportorg.assertj.core.api.Assertions.catchThrowableOfTypeimportorg.junit.TestclassIndexException(valname:String, t:Throwable? = null) :
RuntimeException("Index $name does not exist", t)
classException_Testing{
@Test
funtest() {
val error = catchThrowableOfType({
runBlocking {
Single.error<IndexException>(IndexException("indexName", Exception())).await()
}
}, IndexException::class.java)
assertThat(error.name).isEqualTo("indexName") // this fails in my setup
}
}
I'm using rxJava version 2.2.7, Kotlin 1.3.21, Coroutine 1.1.1
To get around this for now I've introduced an inline class to introduce a new type for the indexName.
This worked in v1.0.1 and I confirmed that the new behavior starts in 1.1.0
The text was updated successfully, but these errors were encountered:
rpmoore
changed the title
Values getting mixed up in tryCopyException
Exception Constructor parameters getting mixed up in tryCopyException when thrown from rxJava Single
Mar 14, 2019
I have some code that after upgrading to v1.1.1 started to have some weird behaviors. I tracked it town to what I believe to be some assumptions made in the
tryCopyException
method inExceptionsConstructor.kt
To explain more what exactly I'm seeing, I have an exception:
If that exception happens to be thrown from inside of an
rxJava Single
, with anawait()
inside of a coroutineContext (we're migrating some code away from rxJava to coroutines), the exception will end up not being the same when thrown from theawait()
For example:
I'm using rxJava version 2.2.7, Kotlin 1.3.21, Coroutine 1.1.1
To get around this for now I've introduced an inline class to introduce a new type for the
indexName
.This worked in v1.0.1 and I confirmed that the new behavior starts in 1.1.0
The text was updated successfully, but these errors were encountered: