From 6d5734447048552c46a5c46dbf630f0e5be50765 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 7 Jul 2022 19:33:41 +0200 Subject: build(trace/parquet): Ignore reload4j dependency This change updates the build configuration to ignore the reload4j dependency that was recently added to the hadoop-common module. Reload4j replaces the old unmaintained log4j1 module. However, since we expose this module as a library, we do not want to include a logging implementation in the dependencies. Currently, there are already instances where this new dependency leads to duplicate logging implementations on the classpath. --- opendc-trace/opendc-trace-parquet/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'opendc-trace') diff --git a/opendc-trace/opendc-trace-parquet/build.gradle.kts b/opendc-trace/opendc-trace-parquet/build.gradle.kts index 9b1e1273..2217a017 100644 --- a/opendc-trace/opendc-trace-parquet/build.gradle.kts +++ b/opendc-trace/opendc-trace-parquet/build.gradle.kts @@ -33,8 +33,8 @@ dependencies { exclude(group = "org.apache.hadoop") } api(libs.hadoop.common) { - exclude(group = "org.slf4j", module = "slf4j-log4j12") - exclude(group = "log4j") + exclude(group = "org.slf4j", module = "slf4j-reload4j") + exclude(group = "ch.qos.reload4j", module = "reload4j") exclude(group = "org.apache.hadoop") exclude(group = "org.apache.curator") exclude(group = "org.apache.zookeeper") -- cgit v1.2.3 From 0f7773e8546ad2fdc6ea44a1bbc0a5d82399667f Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 29 Jul 2022 16:59:16 +0200 Subject: fix(trace/api): Do not cache trace formats This change updates the TraceFormat lookup algorithm to prevent caching the available trace format on first access. Since the result of ServiceLoader depends on the Thread's context ClassLoader, they may differ between different threads. Furthermore, ServiceLoader maintains its own thread-local cache, so we can instead utilize that cache and always use the results returned by it. --- .../src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'opendc-trace') diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt index eff6fa83..26e81cf8 100644 --- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt +++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt @@ -90,18 +90,20 @@ public interface TraceFormat { */ public companion object { /** - * A list of [TraceFormat] that are available on this system. + * Obtain a list of [TraceFormat] that are available in the current thread context. */ @JvmStatic - public val installedProviders: List by lazy { - val loader = ServiceLoader.load(TraceFormat::class.java) - loader.toList() + public fun getInstalledProviders(): Iterable { + return ServiceLoader.load(TraceFormat::class.java) } /** * Obtain a [TraceFormat] implementation by [name]. */ @JvmStatic - public fun byName(name: String): TraceFormat? = installedProviders.find { it.name == name } + public fun byName(name: String): TraceFormat? { + val loader = ServiceLoader.load(TraceFormat::class.java) + return loader.find { it.name == name } + } } } -- cgit v1.2.3