From ed609ee9ac75f8cc0caecc02c6f4d5dbe03d8938 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Tue, 11 Jun 2024 15:23:55 +0200 Subject: [PATCH] Fix linting errors --- buildSrc/src/main/kotlin/Versions.kt | 6 ++---- radar-gateway/build.gradle.kts | 2 +- .../gateway/inject/SchemaRetrieverFactory.kt | 20 ++++++++----------- .../org/radarbase/gateway/io/AvroProcessor.kt | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index e9858d3..f72c017 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,6 +1,6 @@ @Suppress("ConstPropertyName") object Versions { - const val project = "0.7.1-SNAPSHOT" + const val project = "0.7.2-SNAPSHOT" const val java = 17 const val kotlin = "1.9.22" @@ -9,7 +9,7 @@ object Versions { const val ktor = "2.3.10" const val radarJersey = "0.11.1" const val radarCommons = "1.1.2" - const val radarSchemas = "0.8.7" + const val radarSchemas = "0.8.8" const val jackson = "2.15.3" const val slf4j = "2.0.13" const val log4j2 = "2.23.1" @@ -22,6 +22,4 @@ object Versions { const val mockitoKotlin = "5.3.1" const val grizzly = "4.0.2" const val hamcrest = "2.2" - - const val wrapper = "8.4" } diff --git a/radar-gateway/build.gradle.kts b/radar-gateway/build.gradle.kts index 28f03de..09dfe2c 100644 --- a/radar-gateway/build.gradle.kts +++ b/radar-gateway/build.gradle.kts @@ -1,5 +1,5 @@ +import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter import java.time.Duration -import com.github.jk1.license.filter.* plugins { application diff --git a/radar-gateway/src/main/kotlin/org/radarbase/gateway/inject/SchemaRetrieverFactory.kt b/radar-gateway/src/main/kotlin/org/radarbase/gateway/inject/SchemaRetrieverFactory.kt index 8f9ddc6..41503a8 100644 --- a/radar-gateway/src/main/kotlin/org/radarbase/gateway/inject/SchemaRetrieverFactory.kt +++ b/radar-gateway/src/main/kotlin/org/radarbase/gateway/inject/SchemaRetrieverFactory.kt @@ -3,20 +3,15 @@ package org.radarbase.gateway.inject import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig.USER_INFO_CONFIG import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_USER_INFO_CONFIG -import io.ktor.client.HttpClient -import io.ktor.client.engine.cio.CIO import io.ktor.client.plugins.auth.Auth import io.ktor.client.plugins.auth.providers.BasicAuthCredentials import io.ktor.client.plugins.auth.providers.basic import jakarta.ws.rs.core.Context -import java.util.function.Supplier -import kotlin.time.Duration.Companion.seconds import org.radarbase.config.ServerConfig import org.radarbase.gateway.config.GatewayConfig import org.radarbase.producer.io.timeout import org.radarbase.producer.schema.SchemaRetriever import org.radarbase.producer.schema.SchemaRetriever.Companion.schemaRetriever -import org.slf4j.LoggerFactory import java.util.function.Supplier import kotlin.time.Duration.Companion.seconds @@ -37,18 +32,20 @@ class SchemaRetrieverFactory( ?: config.kafka.serialization[USER_INFO_CONFIG].asNonEmptyString() return schemaRetriever(baseUrl = server.urlString) { - if (basicCredentials != null && basicCredentials.contains(':')) { - val (apiKey, apiSecret) = basicCredentials.split(':', limit = 2) - httpClient = HttpClient(CIO) { - timeout(30.seconds) + httpClient { + if (basicCredentials != null && basicCredentials.contains(':')) { install(Auth) { basic { - sendWithoutRequest { true } credentials { - BasicAuthCredentials(username = apiKey, password = apiSecret) + val (username, password) = basicCredentials.split(':', limit = 2) + BasicAuthCredentials( + username = username, + password = password, + ) } } } + timeout(30.seconds) } } } @@ -56,6 +53,5 @@ class SchemaRetrieverFactory( companion object { private fun Any?.asNonEmptyString(): String? = (this as? String)?.takeIf { it.isNotEmpty() } - private val logger = LoggerFactory.getLogger(SchemaRetrieverFactory::class.java) } } diff --git a/radar-gateway/src/main/kotlin/org/radarbase/gateway/io/AvroProcessor.kt b/radar-gateway/src/main/kotlin/org/radarbase/gateway/io/AvroProcessor.kt index 5d63eb9..935d9e0 100644 --- a/radar-gateway/src/main/kotlin/org/radarbase/gateway/io/AvroProcessor.kt +++ b/radar-gateway/src/main/kotlin/org/radarbase/gateway/io/AvroProcessor.kt @@ -132,7 +132,7 @@ class AvroProcessor( "Schema ID not found in subject", ) } else { - throw HttpBadGatewayException("cannot get data from schema registry: ${ex.javaClass.simpleName}") + throw HttpBadGatewayException("cannot get data from schema registry: $ex") } } createMapping(topic, ofValue, parsedSchema.schema)