You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2022/06/09 12:51:24 UTC
[logging-log4j2] branch release-2.x updated: [LOG4J2-3531] Check if XInclude is supported
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new e0d01e05ac [LOG4J2-3531] Check if XInclude is supported
e0d01e05ac is described below
commit e0d01e05ac819046be153a93309d240fcbb1bd38
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Thu Jun 9 14:51:02 2022 +0200
[LOG4J2-3531] Check if XInclude is supported
Xerces does not check if XInclude is supported until the
`DocumentBuilderFactory` is instantiated.
---
.../logging/log4j/core/config/xml/XmlConfiguration.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
index 519fc94b3d..75358ae8d7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
@@ -204,9 +204,6 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
private static void setFeature(final DocumentBuilderFactory factory, final String featureName, final boolean value) {
try {
factory.setFeature(featureName, value);
- // LOG4J2-3531: Xerces only throw when creating a factory.
- // In newer versions 'setFeature' does this automatically.
- factory.newDocumentBuilder();
} catch (final ParserConfigurationException e) {
LOGGER.warn("The DocumentBuilderFactory [{}] does not support the feature [{}]: {}", factory,
featureName, e);
@@ -226,9 +223,13 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu
// Alternative: We set if a system property on the command line is set, for example:
// -DLog4j.XInclude=true
factory.setXIncludeAware(true);
- } catch (final UnsupportedOperationException e) {
+ // LOG4J2-3531: Xerces only checks if the feature is supported when creating a factory. To reproduce:
+ // -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XML11NonValidatingConfiguration
+ factory.newDocumentBuilder();
+ } catch (final UnsupportedOperationException | ParserConfigurationException e) {
+ factory.setXIncludeAware(false);
LOGGER.warn("The DocumentBuilderFactory [{}] does not support XInclude: {}", factory, e);
- } catch (@SuppressWarnings("ErrorNotRethrown") final AbstractMethodError | NoSuchMethodError err) {
+ } catch (final AbstractMethodError | NoSuchMethodError err) {
LOGGER.warn("The DocumentBuilderFactory [{}] is out of date and does not support XInclude: {}", factory,
err);
}