Skip to content

Commit a6ec3f2

Browse files
committed
Revert "Eagerly load CoroutineExceptionHandler and load corresponding service (#2957)"
This reverts commit 0b65246.
1 parent 70d0ec7 commit a6ec3f2

File tree

5 files changed

+2
-27
lines changed

5 files changed

+2
-27
lines changed

kotlinx-coroutines-core/common/src/CoroutineExceptionHandler.kt

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
45
package kotlinx.coroutines
56

67
import kotlin.coroutines.*
7-
import kotlin.jvm.*
88

99
internal expect fun handleCoroutineExceptionImpl(context: CoroutineContext, exception: Throwable)
1010

11-
/**
12-
* JVM kludge: trigger loading of all the classes and service loading
13-
* **before** any exception occur because it may be OOM, SOE or VerifyError
14-
*/
15-
internal expect fun initializeDefaultExceptionHandlers()
16-
1711
/**
1812
* Helper function for coroutine builder implementations to handle uncaught and unexpected exceptions in coroutines,
1913
* that could not be otherwise handled in a normal way through structured concurrency, saving them to a future, and

kotlinx-coroutines-core/common/src/Job.kt

+1-7
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ public interface Job : CoroutineContext.Element {
113113
/**
114114
* Key for [Job] instance in the coroutine context.
115115
*/
116-
public companion object Key : CoroutineContext.Key<Job> {
117-
init {
118-
// `Job` will necessarily be accessed early, so this is as good a place as any for the
119-
// initialization logic that we want to happen as soon as possible
120-
initializeDefaultExceptionHandlers()
121-
}
122-
}
116+
public companion object Key : CoroutineContext.Key<Job>
123117

124118
// ------------ state query ------------
125119

kotlinx-coroutines-core/js/src/CoroutineExceptionHandlerImpl.kt

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ package kotlinx.coroutines
66

77
import kotlin.coroutines.*
88

9-
internal actual fun initializeDefaultExceptionHandlers() {
10-
// Do nothing
11-
}
12-
139
internal actual fun handleCoroutineExceptionImpl(context: CoroutineContext, exception: Throwable) {
1410
// log exception
1511
console.error(exception)

kotlinx-coroutines-core/jvm/src/CoroutineExceptionHandlerImpl.kt

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ private val handlers: List<CoroutineExceptionHandler> = ServiceLoader.load(
2222
CoroutineExceptionHandler::class.java.classLoader
2323
).iterator().asSequence().toList()
2424

25-
internal actual fun initializeDefaultExceptionHandlers() {
26-
// Load CEH and handlers
27-
CoroutineExceptionHandler
28-
}
29-
3025
/**
3126
* Private exception without stacktrace that is added to suppressed exceptions of the original exception
3227
* when it is reported to the last-ditch current thread 'uncaughtExceptionHandler'.

kotlinx-coroutines-core/native/src/CoroutineExceptionHandlerImpl.kt

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ package kotlinx.coroutines
77
import kotlin.coroutines.*
88
import kotlin.native.*
99

10-
internal actual fun initializeDefaultExceptionHandlers() {
11-
// Do nothing
12-
}
13-
1410
@OptIn(ExperimentalStdlibApi::class)
1511
internal actual fun handleCoroutineExceptionImpl(context: CoroutineContext, exception: Throwable) {
1612
// log exception

0 commit comments

Comments
 (0)