Skip to content

Commit

Permalink
Use existing loadXML method in wdm version detector logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Sep 1, 2023
1 parent e4220e6 commit ef27406
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ protected void logSeekRepo(URL driverUrl) {
log.info("Reading {} to seek {}", driverUrl, getDriverName());
}

protected Document loadXML(InputStream inputStream)
public static Document loadXML(InputStream inputStream)
throws SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package io.github.bonigarcia.wdm.versions;

import static io.github.bonigarcia.wdm.WebDriverManager.loadXML;
import static io.github.bonigarcia.wdm.config.Config.isNullOrEmpty;
import static io.github.bonigarcia.wdm.managers.ChromeDriverManager.MIN_CHROMEDRIVER_IN_CFT;
import static io.github.bonigarcia.wdm.versions.Shell.runAndWait;
Expand Down Expand Up @@ -45,7 +46,6 @@
import java.util.Properties;
import java.util.stream.Collectors;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

Expand Down Expand Up @@ -461,8 +461,7 @@ public static final Optional<String> getWdmVersion(Class<?> clazz) {
}
Path pom = path.resolve("pom.xml");
try (InputStream is = Files.newInputStream(pom)) {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(is);
Document doc = loadXML(is);
doc.getDocumentElement().normalize();
String version = (String) XPathFactory.newInstance()
.newXPath().compile("/project/version")
Expand Down

0 comments on commit ef27406

Please sign in to comment.