You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "R Ri (JIRA)" <ji...@apache.org> on 2017/07/05 11:20:00 UTC
[jira] [Updated] (LOG4J2-1912) CompositeConfiguration: Unable to
determine URI for configuration. However, the reconfiguration is completed.
[ https://issues.apache.org/jira/browse/LOG4J2-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
R Ri updated LOG4J2-1912:
-------------------------
Priority: Major (was: Trivial)
> CompositeConfiguration: Unable to determine URI for configuration. However, the reconfiguration is completed.
> -------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-1912
> URL: https://issues.apache.org/jira/browse/LOG4J2-1912
> Project: Log4j 2
> Issue Type: Bug
> Components: API
> Affects Versions: 2.8.1
> Reporter: R Ri
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Hello everybody,
> I found a possible bug in class CompositeConfiguration: Unable to determine URI for configuration. However, the reconfiguration is completed.
> The solution:
> In line 154, Class CompositeConfiguration [log4j-core-2.8.1.jar] change the condition:
> {code:java}
> if (sourceURI != null)" --> "if (sourceURI == null)
> {code}
> Original code:
> {code:java}
> 145 @Override
> 146 public Configuration reconfigure() {
> 147 LOGGER.debug("Reconfiguring composite configuration");
> 148 final List<AbstractConfiguration> configs = new ArrayList<>();
> 149 final ConfigurationFactory factory = ConfigurationFactory.getInstance();
> 150 for (final AbstractConfiguration config : configurations) {
> 151 final ConfigurationSource source = config.getConfigurationSource();
> 152 final URI sourceURI = source.getURI();
> 153 Configuration currentConfig;
> 154 if (sourceURI != null) {
> 155 LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored",
> 156 config.getName());
> 157 currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
> 158 if (currentConfig == null) {
> 159 LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
> 160 currentConfig = config;
> 161 }
> 162 } else {
> 163 currentConfig = config;
> 164 }
> 165 configs.add((AbstractConfiguration) currentConfig);
> 166
> 167 }
> 168
> 169 return new CompositeConfiguration(configs);
> 170 }
> {code}
> So it makes sense, because after that it will be tried to reload the configuration again, and if it does not work, I get a warn, otherwise is ok.
> The changed code might look like this:
> {code:java}
> @Override
> public Configuration reconfigure() {
> LOGGER.debug("Reconfiguring composite configuration");
> final List<AbstractConfiguration> configs = new ArrayList<>();
> final ConfigurationFactory factory = ConfigurationFactory.getInstance();
> for (final AbstractConfiguration config : configurations) {
> final ConfigurationSource source = config.getConfigurationSource();
> final URI sourceURI = source.getURI();
> if (sourceURI == null) {
> LOGGER.warn("Unable to determine URI for configuration {}, changes to it will be ignored", config.getName());
> Configuration currentConfig = factory.getConfiguration(getLoggerContext(), config.getName(), sourceURI);
> if (currentConfig == null) {
> LOGGER.warn("Unable to reload configuration {}, changes to it will be ignored", config.getName());
> }
> else {
> LOGGER.info("Able to reload configuration {}, changes to it will be completed", config.getName());
> configs.add((AbstractConfiguration) currentConfig);
> }
> } else {
> configs.add(config);
> }
> }
> return new CompositeConfiguration(configs);
> }
> {code}
> Your feedback and questions are welcome. Thanks!
> Best regards,
> rri
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)