[
https://issues.apache.org/jira/browse/KAFKA-21093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lucy Liu reassigned KAFKA-21093:
--------------------------------
Assignee: Lucy Liu (was: Chia-Ping Tsai)
> Ensure all ConfigProviders get closed before throwing exception
> ---------------------------------------------------------------
>
> Key: KAFKA-21093
> URL: https://issues.apache.org/jira/browse/KAFKA-21093
> Project: Kafka
> Issue Type: Bug
> Reporter: Chia-Ping Tsai
> Assignee: Lucy Liu
> Priority: Minor
>
> There are two paths where providers are created and configured but never
> closed. We should keep the resources clean as much as possible 😊
> {code:java}
> Â Â Â Â Map<String, ConfigProvider> configProviderInstances = new HashMap<>();
> Â Â Â Â for (Map.Entry<String, String> entry : providerMap.entrySet()) {
> Â Â Â Â Â Â try {
> Â Â Â Â Â Â Â Â String prefix = CONFIG_PROVIDERS_CONFIG + "." +
> entry.getKey() + CONFIG_PROVIDERS_PARAM;
> Â Â Â Â Â Â Â Â Map<String, ?> configProperties =
> configProviderProperties(prefix, providerConfigProperties);
> Â Â Â Â Â Â Â Â ConfigProvider provider = Utils.newInstance(entry.getValue(),
> ConfigProvider.class);
> Â Â Â Â Â Â Â Â provider.configure(configProperties);
> Â Â Â Â Â Â Â Â configProviderInstances.put(entry.getKey(), provider);
> Â Â Â Â Â Â } catch (ClassNotFoundException e) {
> Â Â Â Â Â Â Â Â log.error("Could not load config provider class {}",
> entry.getValue(), e);
> Â Â Â Â Â Â Â Â throw new
> ConfigException(providerClassProperty(entry.getKey()), entry.getValue(),
> "Could not load config provider class or one of its dependencies");
> Â Â Â Â Â Â }
> Â Â Â Â } {code}
> {code:java}
> Â Â Â Â if (!providers.isEmpty()) { Â Â Â Â Â Â ConfigTransformer
> configTransformer = new ConfigTransformer(providers); Â Â Â Â Â Â
> ConfigTransformerResult result =
> configTransformer.transform(indirectVariables); Â Â Â Â Â Â if
> (!result.data().isEmpty()) { Â Â Â Â Â Â Â Â
> resolvedOriginals.putAll(result.data()); Â Â Â Â Â Â } Â Â Â Â } Â Â Â Â
> providers.values().forEach(x -> Utils.closeQuietly(x, "config provider"));
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)