Avoid usage of XmlStreamReader (#1256)

This commit is contained in:
Guillaume Nodet 2023-09-22 09:03:47 +02:00 committed by GitHub
parent eb20034763
commit aefa9599fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -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 {

View File

@ -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;
}
}