You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Chia-Ping Tsai (Jira)" <ji...@apache.org> on 2026/09/28 09:39:00 UTC
[jira] [Resolved] (KAFKA-21093) Ensure all ConfigProviders get closed before throwing exception
[ https://issues.apache.org/jira/browse/KAFKA-21093?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chia-Ping Tsai resolved KAFKA-21093.
------------------------------------
Fix Version/s: 4.5.0
Resolution: Fixed
> 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
> Fix For: 4.5.0
>
>
> 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)