[ https://issues.apache.org/jira/browse/LOG4J2-2662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dmitrii Miliukov updated LOG4J2-2662: ------------------------------------- Priority: Major (was: Critical) > Composite configuration unable to recover after loading corrupted XML > --------------------------------------------------------------------- > > Key: LOG4J2-2662 > URL: https://issues.apache.org/jira/browse/LOG4J2-2662 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Affects Versions: 2.12.0 > Reporter: Dmitrii Miliukov > Priority: Major > Attachments: CompositeConfiguration_reconfigure.patch > > > How to reproduce: > 1) Use composite configuration consisting of XML configurations with > monitorInterval set to reload changes in runtime > 2) Start the app and check that logs are written > 3) Change one of XML configurations (i.e. one with root logger configuration) > to not valid XML > 4) After changes will be loaded events will be redirected to console > 5) Further changes of broken configuration file aren't watched anymore, only > JVM restart could help > Reason of that is how CompositeConfiguration handles reconfiguration: for > each underlying configuration it will try to get new config via > ConfigurationFactory. XML factory (didn't check the others) will return new > configuration, and if source is broken it will be the default one. > ConfiguratonFileWatcher for XML config will be registered only if config is > valid and has monitorInterval property, so no further changes to this file > will not be loaded until JVM restart. > {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(); > Configuration currentConfig = config; > if (sourceURI == null) { > LOGGER.warn("Unable to determine URI for configuration {}, > changes to it will be ignored", > config.getName()); > } else { > currentConfig = factory.getConfiguration(getLoggerContext(), > config.getName(), sourceURI); > if (currentConfig == null) { > LOGGER.warn("Unable to reload configuration {}, changes to it > will be ignored", config.getName()); > } > } > configs.add((AbstractConfiguration) currentConfig); > } > return new CompositeConfiguration(configs); > } > {code} > This might be fixed with two changes: > 1) CompositeConfiguration should use reconfigure() on underlying > configurations if possible > 2) If any of the reconfigure() calls returns null, then null should be > returned so all changes will be ignored -- This message was sent by Atlassian Jira (v8.3.4#803005)