File tree 2 files changed +12
-2
lines changed
integration-testing/src/withGuavaTest/kotlin
kotlinx-coroutines-core/jvm/src
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ package kotlinx.coroutines
7
7
import com.google.common.reflect.*
8
8
import kotlinx.coroutines.*
9
9
import org.junit.Test
10
+ import java.io.Serializable
11
+ import java.lang.reflect.Modifier
10
12
import kotlin.test.*
11
13
12
14
class ListAllCoroutineThrowableSubclassesTest {
@@ -31,13 +33,21 @@ class ListAllCoroutineThrowableSubclassesTest {
31
33
" kotlinx.coroutines.channels.ClosedReceiveChannelException" ,
32
34
" kotlinx.coroutines.flow.internal.ChildCancelledException" ,
33
35
" kotlinx.coroutines.flow.internal.AbortFlowException" ,
34
- )
36
+ )
35
37
36
38
@Test
37
39
fun testThrowableSubclassesAreSerializable () {
38
40
val classes = ClassPath .from(this .javaClass.classLoader)
39
41
.getTopLevelClassesRecursive(" kotlinx.coroutines" );
40
42
val throwables = classes.filter { Throwable ::class .java.isAssignableFrom(it.load()) }.map { it.toString() }
43
+ for (throwable in throwables) {
44
+ for (field in throwable.javaClass.declaredFields) {
45
+ if (Modifier .isStatic(field.modifiers)) continue
46
+ val type = field.type
47
+ assertTrue(type.isPrimitive || Serializable ::class .java.isAssignableFrom(type),
48
+ " Throwable $throwable has non-serializable field $field " )
49
+ }
50
+ }
41
51
assertEquals(knownThrowables.sorted(), throwables.sorted())
42
52
}
43
53
}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ private val handlers: List<CoroutineExceptionHandler> = ServiceLoader.load(
29
29
* The purpose of this exception is to add an otherwise inaccessible diagnostic information and to
30
30
* be able to poke the failing coroutine context in the debugger.
31
31
*/
32
- private class DiagnosticCoroutineContextException (private val context : CoroutineContext ) : RuntimeException() {
32
+ private class DiagnosticCoroutineContextException (@Transient private val context : CoroutineContext ) : RuntimeException() {
33
33
override fun getLocalizedMessage (): String {
34
34
return context.toString()
35
35
}
You can’t perform that action at this time.
0 commit comments