You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Dmitrii Miliukov (JIRA)" <ji...@apache.org> on 2019/07/23 07:59:00 UTC

[jira] [Created] (LOG4J2-2662) Composite configuration unable to recover after loading corrupted XML

Dmitrii Miliukov created LOG4J2-2662:
----------------------------------------

             Summary: 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
         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
(v7.6.14#76016)