From c81137d3b6120a6b371b6dbe3c342079a000159b Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 14 Jan 2022 15:20:14 +0100 Subject: [PATCH] XCOMMONS-2349: Improve performance of AttributeFilter in HTMLCleaner * Do not protect the call to XPathFactory.newInstance() as it seems thread-safe after all. --- .../xwiki/xml/internal/html/filter/AttributeFilter.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/internal/html/filter/AttributeFilter.java b/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/internal/html/filter/AttributeFilter.java index e0e2281912..cf6ebb39e1 100644 --- a/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/internal/html/filter/AttributeFilter.java +++ b/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/internal/html/filter/AttributeFilter.java @@ -95,16 +95,12 @@ public void filter(Document document, Map cleaningParameters) xPathFactory = (XPathFactory) executionContext.getProperty(XPathFactory.class.getName()); if (xPathFactory == null) { - synchronized (XPathFactory.class) { - xPathFactory = XPathFactory.newInstance(); - } + xPathFactory = XPathFactory.newInstance(); executionContext.newProperty(XPathFactory.class.getName()).type(XPathFactory.class).inherited() .nonNull().initial(xPathFactory).makeFinal().declare(); } } else { - synchronized (XPathFactory.class) { - xPathFactory = XPathFactory.newInstance(); - } + xPathFactory = XPathFactory.newInstance(); }