Skip to content

FileWriter is not thread safe #2308

@bingranl

Description

@bingranl

Describe the bug
FileWriter doesn't seem to be thread safe. Android Gradle Plugin integrates with dokka-core and its javadoc plugin to generate javadoc for java/kotlin sources. In order to have more parallelism, we try to launch dokka via gradle workers so that there would more than one dokka generation tasks running at the same time. In this case, we notice test failures(flaky) from FileWriter complaining stream is closed when reading bytes.

see stacktrace

Caused by: java.io.IOException: Stream closed
	at kotlin.io.ByteStreamsKt.copyTo(IOStreams.kt:110)
	at kotlin.io.ByteStreamsKt.copyTo$default(IOStreams.kt:103)
	at kotlin.io.ByteStreamsKt.readBytes(IOStreams.kt:136)
	at org.jetbrains.dokka.base.renderers.FileWriter$copyFromJar$3.invokeSuspend(FileWriter.kt:74)
	at org.jetbrains.dokka.base.renderers.FileWriter$copyFromJar$3.invoke(FileWriter.kt)

I noticed dokka-gradle-plugin doesn't use gradle workers, which is also a sign that dokka-core doesn't is not thread safe.

Expected behaviour
FileWriter/Dokka-core to be thread safe.

Installation

  • Operating system: Linux
  • Build tool: Gradle 7.3.3 Android Gradle plugin 7.2.0-alpha07
  • Dokka version: 1.4.30

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting responseAn issue/PR that cannot be completed without additional information or a discussionbug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions