fix(metadata-service): stop overriding kafka registry props with empty values (#4604)

Co-authored-by: jsotelo <javier.sotelo@viasat.com>
This commit is contained in:
Javier Sotelo 2022-04-11 22:02:47 -07:00 committed by GitHub
parent e7c5eb357c
commit fa4cc3ad31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -65,7 +65,12 @@ public class DataHubKafkaProducerFactory {
Map<String, Object> props = properties.buildProducerProperties();
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, schemaRegistryConfig.getSerializer().getName());
props.putAll(schemaRegistryConfig.getProperties());
// Override KafkaProperties with SchemaRegistryConfig only for non-empty values
schemaRegistryConfig.getProperties().entrySet()
.stream()
.filter(entry -> entry.getValue() != null && !entry.getValue().toString().isEmpty())
.forEach(entry -> props.put(entry.getKey(), entry.getValue()));
return new KafkaProducer<>(props);
}

View File

@ -76,7 +76,12 @@ public class KafkaEventConsumerFactory {
consumerProps.setValueDeserializer(schemaRegistryConfig.getDeserializer());
Map<String, Object> props = properties.buildConsumerProperties();
props.putAll(schemaRegistryConfig.getProperties());
// Override KafkaProperties with SchemaRegistryConfig only for non-empty values
schemaRegistryConfig.getProperties().entrySet()
.stream()
.filter(entry -> entry.getValue() != null && !entry.getValue().toString().isEmpty())
.forEach(entry -> props.put(entry.getKey(), entry.getValue()));
ConcurrentKafkaListenerContainerFactory<String, GenericRecord> factory =
new ConcurrentKafkaListenerContainerFactory<>();