-
Notifications
You must be signed in to change notification settings - Fork 40.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KafkaProperties.buildProperties() calls validate before kafkaProducerFactory uses customizers that can still change the validated properties. #41126
Comments
Thanks for the report but I'm afraid I don't think I understand the problem. How can a |
The properties used by kafka producer factory is a combination of the properties generated by the buildProperties method and some customizations. The final set of properties should be validated. The properties set produced by buildProperties may not be valid but after the customizations are applied it may and vice versa. |
The intention of the customization is that it allows you to configure things that cannot be configured using the properties. If you're partially configuring something using properties and then completing and correcting it using a customizer, we'd recommend configuring it all using properties or all using a customizer.
Yes please, it may demonstrate a situation where a split approach is required. If it does, we may want to consider some additional properties to avoid the need. |
Regardless of the intention of the customizer, the best moment to validate the state of a constructed bean is when all configuration has been applied. I consider other approaches a workaround and we already have a workaround on our side. |
That's what we're doing. The validation is being applied to
Thanks. I don't think such a problem exists as there's some separation between the properties and their validation and the customization of a producer factory so I'll close this one. |
KafkaProperties is not a (real) bean, just a properties container/helper. Validation should be at the right moment in the kafkaProducerFactory bean its lifecycle (e.g. afterPropertiesSet) |
The default kafka producer factory bean gets kafka properties by calling KafkaProperties.buildProducerProperties method.
Behind the scenes this calls Ssl.buildProperties method
which calls validate() and prematurely validates some things
but these properties can still be added, modified or deleted by the customizers in the kafkaProducerFactory method
These validations should be done after the customizers.
The text was updated successfully, but these errors were encountered: