Skip to content

Commit

Permalink
Issue #6273: Accessing POM via XPath is very slow
Browse files Browse the repository at this point in the history
- For the simple get() method, simply use DOM methods instead of going through XPath

Signed-off-by: Richard Eckart de Castilho <[email protected]>
  • Loading branch information
reckart committed Sep 17, 2024
1 parent 318805b commit fdbde0d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions biz.aQute.repository/src/aQute/maven/provider/POM.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,15 @@ private boolean isTrue(String other) {
return "true".equalsIgnoreCase(other);
}

private String get(Element dependency, String name, String deflt) throws XPathExpressionException {
String value = xp.evaluate(name, dependency);
if (value == null || value.isEmpty())
return Strings.trim(deflt);
private String get(Element dependency, String name, String deflt) {
var matchingElements = dependency.getElementsByTagName(name);
if (matchingElements.getLength() > 0) {
var value = matchingElements.item(0).getTextContent();
if (value != null && !value.isEmpty())
return Strings.trim(replaceMacros(value));
}

return Strings.trim(replaceMacros(value));
return Strings.trim(deflt);
}

private String getOrSet(String key, String deflt) {
Expand Down

0 comments on commit fdbde0d

Please sign in to comment.