[ 
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)

Reply via email to