[
https://issues.apache.org/jira/browse/LOG4J2-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ronald Rivas updated LOG4J2-1912:
---------------------------------
Description:
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:
"if (sourceURI != null)" --> "if (sourceURI == null)"
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 could be seem like this:
@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.warn("Able to reload configuration {}, changes to it
will be completed", config.getName());
configs.add((AbstractConfiguration) currentConfig);
}
} else {
configs.add(config);
}
}
return new CompositeConfiguration(configs);
}
Questions or tips are welcome.
Best regards,
rri
PS: Which criterias must I have to resolve it in the API on my own?
was:
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:
"if (sourceURI != null)" --> "if (sourceURI == null)"
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 could be seem like this:
@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.warn("Able to reload configuration {}, changes to it
will be completed", config.getName());
configs.add((AbstractConfiguration) currentConfig);
}
} else {
configs.add(config);
}
}
return new CompositeConfiguration(configs);
}
Questions or tips are welcome.
Best regards,
rri
> 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, 2.8.2
> Reporter: Ronald Rivas
> Priority: Trivial
> Fix For: 2.8.2
>
> 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:
> "if (sourceURI != null)" --> "if (sourceURI == null)"
> 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 could be seem like this:
> @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.warn("Able to reload configuration {}, changes to
> it will be completed", config.getName());
> configs.add((AbstractConfiguration) currentConfig);
> }
> } else {
> configs.add(config);
> }
> }
> return new CompositeConfiguration(configs);
> }
> Questions or tips are welcome.
> Best regards,
> rri
> PS: Which criterias must I have to resolve it in the API on my own?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)