Source:
<code>static Map<String, Long> getExternalResources(Configuration config, String suffix) { final Set<String> resourceSet = getExternalResourceSet(config); LOG.info("Enabled external resources: {}", resourceSet); if (resourceSet.isEmpty()) { return Collections.emptyMap(); } final Map<String, Long> externalResourceConfigs = new HashMap<>(); for (String resourceName: resourceSet) { final ConfigOption<Long> amountOption = key(ExternalResourceOptions.keyWithResourceNameAndSuffix(resourceName, ExternalResourceOptions.EXTERNAL_RESOURCE_AMOUNT_SUFFIX)) .longType() .defaultValue(0L); final ConfigOption<String> configKeyOption = key(ExternalResourceOptions.keyWithResourceNameAndSuffix(resourceName, suffix)) .stringType() .noDefaultValue(); final String configKey = config.getString(configKeyOption); final Long amount = config.getLong(amountOption); if (StringUtils.isNullOrWhitespaceOnly(configKey)) { LOG.warn("Could not find valid for {}", configKeyOption.key(), resourceName); break; } if (amount <= 0) { <START> LOG.warn("The amount of the should be configured with a positive value.", resourceName); <END> break; } if (externalResourceConfigs.put(configKey, amount) != null) { LOG.warn("Duplicate config key occurred for external resources, the one with amount will overwrite the value.", configKey, amount); } else { LOG.info("Add external resources configs with key value {}.", configKey, amount); } } return externalResourceConfigs; }</code><technical_language>separate cases amount is configured amount is configured illegal value</technical_language>

Target:
public static Map<String, Long> getExternalResources(Configuration config, String suffix) { final Set<String> resourceSet = getExternalResourceSet(config); LOG.info("Enabled external resources: {}", resourceSet); if (resourceSet.isEmpty()) { return Collections.emptyMap(); } final Map<String, Long> externalResourceConfigs = new HashMap<>(); for (String resourceName: resourceSet) { final ConfigOption<Long> amountOption = key(ExternalResourceOptions.getAmountConfigOptionForResource(resourceName)) .longType() .noDefaultValue(); final ConfigOption<String> configKeyOption = key(ExternalResourceOptions.getSystemConfigKeyConfigOptionForResource(resourceName, suffix)) .stringType() .noDefaultValue(); final String configKey = config.getString(configKeyOption); final Optional<Long> amountOpt = config.getOptional(amountOption); if (StringUtils.isNullOrWhitespaceOnly(configKey)) { LOG.warn("Could not find valid for {}. Will ignore that resource.", configKeyOption.key(), resourceName); continue; } if (!amountOpt.isPresent()) { LOG.warn("The amount of the should be configured. Will ignore that resource.", resourceName); continue; } else if (amountOpt.get() <= 0) { LOG.warn("The amount of the should be positive while finding {}. Will ignore that resource.", amountOpt.get(), resourceName); continue; } if (externalResourceConfigs.put(configKey, amountOpt.get()) != null) { LOG.warn("Duplicate config key occurred for external resources, the one named with amount will overwrite the value.", configKey, resourceName, amountOpt); } else { LOG.info("Add external resource config for with key value {}.", resourceName, configKey, amountOpt); } } return externalResourceConfigs; }