Skip to content

Commit

Permalink
XCOMMONS-2349: Improve performance of AttributeFilter in HTMLCleaner
Browse files Browse the repository at this point in the history
* Do not protect the call to XPathFactory.newInstance() as it seems thread-safe after all.
  • Loading branch information
michitux committed Jan 14, 2022
1 parent 0afe529 commit c81137d
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,12 @@ public void filter(Document document, Map<String, String> 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();
}


Expand Down

0 comments on commit c81137d

Please sign in to comment.