diff options
author | Ramon <ramon.sadornilrivera@mapbox.com> | 2023-04-17 16:19:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 15:19:41 +0200 |
commit | 115a31829ffa0268c613dd55711d756bc134db5e (patch) | |
tree | a1019513815dfe54ceb10684c5ff9438d4900a7a /runners | |
parent | 5e8120257f842b1abc767143abcb826c80e6e43d (diff) | |
download | dokka-115a31829ffa0268c613dd55711d756bc134db5e.tar.gz dokka-115a31829ffa0268c613dd55711d756bc134db5e.tar.bz2 dokka-115a31829ffa0268c613dd55711d756bc134db5e.zip |
Capture throwable inside generateDocumentation thread (#2935)
Fixes #2934
Diffstat (limited to 'runners')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt index d4314e37..066374e5 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/AbstractDokkaTask.kt @@ -20,6 +20,7 @@ import org.gradle.work.DisableCachingByDefault import org.jetbrains.dokka.* import org.jetbrains.dokka.plugability.ConfigurableBlock import org.jetbrains.dokka.plugability.DokkaPlugin +import java.util.concurrent.atomic.AtomicReference import java.util.function.BiConsumer import kotlin.reflect.full.createInstance @@ -203,14 +204,17 @@ abstract class AbstractDokkaTask : DefaultTask() { internal open fun generateDocumentation() { DokkaBootstrap(runtime, DokkaBootstrapImpl::class).apply { configure(buildDokkaConfiguration().toCompactJsonString(), createProxyLogger()) + val uncaughtExceptionHolder = AtomicReference<Throwable?>() /** * Run in a new thread to avoid memory leaks that are related to ThreadLocal (that keeps `URLCLassLoader`) * Currently, all `ThreadLocal`s leaking are in the compiler/IDE codebase. */ Thread { generate() }.apply { + setUncaughtExceptionHandler { _, throwable -> uncaughtExceptionHolder.set(throwable) } start() join() } + uncaughtExceptionHolder.get()?.let { throw it } } } |