KafkaProducer.kafkaHandleToMessageCallback is a dictionary that is accessed by multiple threads. The code in KafkaProducer used a semaphore to prevent concurrent access, but this was missed in accesses outside of that class (such as in KafkaConfig.setDeliveredMessageCallback()).
KafkaProducer.kafkaHandleToMessageCallback
is a dictionary that is accessed by multiple threads. The code in KafkaProducer used a semaphore to prevent concurrent access, but this was missed in accesses outside of that class (such as inKafkaConfig.setDeliveredMessageCallback()
).This replaces the semaphore with a computed property and NSLock approach similar to https://github.com/IBM-Swift/LoggerAPI/pull/47 .