diff --git a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultRootLocator.java b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultRootLocator.java index beb5a2de3b..c0a28436c2 100644 --- a/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultRootLocator.java +++ b/maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultRootLocator.java @@ -18,6 +18,7 @@ */ package org.apache.maven.internal.impl.model; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -26,7 +27,6 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import com.ctc.wstx.stax.WstxInputFactory; import org.apache.maven.api.di.Named; import org.apache.maven.api.services.model.*; @@ -40,7 +40,7 @@ public class DefaultRootLocator implements RootLocator { // we're too early to use the modelProcessor ... Path pom = dir.resolve("pom.xml"); try (InputStream is = Files.newInputStream(pom)) { - XMLStreamReader parser = new WstxInputFactory().createXMLStreamReader(is); + XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(is); if (parser.nextTag() == XMLStreamReader.START_ELEMENT && parser.getLocalName().equals("project")) { for (int i = 0; i < parser.getAttributeCount(); i++) { diff --git a/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptorBuilder.java b/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptorBuilder.java index 8ac42aa6e2..a912e69d8f 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptorBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/ExtensionDescriptorBuilder.java @@ -18,6 +18,7 @@ */ package org.apache.maven.project; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -30,7 +31,6 @@ import java.util.List; import java.util.jar.JarFile; import java.util.zip.ZipEntry; -import com.ctc.wstx.stax.WstxInputFactory; import org.apache.maven.api.xml.XmlNode; import org.apache.maven.internal.xml.XmlNodeStaxBuilder; @@ -88,7 +88,7 @@ public class ExtensionDescriptorBuilder { XmlNode dom; try { - XMLStreamReader reader = WstxInputFactory.newFactory().createXMLStreamReader(is); + XMLStreamReader reader = XMLInputFactory.newFactory().createXMLStreamReader(is); dom = XmlNodeStaxBuilder.build(reader); } catch (XMLStreamException e) { throw new IOException(e.getMessage(), e); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java index dbd62bebfb..8c2e722c91 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java @@ -108,7 +108,7 @@ public class DefaultModelReader implements ModelReader { private Model read(InputStream input, Path pomFile, Map options) throws IOException { try { - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); XMLStreamReader parser = factory.createXMLStreamReader(input); @@ -132,7 +132,7 @@ public class DefaultModelReader implements ModelReader { private Model read(Reader reader, Path pomFile, Map options) throws IOException { try { - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); XMLStreamReader parser = factory.createXMLStreamReader(reader); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/root/DefaultRootLocator.java b/maven-model-builder/src/main/java/org/apache/maven/model/root/DefaultRootLocator.java index 0321e7b86e..8564a451ac 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/root/DefaultRootLocator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/root/DefaultRootLocator.java @@ -19,6 +19,7 @@ package org.apache.maven.model.root; import javax.inject.Named; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -27,8 +28,6 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import com.ctc.wstx.stax.WstxInputFactory; - @Named public class DefaultRootLocator implements RootLocator { @@ -39,7 +38,7 @@ public class DefaultRootLocator implements RootLocator { // we're too early to use the modelProcessor ... Path pom = dir.resolve("pom.xml"); try (InputStream is = Files.newInputStream(pom)) { - XMLStreamReader parser = new WstxInputFactory().createXMLStreamReader(is); + XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(is); if (parser.nextTag() == XMLStreamReader.START_ELEMENT && parser.getLocalName().equals("project")) { for (int i = 0; i < parser.getAttributeCount(); i++) { diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java index b29b96cd8e..79819f2e34 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java @@ -18,6 +18,7 @@ */ package org.apache.maven.plugin.descriptor; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -30,7 +31,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import com.ctc.wstx.stax.WstxInputFactory; import org.apache.maven.api.xml.XmlNode; import org.apache.maven.internal.xml.XmlNodeStaxBuilder; import org.apache.maven.internal.xml.XmlPlexusConfiguration; @@ -81,11 +81,11 @@ public class PluginDescriptorBuilder { public PluginDescriptor build(ReaderSupplier readerSupplier, String source) throws PlexusConfigurationException { try (BufferedReader br = new BufferedReader(readerSupplier.open(), BUFFER_SIZE)) { br.mark(BUFFER_SIZE); - XMLStreamReader xsr = WstxInputFactory.newFactory().createXMLStreamReader(br); + XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(br); xsr.nextTag(); String nsUri = xsr.getNamespaceURI(); try (BufferedReader br2 = reset(readerSupplier, br)) { - xsr = WstxInputFactory.newFactory().createXMLStreamReader(br2); + xsr = XMLInputFactory.newFactory().createXMLStreamReader(br2); return build(source, nsUri, xsr); } } catch (XMLStreamException | IOException e) { @@ -108,11 +108,11 @@ public class PluginDescriptorBuilder { public PluginDescriptor build(StreamSupplier inputSupplier, String source) throws PlexusConfigurationException { try (BufferedInputStream bis = new BufferedInputStream(inputSupplier.open(), BUFFER_SIZE)) { bis.mark(BUFFER_SIZE); - XMLStreamReader xsr = WstxInputFactory.newFactory().createXMLStreamReader(bis); + XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(bis); xsr.nextTag(); String nsUri = xsr.getNamespaceURI(); try (BufferedInputStream bis2 = reset(inputSupplier, bis)) { - xsr = WstxInputFactory.newFactory().createXMLStreamReader(bis2); + xsr = XMLInputFactory.newFactory().createXMLStreamReader(bis2); return build(source, nsUri, xsr); } } catch (XMLStreamException | IOException e) { @@ -470,7 +470,7 @@ public class PluginDescriptorBuilder { public PlexusConfiguration buildConfiguration(Reader configuration) throws PlexusConfigurationException { try { - XMLStreamReader reader = WstxInputFactory.newFactory().createXMLStreamReader(configuration); + XMLStreamReader reader = XMLInputFactory.newFactory().createXMLStreamReader(configuration); return XmlPlexusConfiguration.toPlexusConfiguration(XmlNodeStaxBuilder.build(reader, true, null)); } catch (XMLStreamException e) { throw new PlexusConfigurationException(e.getMessage(), e); @@ -479,7 +479,7 @@ public class PluginDescriptorBuilder { public PlexusConfiguration buildConfiguration(InputStream configuration) throws PlexusConfigurationException { try { - XMLStreamReader reader = WstxInputFactory.newFactory().createXMLStreamReader(configuration); + XMLStreamReader reader = XMLInputFactory.newFactory().createXMLStreamReader(configuration); return XmlPlexusConfiguration.toPlexusConfiguration(XmlNodeStaxBuilder.build(reader, true, null)); } catch (XMLStreamException e) { throw new PlexusConfigurationException(e.getMessage(), e); diff --git a/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java b/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java index 89df4cf4d5..8d5472b85b 100644 --- a/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java +++ b/maven-repository-metadata/src/test/java/org/apache/maven/artifact/repository/metadata/MetadataTest.java @@ -18,9 +18,6 @@ */ package org.apache.maven.artifact.repository.metadata; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.text.DateFormat; @@ -29,8 +26,6 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; -import com.ctc.wstx.stax.WstxInputFactory; -import com.ctc.wstx.stax.WstxOutputFactory; import org.apache.maven.metadata.v4.MetadataStaxReader; import org.apache.maven.metadata.v4.MetadataStaxWriter; import org.eclipse.aether.artifact.Artifact; @@ -221,9 +216,6 @@ class MetadataTest { @Test void testRoundtrip() throws Exception { - System.setProperty(XMLInputFactory.class.getName(), WstxInputFactory.class.getName()); - System.setProperty(XMLOutputFactory.class.getName(), WstxOutputFactory.class.getName()); - Metadata source = new Metadata(org.apache.maven.api.metadata.Metadata.newBuilder( createMetadataFromArtifact(artifact).getDelegate(), true) .modelEncoding("UTF-16") diff --git a/maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeStaxBuilder.java b/maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeStaxBuilder.java index 311c720b71..caa8781fab 100644 --- a/maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeStaxBuilder.java +++ b/maven-xml-impl/src/main/java/org/apache/maven/internal/xml/XmlNodeStaxBuilder.java @@ -18,6 +18,7 @@ */ package org.apache.maven.internal.xml; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -28,7 +29,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.ctc.wstx.stax.WstxInputFactory; import org.apache.maven.api.xml.XmlNode; /** @@ -40,12 +40,12 @@ public class XmlNodeStaxBuilder { public static XmlNodeImpl build(InputStream stream, InputLocationBuilderStax locationBuilder) throws XMLStreamException { - XMLStreamReader parser = WstxInputFactory.newFactory().createXMLStreamReader(stream); + XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(stream); return build(parser, DEFAULT_TRIM, locationBuilder); } public static XmlNodeImpl build(Reader reader, InputLocationBuilderStax locationBuilder) throws XMLStreamException { - XMLStreamReader parser = WstxInputFactory.newFactory().createXMLStreamReader(reader); + XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(reader); return build(parser, DEFAULT_TRIM, locationBuilder); } diff --git a/maven-xml-impl/src/test/java/org/apache/maven/internal/xml/XmlNodeBuilderTest.java b/maven-xml-impl/src/test/java/org/apache/maven/internal/xml/XmlNodeBuilderTest.java index 5d3f3a0577..779285c5e2 100644 --- a/maven-xml-impl/src/test/java/org/apache/maven/internal/xml/XmlNodeBuilderTest.java +++ b/maven-xml-impl/src/test/java/org/apache/maven/internal/xml/XmlNodeBuilderTest.java @@ -18,12 +18,12 @@ */ package org.apache.maven.internal.xml; +import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; import java.io.IOException; import java.io.StringReader; -import com.ctc.wstx.stax.WstxInputFactory; import org.apache.maven.api.xml.XmlNode; import org.junit.jupiter.api.Test; @@ -49,7 +49,7 @@ class XmlNodeBuilderTest { void testWithNamespace() throws Exception { String doc = ""; StringReader r = new StringReader(doc); - XMLStreamReader xsr = WstxInputFactory.newFactory().createXMLStreamReader(r); + XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(r); XmlNode node = XmlNodeStaxBuilder.build(xsr); assertEquals("doc", node.getName()); assertEquals(1, node.getAttributes().size()); diff --git a/src/mdo/reader-stax.vm b/src/mdo/reader-stax.vm index d253537c5b..692bd2a8a6 100644 --- a/src/mdo/reader-stax.vm +++ b/src/mdo/reader-stax.vm @@ -421,7 +421,7 @@ public class ${className} { #else public ${root.name} read(Reader reader, boolean strict) throws XMLStreamException { #end - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); #if ( $locationTracking ) StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null); @@ -458,7 +458,7 @@ public class ${className} { #else public ${root.name} read(InputStream in, boolean strict) throws XMLStreamException { #end - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); #if ( $locationTracking ) StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null); diff --git a/src/mdo/reader.vm b/src/mdo/reader.vm index 1b7e8a3a7b..dd2150eb66 100644 --- a/src/mdo/reader.vm +++ b/src/mdo/reader.vm @@ -358,7 +358,7 @@ public class ${className} { * @return ${root.name} */ public ${root.name} read(Reader reader, boolean strict) throws IOException, XMLStreamException { - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); XMLStreamReader parser = null; try { @@ -392,7 +392,7 @@ public class ${className} { * @return ${root.name} */ public ${root.name} read(InputStream in, boolean strict) throws IOException, XMLStreamException { - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); StreamSource streamSource = new StreamSource(in, null); XMLStreamReader parser = factory.createXMLStreamReader(streamSource); @@ -409,7 +409,7 @@ public class ${className} { * @return ${root.name} */ public ${root.name} read(InputStream in) throws IOException, XMLStreamException { - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newFactory(); factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); StreamSource streamSource = new StreamSource(in, null); XMLStreamReader parser = factory.createXMLStreamReader(streamSource);