aboutsummaryrefslogtreecommitdiff
path: root/core/test-api/src/main
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-01-31 18:38:09 +0100
committerGitHub <noreply@github.com>2023-01-31 18:38:09 +0100
commitfe360f7fadc7173be3ae170778a93ebd01962149 (patch)
tree25ea1be7e75ffd3c3235cd8ab4109bb26c5b2ad0 /core/test-api/src/main
parenteb54d69a5cd8e27b1235a23b9098e285c408cb23 (diff)
downloaddokka-fe360f7fadc7173be3ae170778a93ebd01962149.tar.gz
dokka-fe360f7fadc7173be3ae170778a93ebd01962149.tar.bz2
dokka-fe360f7fadc7173be3ae170778a93ebd01962149.zip
Make implementations of DokkaLogger thread-safe (#2827)
Diffstat (limited to 'core/test-api/src/main')
-rw-r--r--core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
index 0bc66a2b..e70200a7 100644
--- a/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
+++ b/core/test-api/src/main/kotlin/testApi/logger/TestLogger.kt
@@ -1,24 +1,28 @@
package org.jetbrains.dokka.testApi.logger
import org.jetbrains.dokka.utilities.DokkaLogger
+import java.util.Collections
+/*
+ * Even in tests it be used in a concurrent environment, so needs to be thread safe
+ */
class TestLogger(private val logger: DokkaLogger) : DokkaLogger {
override var warningsCount: Int by logger::warningsCount
override var errorsCount: Int by logger::errorsCount
- private var _debugMessages = mutableListOf<String>()
+ private var _debugMessages = synchronizedMutableListOf<String>()
val debugMessages: List<String> get() = _debugMessages.toList()
- private var _infoMessages = mutableListOf<String>()
+ private var _infoMessages = synchronizedMutableListOf<String>()
val infoMessages: List<String> get() = _infoMessages.toList()
- private var _progressMessages = mutableListOf<String>()
+ private var _progressMessages = synchronizedMutableListOf<String>()
val progressMessages: List<String> get() = _progressMessages.toList()
- private var _warnMessages = mutableListOf<String>()
+ private var _warnMessages = synchronizedMutableListOf<String>()
val warnMessages: List<String> get() = _warnMessages.toList()
- private var _errorMessages = mutableListOf<String>()
+ private var _errorMessages = synchronizedMutableListOf<String>()
val errorMessages: List<String> get() = _errorMessages.toList()
override fun debug(message: String) {
@@ -45,4 +49,6 @@ class TestLogger(private val logger: DokkaLogger) : DokkaLogger {
_errorMessages.add(message)
logger.error(message)
}
+
+ private fun <T> synchronizedMutableListOf(): MutableList<T> = Collections.synchronizedList(mutableListOf())
}