diff --git a/Sources/Kafka/KafkaAcknowledgedMessage.swift b/Sources/Kafka/KafkaAcknowledgedMessage.swift index 8f529acc..6b3c0750 100644 --- a/Sources/Kafka/KafkaAcknowledgedMessage.swift +++ b/Sources/Kafka/KafkaAcknowledgedMessage.swift @@ -40,9 +40,16 @@ public struct KafkaAcknowledgedMessage { throw KafkaError.rdKafkaError(wrapping: rdKafkaMessage.err) } + #if swift(>=6.0) + guard let topic = String(validatingCString: rd_kafka_topic_name(rdKafkaMessage.rkt)) else { + fatalError("Received topic name that is non-valid UTF-8") + } + #else guard let topic = String(validatingUTF8: rd_kafka_topic_name(rdKafkaMessage.rkt)) else { fatalError("Received topic name that is non-valid UTF-8") } + #endif + self.topic = topic self.partition = KafkaPartition(rawValue: Int(rdKafkaMessage.partition)) diff --git a/Sources/Kafka/KafkaConsumerMessage.swift b/Sources/Kafka/KafkaConsumerMessage.swift index c4a6570a..58aba5be 100644 --- a/Sources/Kafka/KafkaConsumerMessage.swift +++ b/Sources/Kafka/KafkaConsumerMessage.swift @@ -52,9 +52,15 @@ public struct KafkaConsumerMessage { } } + #if swift(>=6.0) + guard let topic = String(validatingCString: rd_kafka_topic_name(rdKafkaMessage.rkt)) else { + fatalError("Received topic name that is non-valid UTF-8") + } + #else guard let topic = String(validatingUTF8: rd_kafka_topic_name(rdKafkaMessage.rkt)) else { fatalError("Received topic name that is non-valid UTF-8") } + #endif self.topic = topic self.partition = KafkaPartition(rawValue: Int(rdKafkaMessage.partition)) diff --git a/Sources/Kafka/RDKafka/RDKafkaClient.swift b/Sources/Kafka/RDKafka/RDKafkaClient.swift index 9e62f945..77ef5510 100644 --- a/Sources/Kafka/RDKafka/RDKafkaClient.swift +++ b/Sources/Kafka/RDKafka/RDKafkaClient.swift @@ -20,7 +20,7 @@ import Logging /// Base class for ``KafkaProducer`` and ``KafkaConsumer``, /// which is used to handle the connection to the Kafka ecosystem. @_spi(Internal) -public final class RDKafkaClient: Sendable { +public final class RDKafkaClient: @unchecked Sendable { // Default size for Strings returned from C API static let stringSize = 1024 diff --git a/Sources/Kafka/RDKafka/RDKafkaTopicHandles.swift b/Sources/Kafka/RDKafka/RDKafkaTopicHandles.swift index dc9e6ff8..0187e746 100644 --- a/Sources/Kafka/RDKafka/RDKafkaTopicHandles.swift +++ b/Sources/Kafka/RDKafka/RDKafkaTopicHandles.swift @@ -16,7 +16,7 @@ import Crdkafka import NIOConcurrencyHelpers /// Swift class that matches topic names with their respective `rd_kafka_topic_t` handles. -internal final class RDKafkaTopicHandles: Sendable { +internal final class RDKafkaTopicHandles: @unchecked Sendable { private let _internal: NIOLockedValueBox<[String: OpaquePointer]> // Note: we retain the client to ensure it does not get diff --git a/docker/docker-compose.2204.510.yaml b/docker/docker-compose.2204.510.yaml index 17acb143..2839ddcb 100644 --- a/docker/docker-compose.2204.510.yaml +++ b/docker/docker-compose.2204.510.yaml @@ -6,7 +6,8 @@ services: image: swift-kafka-client:22.04-5.10 build: args: - base_image: "swiftlang/swift:nightly-5.10-jammy" + ubuntu_version: "jammy" + swift_version: "5.10" build: image: swift-kafka-client:22.04-5.10