Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close Input/Output streams #2319

Merged
merged 2 commits into from Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/src/main/kotlin/DokkaVersion.kt
Expand Up @@ -4,7 +4,8 @@ import java.util.*

object DokkaVersion {
val version: String by lazy {
val stream = javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties")
Properties().apply { load(stream) }.getProperty("dokka-version")
javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties").use { stream ->
Properties().apply { load(stream) }.getProperty("dokka-version")
}
}
}
Expand Up @@ -189,8 +189,12 @@ class KorteJavadocRenderer(val context: DokkaContext, resourceDir: String) :

private class ResourceTemplateProvider(val basePath: String) : TemplateProvider {
override suspend fun get(template: String): String =
javaClass.classLoader.getResourceAsStream("$basePath/$template")?.bufferedReader()?.lines()?.toArray()
?.joinToString("\n") ?: throw IllegalStateException("Template not found: $basePath/$template")
javaClass.classLoader.getResourceAsStream("$basePath/$template")?.use { stream ->
stream.bufferedReader()
.lines()
.toArray()
.joinToString("\n")
} ?: throw IllegalStateException("Template not found: $basePath/$template")
}

}