This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new aefa9599fb Avoid usage of XmlStreamReader (#1256) aefa9599fb is described below commit aefa9599fbc685c16cbfe03d09b68c19f10b4053 Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Fri Sep 22 09:03:47 2023 +0200 Avoid usage of XmlStreamReader (#1256) --- .../repository/metadata/io/DefaultMetadataReader.java | 3 +-- .../settings/PomConstructionWithSettingsTest.java | 18 ++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java index e4f4a97e13..dc5cf5b5a2 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Objects; import org.apache.maven.artifact.repository.metadata.Metadata; -import org.codehaus.plexus.util.xml.XmlStreamReader; /** * Handles deserialization of metadata from some kind of textual format like XML. @@ -44,7 +43,7 @@ public class DefaultMetadataReader implements MetadataReader { public Metadata read(File input, Map<String, ?> options) throws IOException { Objects.requireNonNull(input, "input cannot be null"); - return read(new XmlStreamReader(Files.newInputStream(input.toPath())), options); + return read(Files.newInputStream(input.toPath()), options); } public Metadata read(Reader input, Map<String, ?> options) throws IOException { diff --git a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java index f8630aa397..bb7193d431 100644 --- a/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java +++ b/maven-core/src/test/java/org/apache/maven/settings/PomConstructionWithSettingsTest.java @@ -23,8 +23,10 @@ import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.IOException; -import java.io.Reader; +import java.io.InputStream; +import java.nio.file.Files; +import org.apache.maven.api.settings.InputSource; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.bridge.MavenRepositorySystem; import org.apache.maven.model.Profile; @@ -33,9 +35,8 @@ import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.harness.PomTestWrapper; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; -import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; +import org.apache.maven.settings.v4.SettingsStaxReader; import org.codehaus.plexus.testing.PlexusTest; -import org.codehaus.plexus.util.xml.XmlStreamReader; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; @@ -121,13 +122,10 @@ class PomConstructionWithSettingsTest { } private static Settings readSettingsFile(File settingsFile) throws IOException, XMLStreamException { - Settings settings = null; - - try (Reader reader = new XmlStreamReader(settingsFile)) { - SettingsXpp3Reader modelReader = new SettingsXpp3Reader(); - - settings = modelReader.read(reader); + try (InputStream is = Files.newInputStream(settingsFile.toPath())) { + SettingsStaxReader reader = new SettingsStaxReader(); + InputSource source = new InputSource(settingsFile.toString()); + return new Settings(reader.read(is, true, source)); } - return settings; } }