From 1aa19c67e691d62f3d9560fec0cfe7f5443d6497 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 13 Sep 2021 01:47:08 +0200 Subject: Replace XMLReaderFactory deprecated since Java 9 Change-Id: Ie8a9d411fc19e8b7bf86c0b4df0b02153a0e9444 --- .../src/org/eclipse/jgit/gitrepo/ManifestParser.java | 8 +++++--- org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java index 6a2c3898a6..aa69a05112 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java @@ -24,6 +24,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; + import org.eclipse.jgit.annotations.NonNull; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.gitrepo.RepoProject.CopyFile; @@ -37,7 +40,6 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; /** * Repo XML manifest parser. @@ -137,8 +139,8 @@ public class ManifestParser extends DefaultHandler { xmlInRead++; final XMLReader xr; try { - xr = XMLReaderFactory.createXMLReader(); - } catch (SAXException e) { + xr = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); + } catch (SAXException | ParserConfigurationException e) { throw new IOException(JGitText.get().noXMLParserAvailable, e); } xr.setContentHandler(this); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java index 9210ec1721..d56b5b320d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java @@ -31,6 +31,7 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.MessageFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -46,10 +47,11 @@ import java.util.SortedMap; import java.util.TimeZone; import java.util.TreeMap; import java.util.stream.Collectors; -import java.time.Instant; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.Constants; @@ -64,7 +66,6 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; /** * A simple HTTP REST client for the Amazon S3 service. @@ -683,8 +684,9 @@ public class AmazonS3 { final XMLReader xr; try { - xr = XMLReaderFactory.createXMLReader(); - } catch (SAXException e) { + xr = SAXParserFactory.newInstance().newSAXParser() + .getXMLReader(); + } catch (SAXException | ParserConfigurationException e) { throw new IOException( JGitText.get().noXMLParserAvailable, e); } -- cgit v1.2.3